/**
  * load initail data for employee form needed during 
  * creating and editing employee
  * data 
  */
 public function getData()
 {
     global $database;
     $depts = Department::find_all();
     $area = Area::find_all();
     $country = Country::find_all();
     $vendors = Vendor::find_all();
     $zone = Zone::find_by_sql("SELECT * FROM zone");
     $startups = array("departs" => $depts, "country" => $country, "zone" => $zone, "vendors" => $vendors, "area" => $area);
     return $startups;
 }
 public function getData()
 {
     global $database;
     $depts = Department::find_all();
     $role = Roles::find_all();
     $country = Country::find_all();
     $vendors = Vendor::find_all();
     $area = Area::find_all();
     $issues = Issue::find_all();
     $zone = Zone::find_by_sql("SELECT * FROM zone");
     $techEmp = Employee::find_by_sql("SELECT * FROM employee WHERE emp_dept='5'");
     $startups = array("departs" => $depts, "country" => $country, "zone" => $zone, "vendors" => $vendors, "role" => $role, "techemp" => $techEmp, "area" => $area, "issues" => $issues);
     return $startups;
 }
 public function index($mid = 1)
 {
     $productlist = "";
     if (empty($mid)) {
         redirect_to($this->uri->link("error/index"));
         exit;
     }
     $this->loadModel("Clientproduct");
     $datum = $this->model->getList("", "clientproduct");
     $this->view->myclientsproducts = $datum['clientproduct'];
     $this->view->area = Area::find_all();
     global $session;
     $uri = new Url("");
     $productlist .= "<div class='row'><div class='large-12 columns'>";
     $productlist .= "</div></div><div class='row'><div class='large-12 columns'><table  id='dt_basic'>\n            <thead><tr>\n            \t<th>S/N</th><th>Terminal ID</th><th>Product </th><th>Client</th><th>Location</th><th>City </th><th></th><th></th>";
     /**
      * check for priviledge
      * for logged in users
      * at table level
      */
     $productlist .= "<td></td></tr>\n            </thead>\n            <tbody>";
     if ($this->view->myclientsproducts) {
         $x = 1;
         foreach ($this->view->myclientsproducts as $products) {
             $productlist .= "<tr>\n                \t<td>{$x}</td><td>{$products->terminal_id}</td><td><a href='" . $uri->link("clientproduct/detail/" . $products->id) . "'>{$products->prod_name}</a> </td><td>{$products->client_name}</td><td>{$products->install_address}</td><td>{$products->install_city}</td>";
             foreach ($session->employee_role as $erole) {
                 //$emodule = Modules::find_by_module($erole->module);
                 $grant = array();
                 $grant = explode(",", $erole->access);
                 if ($erole->module == "clientproduct") {
                     if (in_array("Modify", $grant)) {
                         $productlist .= "<td><a href='" . $uri->link("clientproduct/edit/" . $products->id . "") . "'>Edit</a></td>";
                     } else {
                         $productlist .= "<td>";
                         $productlist .= "</td>";
                     }
                     if (in_array("Delete", $grant)) {
                         $productlist .= "<td><a class='dataDelete' data-reveal-id='firstModal{$products->id}' href='#'>Delete</a>\n                            \n                            \n                             <div id='firstModal{$products->id}' class='reveal-modal small' style='background-image: linear-gradient(0deg, #f2f9fc, #addcf0 20.0em); border-radius:5px'>\n    <h2>Data Delete Console.</h2>\n    <hr />\n    <p>You are about to delete a record. Any record deleted will not longer be available in the database <br /> Are you sure you want to delete <b>{$products->prod_name}</b> from the database?</p>\n    <p><a href='?url=clientproduct/doCheckTransLog/{$products->main_id}' data-reveal-id='secondModal{$products->id}' class='btn button btn-danger' data-reveal-ajax='true'>Yes</a>&nbsp; &nbsp; &nbsp;<a pdid='{$products->id}' class='btn button btn-danger modalclose'>No</a></p>\n    <a class='close-reveal-modal'>&#215;</a>\n  </div>\n\n  <div id='secondModal{$products->id}' class='reveal-modal small' style='background-image: linear-gradient(0deg, #f2f9fc, #addcf0 20.0em); border-radius:5px'>\n    <h2>This is a second modal.</h2>\n    <hr />\n\n    <a class='close-reveal-modal closemodal'>&#215;</a>\n  </div>\n                            </td><td><a <a href='" . $uri->link("clientproduct/detail/" . $products->id) . "'>Schedule</a></td>";
                     } else {
                         $productlist .= "<td></td>";
                     }
                 }
             }
             $productlist .= "</tr>";
             $x++;
         }
     } else {
         $productlist .= "<tr><td colspan='7'>No record to display</td></tr>";
     }
     $productlist .= "</tbody>\n            </table></div></div><div class='row'><div class='large-12 columns'>";
     $productlist .= "</div><p>&nbsp;</p></div>";
     $this->view->myprods = $productlist;
     /**
      * this aim of doing this check is to
      * ensure that the view is not rendered during
      * when record is being filtered fron the db
      */
     if (Session::getRole()) {
         if (in_array(strtolower(get_class($this)), $_SESSION['emp_role_module'])) {
             if (isset($_POST['areaname'])) {
                 echo $productlist;
             } elseif (isset($_POST['rec'])) {
                 echo $productlist;
             } else {
                 $this->view->render("clientproduct/index");
             }
         } else {
             $this->view->render("access/restricted");
         }
     }
 }