Esempio n. 1
0
    public function send_offline_report()
    {
        // I'll leave this here for now
        $facilities_not_synced = Facilities::get_facilities_not_synced();
        // echo "<pre>"; print_r($facilities_not_synced); exit;
        $scp_emails = array("*****@*****.**");
        // $scp_details_all = array();
        // for($i = 0; $i < count($facilities_not_synced); $i++) {
        // 	$scp_details_all = Users::get_scp_details($facilities_not_synced[$i]['district_id']);
        // 	//echo "<pre>"; print_r($facilities_not_synced[$i]);
        // 	// $scp_emails = array_push($scp_details, Users::get_scp_details($facilities_not_synced[$i]['district_id']);
        // }
        $excel_data = array('doc_creator' => 'HCMP-Kenya', 'doc_title' => 'HCMP_Facilities_Not_Synchronized', 'file_name' => 'Facilities_Not_Synchronized');
        $column_data = array("District Name", "Facility Name", "MFL", "Days From Last Synchronization");
        $excel_data['column_data'] = $column_data;
        $row_data = array();
        foreach ($facilities_not_synced as $facilities_not_synced) {
            array_push($row_data, array($facilities_not_synced['district_name'], $facilities_not_synced['facility_name'], $facilities_not_synced['facility_code'], $facilities_not_synced['days_from_last_sync']));
        }
        $excel_data['row_data'] = $row_data;
        $excel_data['report_type'] = 'Email Attachment';
        $file = $this->hcmp_functions->create_new_excel($excel_data);
        $message = '';
        $message .= "<style> table {\n\t\t\tborder-collapse: collapse; \n\t\t}td,th{\n\t\t\tpadding: 12px;\n\t\t\ttext-align:center;\n\t\t}\n\n\t\t*{margin:0;padding:0}*{font-family:'Helvetica Neue',Helvetica,Helvetica,Arial,sans-serif}img{max-width:100%}.collapse{padding:0}body{-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:none;width:100%!important;height:100%}a{color:#2BA6CB}.btn{text-decoration:none;color:#FFF;background-color:#666;padding:10px 16px;font-weight:700;margin-right:10px;text-align:center;cursor:pointer;display:inline-block}p.callout{padding:15px;background-color:#ECF8FF;margin-bottom:15px}.callout a{font-weight:700;color:#2BA6CB}table.social{background-color:#ebebeb}.social .soc-btn{padding:3px 7px;font-size:12px;margin-bottom:10px;text-decoration:none;color:#FFF;font-weight:700;display:block;text-align:center}a.fb{background-color:#3B5998!important}a.tw{background-color:#1daced!important}a.gp{background-color:#DB4A39!important}a.ms{background-color:#000!important}.sidebar .soc-btn{display:block;width:100%}table.head-wrap{width:100%}.header.container table td.logo{padding:15px}.header.container table td.label{padding:15px 15px 15px 0}table.body-wrap{width:100%}table.footer-wrap{width:100%;clear:both!important}.footer-wrap .container td.content p{border-top:1px solid #d7d7d7;padding-top:15px;font-size:9px;font-weight:500}h1,h2,h3,h4,h5,h6{font-family:HelveticaNeue-Light,'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;line-height:1.1;margin-bottom:15px;color:#000}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-size:60%;color:#6f6f6f;line-height:0;text-transform:none}h1{font-weight:200;font-size:44px}h2{font-weight:200;font-size:37px}h3{font-weight:500;font-size:27px}h4{font-weight:500;font-size:23px}h5{font-weight:900;font-size:17px}h6{font-weight:900;font-size:14px;text-transform:uppercase;color:#444}.collapse{margin:0!important}p,ul{margin-bottom:10px;font-weight:400;font-size:14px;line-height:1.6}p.lead{font-size:17px}p.last{margin-bottom:0}ul li{margin-left:5px;list-style-position:inside}ul.sidebar{background:#ebebeb;display:block;list-style-type:none}ul.sidebar li{display:block;margin:0}ul.sidebar li a{text-decoration:none;color:#666;padding:10px 16px;cursor:pointer;border-bottom:1px solid #777;border-top:1px solid #FFF;display:block;margin:0}ul.sidebar li a.last{border-bottom-width:0}ul.sidebar li a h1,ul.sidebar li a h2,ul.sidebar li a h3,ul.sidebar li a h4,ul.sidebar li a h5,ul.sidebar li a h6,ul.sidebar li a p{margin-bottom:0!important}.container{display:block!important;max-width:100%!important;margin:0 auto!important;clear:both!important}.content{padding:15px;max-width:80%px;margin:0 auto;display:block}.content table{width:100%}.column{width:300px;float:left}.column tr td{padding:15px}.column-wrap{padding:0!important;margin:0 auto;max-width:600px!important}.column table{width:100%}.social .column{width:280px;min-width:279px;float:left}.clear{display:block;clear:both}@media only screen and (max-width:600px){a[class=btn]{display:block!important;margin-bottom:10px!important;background-image:none!important;margin-right:0!important}div[class=column]{width:auto!important;float:none!important}table.social div[class=column]{width:auto!important}}</style>";
        $message .= '
		<tr>
			<td colspan="12">
			</tr>
		</tbody>
			</table>';
        $message .= "<!-- BODY -->\n\t\t<table class='body-wrap'>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td class='container' bgcolor='#FFFFFF'>\n\n\t\t\t\t\t<div class='content'>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>\n\n\t\t\t\t\t\t\t\t\t<p class='lead'>Find attached a summary of Facility Not Synchronized for more than 30 days</p>\n\t\t\t\t\t\t\t\t\t<table class='social' width='100%'>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>\n\n\t\t\t\t\t\t\t\t\t\t\t\t<!-- column 1 -->\n\t\t\t\t\t\t\t\t\t\t\t\t<table align='left' class='column'>\n\n\t\t\t\t\t\t\t\t\t\t\t\t</table><!-- /column 1 -->\t\n\n\t\t\t\t\t\t\t\t\t\t\t\t<!-- column 2 -->\n\t\t\t\t\t\t\t\t\t\t\t\t<table align='left' class='column'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t</table><!-- /column 2 -->\n\n\t\t\t\t\t\t\t\t\t\t\t\t<span class='clear'></span>\t\n\n\t\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t</table><!-- /social & contact -->\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</div><!-- /content -->\n\n\t\t\t\t</td>\n\t\t\t\t<td></td>\n\t\t\t</tr>\n\t\t</table><!-- /BODY -->";
        $handler = "./print_docs/excel/excel_files/" . $excel_data['file_name'] . ".xls";
        $subject = "Facilities Not Synchronized";
        // echo "<pre>"; var_dump($scp_emails); var_dump($message); var_dump($subject); var_dump($handler); exit;
        $status = $this->hcmp_functions->send_email($scp_emails, $message, $subject, $handler);
    }