Re: Sending out notification emails if contract expire
Posted: 2014-03-03 15:06
Good day,
Can somebody give me some pointers please? I want to send out a notification email (alert e-mail) to the project manager if a contract expire in a months time and then in3,2 and in a weeks time in the table:
CREATE TABLE IF NOT EXISTS `procurement_reporting_below_r500` (
`procurement_reporting_below_r500k_id` int(11) NOT NULL AUTO_INCREMENT,
`contract_number` varchar(40) DEFAULT NULL,
`programme_name_as_per_budget` int(11) DEFAULT NULL,
`cost_centre_number` varchar(40) DEFAULT NULL,
`type_of_services` text,
`industrial_sector` int(11) DEFAULT NULL,
`planned_method_of_procurement` int(11) DEFAULT NULL,
`total_awarded_value` decimal(1,0) DEFAULT NULL,
`source_of_funding` int(11) DEFAULT NULL,
`advertisement_date` date DEFAULT NULL,
`briefing_session` int(11) NOT NULL,
`briefing_session_date` date DEFAULT NULL,
`closing_date` date DEFAULT NULL,
`evaluation_date` date DEFAULT NULL,
`date_of_adjudication` date DEFAULT NULL,
`contract_signoff_date` date DEFAULT NULL,
`contract_started` date DEFAULT NULL,
`contract_terminated` date DEFAULT NULL,
`contract_duration` varchar(40) DEFAULT NULL,
`project_manager` int(11) DEFAULT NULL,
`delivery_lead_time` varchar(40) DEFAULT NULL,
PRIMARY KEY (`procurement_reporting_below_r500k_id`),
KEY `programme_name_as_per_budget` (`programme_name_as_per_budget`),
KEY `industrial_sector` (`industrial_sector`),
KEY `planned_method_of_procurement` (`planned_method_of_procurement`),
KEY `source_of_funding` (`source_of_funding`),
KEY `briefing_session` (`briefing_session`),
KEY `project_manager` (`project_manager`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
in the hook procurement_planning_above_r500.php the following code is inserted both in before_insert and before_update function and the correct date is displayed
function procurement_planning_above_r500_before_insert(&$data, $memberInfo, &$args){
$std = strtotime($data['contract_started']);
$ste = strtotime($data['contract_terminated']);
$years = date('Y',$ste) - date('Y',$std);
$months = date('m',$ste) - date('m',$std);
if ($months < 0)
{
$years--;
$months = $months + 12;
}
$days = date('d',$ste) - date ('d',$std);
if ($days < 0)
{
$months--;
$days = $days + 30;
}
$data['contract_duration'] = $years . " Years " . $months . " Months " . $days . " Days";
return TRUE;
}
Now: What email code (if I create notifyemail.php) must be written in the notifyemail.php order to notify the project manager of the status of the contract or when budget plans are due? I also presume I must create a cron job as well?
Please assist.
Thank you.
Kind regards.
Mara
Can somebody give me some pointers please? I want to send out a notification email (alert e-mail) to the project manager if a contract expire in a months time and then in3,2 and in a weeks time in the table:
CREATE TABLE IF NOT EXISTS `procurement_reporting_below_r500` (
`procurement_reporting_below_r500k_id` int(11) NOT NULL AUTO_INCREMENT,
`contract_number` varchar(40) DEFAULT NULL,
`programme_name_as_per_budget` int(11) DEFAULT NULL,
`cost_centre_number` varchar(40) DEFAULT NULL,
`type_of_services` text,
`industrial_sector` int(11) DEFAULT NULL,
`planned_method_of_procurement` int(11) DEFAULT NULL,
`total_awarded_value` decimal(1,0) DEFAULT NULL,
`source_of_funding` int(11) DEFAULT NULL,
`advertisement_date` date DEFAULT NULL,
`briefing_session` int(11) NOT NULL,
`briefing_session_date` date DEFAULT NULL,
`closing_date` date DEFAULT NULL,
`evaluation_date` date DEFAULT NULL,
`date_of_adjudication` date DEFAULT NULL,
`contract_signoff_date` date DEFAULT NULL,
`contract_started` date DEFAULT NULL,
`contract_terminated` date DEFAULT NULL,
`contract_duration` varchar(40) DEFAULT NULL,
`project_manager` int(11) DEFAULT NULL,
`delivery_lead_time` varchar(40) DEFAULT NULL,
PRIMARY KEY (`procurement_reporting_below_r500k_id`),
KEY `programme_name_as_per_budget` (`programme_name_as_per_budget`),
KEY `industrial_sector` (`industrial_sector`),
KEY `planned_method_of_procurement` (`planned_method_of_procurement`),
KEY `source_of_funding` (`source_of_funding`),
KEY `briefing_session` (`briefing_session`),
KEY `project_manager` (`project_manager`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
in the hook procurement_planning_above_r500.php the following code is inserted both in before_insert and before_update function and the correct date is displayed
function procurement_planning_above_r500_before_insert(&$data, $memberInfo, &$args){
$std = strtotime($data['contract_started']);
$ste = strtotime($data['contract_terminated']);
$years = date('Y',$ste) - date('Y',$std);
$months = date('m',$ste) - date('m',$std);
if ($months < 0)
{
$years--;
$months = $months + 12;
}
$days = date('d',$ste) - date ('d',$std);
if ($days < 0)
{
$months--;
$days = $days + 30;
}
$data['contract_duration'] = $years . " Years " . $months . " Months " . $days . " Days";
return TRUE;
}
Now: What email code (if I create notifyemail.php) must be written in the notifyemail.php order to notify the project manager of the status of the contract or when budget plans are due? I also presume I must create a cron job as well?
Please assist.
Thank you.
Kind regards.
Mara