. */ /** * @brief Contains the functions to manage visa and notice workflow. * * @file * @author Nicolas Couture * @date $date$ * @version $Revision$ * @ingroup visa */ class visa extends dbquery { /*** * Build Maarch module tables into sessions vars with a xml configuration file * * */ public function build_modules_tables() { if (file_exists( $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "visa" . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "config.xml" ) ) { $configPath = $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "visa" . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "config.xml"; } else { $configPath = "modules" . DIRECTORY_SEPARATOR . "visa" . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "config.xml"; } $xmlconfig = simplexml_load_file($configPath); $conf = $xmlconfig->CONFIG; $_SESSION['modules_loaded']['visa']['exeSign'] = (string) $conf->exeSign; $_SESSION['modules_loaded']['visa']['reason'] = (string) $conf->reason; $_SESSION['modules_loaded']['visa']['location'] = (string) $conf->location; $_SESSION['modules_loaded']['visa']['licence_number'] = (string) $conf->licence_number; $routing_template = (string) $conf->routing_template; if (file_exists( $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "visa" . DIRECTORY_SEPARATOR . "Bordereau_visa_modele.pdf" ) ) { $routing_template = $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "visa" . DIRECTORY_SEPARATOR . "Bordereau_visa_modele.pdf"; } $_SESSION['modules_loaded']['visa']['routing_template'] = $routing_template; } public function getWorkflow($res_id, $coll_id, $typeList){ require_once('modules/entities/class/class_manage_listdiff.php'); $listdiff = new diffusion_list(); $roles = $listdiff->list_difflist_roles(); $circuit = $listdiff->get_listinstance($res_id, false, $coll_id, $typeList); if (isset($circuit['copy'])) unset($circuit['copy']); return $circuit; } public function saveWorkflow($res_id, $coll_id, $workflow, $typeList){ require_once('modules/entities/class/class_manage_listdiff.php'); $diff_list = new diffusion_list(); $diff_list->save_listinstance( $workflow, $typeList, $coll_id, $res_id, $_SESSION['user']['UserId'], $_SESSION['user']['primaryentity']['id'] ); } public function saveModelWorkflow($id_list, $workflow, $typeList, $title){ require_once('modules/entities/class/class_manage_listdiff.php'); $diff_list = new diffusion_list(); $diff_list->save_listmodel( $workflow, $typeList, $id_list, $title ); } public function deleteWorkflow($res_id, $coll_id){ $this->connect(); $this->query("DELETE FROM visa_circuit WHERE res_id=$res_id AND coll_id='$coll_id'"); } public function nbVisa($res_id, $coll_id){ $this->connect(); $this->query("SELECT listinstance_id from listinstance WHERE res_id=$res_id and coll_id = '$coll_id' and item_mode = 'visa'"); return $this->nb_result(); } public function getCurrentStep($res_id, $coll_id, $listDiffType){ $this->connect(); $this->query("SELECT sequence, item_mode from listinstance WHERE res_id=$res_id and coll_id = '$coll_id' and difflist_type = '$listDiffType' and process_date ISNULL ORDER BY listinstance_id ASC LIMIT 1"); $res=$this->fetch_object(); if ($res->item_mode == 'sign'){ return $this->nbVisa($res_id, $coll_id); } return $res->sequence; } public function myPosVisa($res_id, $coll_id, $listDiffType){ $this->connect(); $this->query("SELECT sequence, item_mode from listinstance WHERE res_id=$res_id and coll_id = '$coll_id' and difflist_type = '$listDiffType' and item_id = '".$_SESSION['user']['UserId']."' ORDER BY listinstance_id ASC LIMIT 1"); $res=$this->fetch_object(); if ($res->item_mode == 'sign'){ return $this->nbVisa($res_id, $coll_id); } return $res->sequence; } public function getUsersVis(){ $requete_users = "SELECT users.user_id, users.firstname, users.lastname from users, usergroup_content WHERE users.user_id = usergroup_content.user_id AND group_id IN (SELECT group_id FROM usergroups_services WHERE service_id = 'visa_documents') ORDER BY users.lastname"; $db_users = new dbquery(); $db_users->connect(); $db_users->query($requete_users); $tab_users = array(); while($res = $db_users->fetch_object()){ array_push($tab_users,array('id'=>$res->user_id, 'firstname'=>$res->firstname,'lastname'=>$res->lastname)); } return $tab_users; } public function allUserVised($res_id, $coll_id, $typeList){ $circuit = $this->getWorkflow($res_id, $coll_id, 'VISA_CIRCUIT'); if (isset($circuit['visa'])) { foreach($circuit['visa']['users'] as $seq=>$step){ if ($step['process_date'] == ''){ return false; } } } return true; } public function getConsigne($res_id, $coll_id, $userId){ $circuit = $this->getWorkflow($res_id, $coll_id, 'VISA_CIRCUIT'); if (isset($circuit['visa'])) { foreach($circuit['visa']['users'] as $seq=>$step){ if ($step['user_id'] == $userId){ return $step['process_comment']; } } } if (isset($circuit['sign'])) { foreach($circuit['sign']['users'] as $seq=>$step){ if ($step['user_id'] == $userId){ return $step['process_comment']; } } } return ''; } public function getList($res_id, $coll_id, $bool_modif=false, $typeList, $isVisaStep = false){ $core_tools =new core_tools(); if ( $typeList == 'VISA_CIRCUIT'){ $id_tab="tab_visaSetWorkflow"; $id_form="form_visaSetWorkflow"; } else{ $id_tab="tab_avisSetWorkflow"; $id_form="form_avisSetWorkflow"; } $circuit = $this->getWorkflow($res_id, $coll_id, $typeList); if (!isset($circuit['visa']['users']) && !isset($circuit['sign']['users']) && !$core_tools->test_service('config_visa_workflow', 'visa', false)){ $str .= '
'._EMPTY_USER_LIST.'
'; } else{ require_once('modules/entities/class/class_manage_listdiff.php'); $diff_list = new diffusion_list(); $listModels = $diff_list->select_listmodels($typeList); $str .= '
'; $str .= '
'; if (!empty($listModels) && $bool_modif && !$isVisaStep){ $str .= ''; } $str .= ''; $str .= ''; $str .= ''; if ($bool_modif){ $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; } else{ $str .= ''; $str .= ''; } $str .= ''; $str .= ''; $color = ""; if ($typeList == 'VISA_CIRCUIT'){ if (!isset($circuit['visa']['users']) && !isset($circuit['sign']['users'])){ $j=0; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; } else{ if ($isVisaStep) $myPosVisa = $this->myPosVisa($res_id, $coll_id, $typeList); if (isset($circuit['visa']['users'])){ foreach($circuit['visa']['users'] as $seq=>$step){ if($color == ' class="col"') { $color = ''; } else { $color = ' class="col"'; } $str .= ''; //$str .= ''; if ($bool_modif){ $str .= ''; $up = ' style="visibility:visible"'; $displayCB = ' style="visibility:hidden"'; $checkCB = ''; if ($isVisaStep && $myPosVisa >= $seq) $down = ' style="visibility:hidden"'; else $down = ' style="visibility:visible"'; if ($isVisaStep && $myPosVisa >= $seq) $del = ' style="visibility:hidden"'; else $del = ' style="visibility:visible"'; if (empty($circuit['sign']['users']) && $seq == count ($circuit['visa']['users'])-1){ $add = ' style="visibility:visible"'; $down = ' style="visibility:hidden"'; $displayCB = ' style="visibility:hidden"'; $checkCB = ' checked'; } else{ $add = ' style="visibility:hidden"'; } if ($isVisaStep && $myPosVisa >= $seq) $displayCB = ' style="visibility:hidden"'; if ($seq == 0 || ($isVisaStep && $myPosVisa+1 >= $seq)){ $up = ' style="visibility:hidden"'; } $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; } else{ $str .= ''; $str .= ''; if ($step['process_date'] != '') $str .= ''; elseif ($step['user_id'] == $_SESSION['user']['UserId']) $str .= ''; else $str .= ''; } $str .= ''; } } //ajout signataire if (!empty($circuit['sign']['users'])){ $seq = count ($circuit['visa']['users']); if($color == ' class="col"') { $color = ''; } else { $color = ' class="col"'; } $str .= ''; if ($bool_modif){ if ($isVisaStep && $myPosVisa >= $seq) $disabled = ' disabled '; else $disabled = ''; $str .= ''; if ($isVisaStep && ($myPosVisa+1 == $seq || $myPosVisa == $seq)) $up = ' style="visibility:hidden"'; else $up = ' style="visibility:visible"'; $down = ' style="visibility:hidden"'; if ($isVisaStep && $myPosVisa == $seq) $add = ' style="visibility:hidden"'; else $add = ' style="visibility:visible"'; if ($isVisaStep && $myPosVisa == $seq) $del = ' style="visibility:hidden"'; else $del = ' style="visibility:visible"'; $displayCB = ' style="visibility:hidden"'; if ($isVisaStep && $myPosVisa == $seq) $displayCB = ' style="visibility:hidden"'; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; } else{ $str .= ''; $str .= ''; if ($circuit['sign']['users'][0]['process_date'] != '') $str .= ''; elseif ($circuit['sign']['users'][0]['user_id'] == $_SESSION['user']['UserId']) $str .= ''; else $str .= ''; } $str .= ''; } } } $str .= ''; $str .= '
VisaConsigneConsigneEtat
'; if ($bool_modif){ $tab_users = $this->getUsersVis(); $str .= ''; } $str .= '
' . $seq+1 . ''; $tab_users = $this->getUsersVis(); if ($isVisaStep && $myPosVisa >= $seq) $disabled = ' disabled '; else $disabled = ''; $str .= ''; $str .= ''.$step['firstname'].' '.$step['lastname']; $str .= ''.$step['process_comment'].'
'; $tab_users = $this->getUsersVis(); $str .= ''; $str .= ''.$circuit['sign']['users'][0]['firstname'].' '.$circuit['sign']['users'][0]['lastname']; $str .= ''.$circuit['sign']['users'][0]['process_comment'].'
'; if ($bool_modif){ $str .= ' '; $str .= ''; $str .= '
'; $str .= '

Sauvegarder le circuit de visa

'; $str .= '
'; $str .= ' '; $str .= '
'; $str .= ' '; $str .= ''; $str .= '
'; } $str .= '
'; } return $str; } } /* EXEMPLE TAB VISA_CIRCUIT Array ( [coll_id] => letterbox_coll [res_id] => 190 [difflist_type] => entity_id [sign] => Array ( [users] => Array ( [0] => Array ( [user_id] => sgros [lastname] => GROS [firstname] => Sébastien [entity_id] => CHEFCABINET [entity_label] => Chefferie [visible] => Y [viewed] => 0 [difflist_type] => VISA_CIRCUIT [process_date] => [process_comment] => ) ) ) [visa] => Array ( [users] => Array ( [0] => Array ( [user_id] => sbes [lastname] => BES [firstname] => Stéphanie [entity_id] => CHEFCABINET [entity_label] => Chefferie [visible] => Y [viewed] => 0 [difflist_type] => VISA_CIRCUIT [process_date] => [process_comment] => ) [1] => Array ( [user_id] => fbenrabia [lastname] => BENRABIA [firstname] => Fadela [entity_id] => POLESOCIAL [entity_label] => Pôle social [visible] => Y [viewed] => 0 [difflist_type] => VISA_CIRCUIT [process_date] => [process_comment] => ) [2] => Array ( [user_id] => bpont [lastname] => PONT [firstname] => Brieuc [entity_id] => POLEAFFAIRESETRANGERES [entity_label] => Pôle affaires étrangères [visible] => Y [viewed] => 0 [difflist_type] => VISA_CIRCUIT [process_date] => [process_comment] => ) ) ) ) */ ?>