예제 #1
0
    public function create_order_delivery_color_coded_table($order_id)
    {
        // get the order and order details here
        $detail_list = facility_order_details::get_order_details($order_id, true);
        $dates = facility_orders::get_order_($order_id)->toArray();
        $facility_name = Facilities::get_facility_name_($dates[0]['facility_code'])->toArray();
        $facility_name = $facility_name[0]['facility_name'];
        //set up the details
        $table_body = "";
        $total_fill_rate = 0;
        $order_value = 0;
        //get the lead time
        $ts1 = strtotime(date($dates[0]["order_date"]));
        $ts2 = strtotime(date($dates[0]["deliver_date"]));
        $seconds_diff = $ts2 - $ts1;
        //strtotime($a_date) ? date('d M, Y', strtotime($a_date)) : "N/A";
        $date_diff = strtotime($dates[0]["deliver_date"]) ? floor($seconds_diff / 3600 / 24) : "N/A";
        $order_date = strtotime($dates[0]["order_date"]) ? date('D j M, Y', $ts1) : "N/A";
        $deliver_date = strtotime($dates[0]["deliver_date"]) ? date('D j M, Y', $ts2) : "N/A";
        $kemsa_order_no = $dates[0]['kemsa_order_id'];
        $order_total = number_format($dates[0]['order_total'], 2, '.', ',');
        $actual_order_total = number_format($date[0]['deliver_total'], 2, '.', ',');
        $tester = count($detail_list);
        if ($tester == 0) {
        } else {
            foreach ($detail_list as $rows) {
                //setting the values to display
                $received = $rows['quantity_recieved'];
                $price = $rows['unit_cost'];
                $ordered = $rows['quantity_ordered_unit'];
                $code = $rows['commodity_id'];
                $drug_name = $rows['commodity_name'];
                $kemsa_code = $rows['commodity_code'];
                $unit_size = $rows['unit_size'];
                $total_units = $rows['total_commodity_units'];
                $cat_name = $rows['sub_category_name'];
                $received = round(@$received / $total_units);
                $fill_rate = round(@($received / $ordered) * 100);
                $total = $price * $ordered;
                $total_ = $price * $received;
                $total_fill_rate = $total_fill_rate + $fill_rate;
                switch (true) {
                    case $fill_rate == 0:
                        $table_body .= "<tr style='background-color: #FBBBB9;'>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                    case $fill_rate <= 60:
                        $table_body .= "<tr style=' background-color: #FAF8CC;'>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                    case $fill_rate > 100.01:
                    case $fill_rate == 100.01:
                        $table_body .= "<tr style='background-color: #ea1e17'>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                    case $fill_rate == 100:
                        $table_body .= "<tr style=' background-color: #C3FDB8;'>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                    default:
                        $table_body .= "<tr>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                }
            }
            $order_value = round($total_fill_rate / count($detail_list), 0, PHP_ROUND_HALF_UP);
        }
        $message = <<<HTML_DATA
\t<table>
\t\t\t<tr>
\t\t<th colspan='11'>
\t\t<p>{$facility_name}</p>
\t\t<p>Fill rate(Quantity Ordered/Quantity Received)</p>
         <p style="letter-spacing: 1px;font-weight: bold;text-shadow: 0 1px rgba(0, 0, 0, 0.1);">
Facility Order No {$order_id}| KEMSA Order No {$kemsa_order_no} | Total ordered value(ksh) {$order_total} | Total recieved order value(ksh) {$actual_order_total} |Date Ordered {$order_date}| Date Delivered {$deliver_date}| Order lead Time {$date_diff}; day(s)</p>
\t\t</th>
\t\t</tr>
\t\t<tr>
\t\t<th width="50px" style="background-color: #C3FDB8; "></th>
\t\t<th>Full Delivery 100%</th>
\t\t<th width="50px" style="background-color:#FFFFFF"></th>
\t\t<th>Ok Delivery 60%-less than 100%</th>
\t\t<th width="50px" style="background-color:#FAF8CC;"></th> 
\t\t<th>Partial Delivery less than 60% </th>
\t\t<th width="50px" style="background-color:#FBBBB9;"></th>
\t\t<th>Problematic Delivery 0% </th>
\t\t<th width="50px" style="background-color:#ea1e17;"></th>
\t\t<th>Problematic Delivery over 100%</th>
\t\t</tr></table> </br></n>
<table id="main1" width="100%" class="row-fluid table table-bordered">
\t<thead>
\t\t<tr>
\t\t<th><strong>Category</strong></th>
\t\t<th><strong>Description</strong></th>
\t\t<th><strong>Commodity Code</strong></th>
\t\t<th><strong>Unit Size</strong></th>
\t\t<th><strong>Unit Cost Ksh</strong></th>
\t\t<th><strong>Quantity Ordered</strong></th>
\t\t<th><strong>Total Cost</strong></th>
\t\t<th><strong>Quantity Received</strong></th>
\t\t<th><strong>Total Cost</strong></th>
\t\t<th><strong>Fill rate</strong></th>\t
\t\t</tr>
\t</thead>
\t<tbody>\t
\t\t {$table_body}\t
\t</tbody>
</table>
<br></n>
HTML_DATA;
        return array('table' => $message, 'date_ordered' => $order_date, 'date_received' => $deliver_date, 'order_total' => $order_total, 'actual_order_total' => $actual_order_total, 'lead_time' => $date_diff, 'facility_name' => $facility_name);
    }
예제 #2
0
 public function update_meds_order_delivery($order_id)
 {
     $facility_code = $this->session->userdata('facility_id');
     $data['content_view'] = "facility/facility_orders/update_order_delivery_from_meds_v";
     $data['title'] = "Facility Update Order Delivery";
     $data['facility_commodity_list'] = Commodities::get_all_from_meds(2);
     $data['order_details'] = facility_order_details::get_order_details($order_id);
     $data['general_order_details'] = facility_orders::get_order_($order_id);
     $data['banner_text'] = "Facility MEDS Update Order Delivery";
     $ordered_by = $data['general_order_details'][0]['ordered_by'];
     $data['ordered_by'] = users::get_user_names($ordered_by);
     $this->load->view('shared_files/template/template', $data);
 }
예제 #3
0
 public function update_order_delivery($order_id)
 {
     $facility_code = $this->session->userdata('facility_id');
     $data['content_view'] = "facility/facility_orders/update_order_delivery_from_kemsa_v";
     $data['title'] = "Facility Update Order Delivery";
     $data['facility_commodity_list'] = Commodities::get_all_from_supllier(1);
     $data['order_details'] = facility_order_details::get_order_details($order_id);
     $data['general_order_details'] = facility_orders::get_order_($order_id);
     $data['banner_text'] = "Facility Update Order Delivery";
     $this->load->view('shared_files/template/template', $data);
 }