id_tache = $id_tache; } //formulaire spécifique au type de tâche function show_form ($param='') { global $msg, $pmb_lecteurs_localises, $empr_sort_rows, $empr_show_rows, $empr_filter_rows, $deflt2docs_location; // //paramètres pré-enregistré // $lst_opt = array(); // if ($param['chk_loan']) { // foreach ($param['chk_loan'] as $elem) { // $lst_opt[$elem] = $elem; // } // } // $loc_selected = ($param["empr_location_id"] ? $param["empr_location_id"] : ""); //Automatisation sur les prêts $form_task .= "
".$this->msg["loan_all_actions"]."
".$this->msg["loan_print_mail"]."
".$this->msg["loan_csv_mail"]."
 
"; if (($empr_sort_rows)||($empr_show_rows)||($empr_filter_rows)) { if ($pmb_lecteurs_localises) $localisation=",l"; $filter=new filter_list("empr","empr_list","b,n,c,g","b,n,c,g".$localisation.",2,3,cs","n,g"); if ($pmb_lecteurs_localises) { $lo="f".$filter->fixedfields["l"]["ID"]; global $$lo; if (!$$lo) { $tableau=array(); $tableau[0]=$deflt2docs_location; $$lo=$tableau; } } $filter->fixedcolumns="b,n,c"; $filter->original_query=$requete; $filter->multiple=1; $filter->select_original="table_filter_tempo.empr_nb,empr_mail"; $filter->original_query="select id_empr,count(pret_idexpl) as empr_nb from empr,pret where pret_retourfrom_original=""; $filter->activate_filters(); if (!$filter->error) { $t_filters = explode(",",$filter->filtercolumns); foreach ($t_filters as $i=>$f) { if ((substr($s[$i],0,1)=="#")&&($filter->params["REFERENCE"][0]["DYNAMICFIELDS"]=="yes")) { //Faut-il adapter les champs perso ?? } elseif (array_key_exists($t_filters[$i],$filter->fixedfields)) { $filters_selectors="f".$filter->fixedfields[$f]["ID"]; } else { $filters_selectors="f".$filter->specialfields[$f]["ID"]; } global $$filters_selectors; if ($param[$filters_selectors]) { $tableau=array(); foreach ($param[$filters_selectors] as $categ) { $tableau[$categ] = $categ; } $$filters_selectors = $tableau; } } $form_task .= "
".$filter->display_filters()."
 
"; $t_sort = explode(",",$filter->sortablecolumns); //parcours des selecteurs de tris for ($j=0;$j<=count($t_sort)-1;$j++) { $sort_selector="sort_list_".$j; global $$sort_selector; if ($param[$sort_selector]) { $$sort_selector = $param[$sort_selector]; } } $form_task .= "
".$filter->display_sort()."
 
"; } else { $form_task .= $filter->error_message; } } return $form_task; } function task_execution() { global $dbh,$msg,$PMBusername,$pmb_lecteurs_localises,$empr_filter_rows,$empr_sort_rows,$empr_show_rows; //& (RESTRICTCIRC_AUTH) if (SESSrights & CIRCULATION_AUTH) { //requete pour la construction du pdf $rqt = "select distinct p.libelle_tache, p.rep_upload, p.path_upload from planificateur p left join taches t on t.num_planificateur = p.id_planificateur left join tache_docnum tdn on tdn.tache_docnum_repertoire=p.rep_upload where t.id_tache=".$id_tache; $res_query = mysql_query($rqt, $dbh); $parameters = $this->unserialize_task_params(); if ($parameters["chk_loan"]) { $option = $parameters["chk_loan"]; // $count = count($parameters["chk_loan"]); // $percent = 0; // $p_value = (int) 100/$count; // foreach ($parameters["chk_loan"] as $elem) { // $this->listen_commande(array(&$this, 'traite_commande')); //fonction a rappeller (traite commande) // if($this->statut == WAITING) { // $this->send_command(RUNNING); // } if ($this->statut == RUNNING) { $this->report[] = "".$this->msg["loan_relance"].""; $results=array(); if (method_exists($this->proxy, "pmbesLoans_filterLoansReaders")) { $results[] = $this->proxy->pmbesLoans_filterLoansReaders("empr","empr_list","b,n,c,g","b,n,c,g,2,3,cs","n,g",$parameters); $t_empr = array(); if ($results) { foreach ($results as $result) { $t_empr[] = $result["id_empr"]; } //Au minimum 1 emprunteur dans le tableau pour poursuivre.. if (count($t_empr) > 0) { //traitement des options choisies switch ($option) { case LOAN_ALL_ACTIONS : //Comment connaître le niveau à valider ?? $this->report[] = "".$this->msg["loan_all_actions"].""; foreach ($results as $result) { if ($result["id_empr"] != "") { // $this->proxy->fonction_pour_valider_action } } break; case LOAN_PRINT_MAIL : $this->report[] = "".$this->msg["loan_print_mail"].""; if(method_exists($this->proxy, "pmbesLoans_relanceLoansReaders")) { if(method_exists($this->proxy, "pmbesLoans_buildPdfLoansDelayReaders")) { if ($this->isUploadValide()) { $not_all_mail = $this->proxy->pmbesLoans_relanceLoansReaders($t_empr); if ($not_all_mail) { $object_fpdf = $this->proxy->pmbesLoans_buildPdfLoansDelayReaders($t_empr, "", ""); if ($object_fpdf) { $this->generate_docnum($object_fpdf,"application/pdf","pdf"); } } else { $this->report[] = "".$this->msg["loan_no_letter"].""; } } else { $this->report[] = "Le chemin du répertoire d'upload est invalide ou protégé en écriture"; } } else { $this->report[] = "".sprintf($msg["planificateur_function_rights"],"buildPdfLoansDelayReaders","pmbesLoans",$PMBusername).""; } } else { $this->report[] = "".sprintf($msg["planificateur_function_rights"],"relanceLoansReaders","pmbesLoans",$PMBusername).""; } break; case LOAN_CSV_MAIL : $this->report[] = "".$this->msg["loan_csv_mail"].""; if (method_exists($this->proxy, "pmbesLoans_exportCSV")) { if ($this->isUploadValide()) { $content_csv = $this->proxy->pmbesLoans_exportCSV($t_empr); $this->generate_docnum($content_csv,"application/ms-excel","xls"); } else { $this->report[] = "Le chemin du répertoire d'upload est invalide ou protégé en écriture"; } } else { $this->report[] = "".sprintf($msg["planificateur_function_rights"],"exportCSV","pmbesLoans",$PMBusername).""; } break; } } else { $this->report[] = "".$this->msg["loan_no_empr"].""; } } } else { $this->report[] = "".sprintf($msg["planificateur_function_rights"],"filterLoansReaders","pmbesLoans").""; } } // $percent = $percent + $p_value; $percent = 100; $this->update_progression($percent); } else { $this->report[] = "Aucune option choisie !"; } } else { $this->report[] = "".sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername).""; } } //inutilisé.. function traite_commande($cmd,$message) { switch ($cmd) { case RESUME: $this->send_command(WAITING); break; case SUSPEND: $this->suspend_loan(); break; case STOP: $this->finalize(); break; case RETRY: break; } } function make_serialized_task_params() { global $chk_loan,$empr_location_id; global $f6, $f8, $f5, $f11, $f2, $f3; global $sort_list_0, $sort_list_1; $t = parent::make_serialized_task_params(); if ($chk_loan) { $t["chk_loan"]=$chk_loan; } if (!empty($f6)) { for ($i=0; $iget_task_params(); return $params; } function suspend_loan() { while ($this->statut == SUSPENDED) { sleep(20); $this->listen_commande(array(&$this,"traite_commande")); } } }