\n"; echo "\n"; // Initial value $equipment_available = 0; /************************************/ /* Title */ /************************************/ print_title("Assign equipment"); // Retrieve all device types $types = db_fetch_system_devices($_SESSION[$_PAGE_INFO['id']]['i18n']); // Determine amount per device type if (is_array($types)) { // Retrieve project information $projects = db_fetch_projects("", $_SESSION[$_PAGE_INFO['id']]['login']['customer']['id'], 1); foreach($types as $type) { // Retrieve lance information $lances = db_fetch_lances($_SESSION[$_PAGE_INFO['id']]['login']['customer']['id'], "", $type['id'], "", array("service", "winkel", "actief")); if ((is_array($lances)) && (!empty($lances))) { $equipment_available = 1; /************************************/ /* Subtitle */ /************************************/ print_subtitle($type['naam']); /************************************/ /* Equipment Overview */ /************************************/ // Fill arrays $id = ""; $id[0] = ""; $value = ""; $value[0] = array("","",""); // Initial values $owned = 0; $hire = 0; $service = 0; $rented = 0; $inactive = 0; $owned_array = array(); $hire_array = array(); $total_array = array(); $service_array = array(); $rented_array = array(); $rented_to_array = array(); $inactive_array = array(); $available_array = array(); $assigned_array = array(); $result_array = array(); $multiple_array = array(); if (is_array($lances)) { foreach($lances as $lance) { // Owner? if ($lance['eigenaar'] == $_SESSION[$_PAGE_INFO['id']]['login']['customer']['id']) { $owned++; array_push($owned_array , ",- " . $lance['idcode']); array_push($total_array , ",- " . $lance['idcode']); array_push($available_array, ",- " . $lance['idcode']); } // hired? else if ($lance['gebruiker'] == $_SESSION[$_PAGE_INFO['id']]['login']['customer']['id']) { $hire++; $cust = db_fetch_customer($lance['gebruiker'], 1); array_push($hire_array , ",- " . $lance['idcode'] . " (" . $cust['bedrijfsnaam'] . ")"); array_push($total_array , ",- " . $lance['idcode']); array_push($available_array, ",- " . $lance['idcode']); } // In service? if (in_array($lance['lans_status'], array("service", "winkel"))) { $service++; array_push($service_array, ",- " . $lance['idcode']); } // Rented? else if ((strlen($lance['gebruiker'])) && ($lance['gebruiker'] != $_SESSION[$_PAGE_INFO['id']]['login']['customer']['id'])) { $rented++; $cust = db_fetch_customer($lance['gebruiker'], 1); array_push($rented_to_array , ",- " . $lance['idcode'] . " (" . $cust['bedrijfsnaam'] . ")"); array_push($rented_array, ",- " . $lance['idcode']); } // Non-active else if (in_array($lance['klant_status'], array("inactief"))) { $inactive++; array_push($inactive_array, ",- " . $lance['idcode']); } } } // Remove service/rented/non-active/assigned from available array if (is_array($available_array)) { if (is_array($service_array)) { foreach($service_array as $item) { $pos = array_search($item, $available_array); array_splice($available_array, $pos, 1); } } if (is_array($rented_array)) { foreach($rented_array as $item) { $pos = array_search($item, $available_array); array_splice($available_array, $pos, 1); } } if (is_array($inactive_array)) { foreach($inactive_array as $item) { $pos = array_search($item, $available_array); array_splice($available_array, $pos, 1); } } } // Assigned/Requested $request = 0; $assigned = 0; $open_request = 0; $result_array = $available_array; if (is_array($projects)) { foreach($projects as $project) { // Requested $amount = db_fetch_project_amounts($project['id'], $type['id']); $request += $amount['aantal']; // Assigned (only non-rented and active equipment) $project_lances = db_fetch_project_lances($project['id'], $type['id'], "", 1, array("actief"),array("actief")); if (is_array($project_lances)) { $assigned_project = sizeof($project_lances); foreach($project_lances as $lance) { array_push($assigned_array, ",- " . $lance['idcode']); // In result array? => Remove $pos = array_search(",- " . $lance['idcode'], $result_array); if ($pos !== FALSE) { array_splice($result_array, $pos, 1); } } } else { $assigned_project = 0; } $assigned = $assigned + $assigned_project; // Open request if ($amount['aantal'] > $assigned_project) { $open_request += $amount['aantal'] - $assigned_project; } } } // Multiple assignments (only active, rest is handled by service/non-active!!) $multiple_assigned = db_fetch_project_double_assigned_lances($_SESSION[$_PAGE_INFO['id']]['login']['customer']['id'], $type['id'], array("actief"), array("actief")); $multiple = 0; if (is_array($multiple_assigned)) { foreach($multiple_assigned as $item) { if (db_check_lance_active($item, $_SESSION[$_PAGE_INFO['id']]['login']['customer']['id'])) { $lance_projects = db_fetch_lance_projects($item, 1, $_SESSION[$_PAGE_INFO['id']]['login']['customer']['id']); if (is_array($lance_projects)) { $lance = db_fetch_lance($item, "", 1); for($i=0; $i < sizeof($lance_projects); $i++) { array_push($multiple_array, ",- " . $lance['idcode']); $multiple++; } } } } } // Counters $value[1] = array(color => "" ,"Owned" , $owned); $value[2] = array(color => "" ,"Hired" , $hire); $value[3] = array(color => "" ,"" , "------- +"); $value[4] = array(color => "" ,"Total fleet" , $owned + $hire); $value[5] = array(color => "service" ,"In service" , $service); $value[6] = array(color => "rented" ,"Hired out" , $rented); $value[7] = array(color => "inactive" ,"Inactive" , $inactive); $value[8] = array(color => "" ,"" , "------- -"); $value[9] = array(color => "" ,"Available" , $owned + $hire - $service - $rented - $inactive); $value[10] = array(color => "" ,"Assigned to project" , $assigned); $value[11] = array(color => "" ,"" , "------- -"); $value[12] = array(color => "" ,"Result" , $owned + $hire - $service - $rented - $inactive - $assigned); $value[13] = array(color => "d_assigned_project" ,"Multiple project assignments" , $multiple); $value[14] = array(color => "" ,"Open requests" , $open_request); // Sort all arrays array_multisort($owned_array, SORT_STRING, $owned_array); array_multisort($hire_array, SORT_STRING, $hire_array); array_multisort($total_array, SORT_STRING, $total_array); array_multisort($service_array, SORT_STRING, $service_array); array_multisort($rented_to_array, SORT_STRING, $rented_to_array); array_multisort($inactive_array, SORT_STRING, $inactive_array); array_multisort($available_array, SORT_STRING, $available_array); array_multisort($assigned_array, SORT_STRING, $assigned_array); array_multisort($multiple_array, SORT_STRING, $multiple_array); // Popup message $id[1] = (empty($owned_array)) ? "" : _("Owned") . ":" . implode($owned_array); $id[2] = (empty($hire_array)) ? "" : _("Hired") . ":" . implode($hire_array); $id[3] = ""; $id[4] = (empty($total_array)) ? "" : _("Total fleet") . ":" . implode($total_array); $id[5] = (empty($service_array)) ? "" : _("In service") . ":" . implode($service_array); $id[6] = (empty($rented_to_array))? "" : _("Hired out") . ":" . implode($rented_to_array); $id[7] = (empty($inactive_array)) ? "" : _("Inactive") . ":" . implode($inactive_array); $id[8] = ""; $id[9] = (empty($available_array))? "" : _("Available") . ":" . implode($available_array); $id[10] = (empty($assigned_array)) ? "" : _("Assigned to project") . ":" . implode($assigned_array); $id[11] = ""; $id[12] = (empty($result_array)) ? "" : _("Result") . ":" . implode($result_array); $id[13] = (empty($multiple_array)) ? "" : _("Multiple project assignments") . ":" . implode($multiple_array); $id[14] = ""; // Set values $value1[1] = array((is_array($lances)) ? sizeof($lances) : 0, $req, $grant, sizeof($unassinged_lances)); print_table(_("Totals overview"), $type['id'] . "_total", $value, "", $id, array(54,24,18), array("L","C","L"), "", "onSubmit('show_equip', '', 1);", "", "", 0, 1); /************************************/ /* Project overview */ /************************************/ // Fill arrays $id = ""; $id[0] = ""; $opt = ""; $opt[0] = ""; $value = ""; $value[0] = array("Project", "Requested", "Expected", "Assigned"); if (is_array($projects)) { foreach($projects as $project) { // Expected/Assigned $project_lances = db_fetch_project_lances($project['id'], $type['id'], "", 0, array("service","winkel", "actief")); $assigned = 0; $expected = 0; if (is_array($project_lances)) { foreach($project_lances as $project_lance) { if (db_check_lance_active($project_lance['id'], $_SESSION[$_PAGE_INFO['id']]['login']['customer']['id'])) { $assigned++; } else { $expected++; } } } // Add project shortcut array_push($id, $project['id']); // Get project amounts $amount = db_fetch_project_amounts($project['id'], $type['id']); $amount['aantal'] = (is_array($amount)) ? $amount['aantal'] : 0; // Color assignment $color = db_check_project_color($project['id'], $type['id'], $_SESSION[$_PAGE_INFO['id']]['login']['customer']['id']); // Get all info array_push($value, array($project['naam'], $amount['aantal'], $expected, $assigned, color => $color)); } } // Show when not empty if (sizeof($value) > 1) { print_table(ucfirst(_("projects")), $type['id'] . "_id", $value, "", $id, array(34, 22, 22, 22), array("L","C","C","C"), array(), "onSubmit('project', '', 0);", "", "", 0, 1); } } } } if (!$equipment_available) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "
\n"; echo _("There is no equipment to assign"); echo "
\n"; echo "\n"; ?>