Esempio n. 1
0
 function list_loans($session_id, $loan_type)
 {
     global $dbh, $msg;
     if (!$session_id) {
         return array();
     }
     $session_info = $this->retrieve_session_information($session_id);
     $empr_id = $session_info["empr_id"];
     if (!$empr_id) {
         return array();
     }
     $empr = new emprunteur($empr_id);
     switch ($loan_type) {
         case LIST_LOAN_LATE:
         case LIST_LOAN_CURRENT:
             $empr->fetch_info_suite();
             $results = array();
             foreach ($empr->prets as $apret) {
                 if ($loan_type == LIST_LOAN_LATE && !$apret["pret_retard"]) {
                     continue;
                 }
                 $expl_object = new exemplaire($apret["cb"]);
                 $aresult = array("empr_id" => $empr_id, "notice_id" => $expl_object->id_notice, "bulletin_id" => $expl_object->id_bulletin, "expl_id" => $apret["id"], "expl_cb" => utf8_normalize($apret["cb"]), "expl_support" => utf8_normalize($apret["typdoc"]), "expl_location_id" => $expl_object->location_id, "expl_location_caption" => utf8_normalize($apret["location"]), "expl_section_id" => $expl_object->section_id, "expl_section_caption" => utf8_normalize($apret["section"]), "expl_libelle" => utf8_normalize(strip_tags($apret["libelle"])), "loan_startdate" => $apret["date_pret"], "loan_returndate" => $apret["date_retour"]);
                 $results[] = $aresult;
             }
             break;
         case LIST_LOAN_PRECEDENT:
             $sql = "SELECT arc_expl_notice, arc_expl_bulletin, arc_expl_id, tdoc_libelle,";
             $sql .= "group_concat(distinct date_format(arc_debut, '" . $msg["format_date"] . "') separator '<br />') as aff_pret_debut, ";
             $sql .= "group_concat(distinct date_format(arc_fin, '" . $msg["format_date"] . "') separator '<br />') as aff_pret_fin, ";
             $sql .= "trim(concat(ifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if(mention_date, concat(' (',mention_date,')') ,if (date_date, concat(' (',date_format(date_date, '" . $msg["format_date"] . "'),')') ,'')))) as tit, if(notices_m.notice_id, notices_m.notice_id, notices_s.notice_id) as not_id ";
             $sql .= "FROM (((pret_archive LEFT JOIN notices AS notices_m ON arc_expl_notice = notices_m.notice_id ) ";
             $sql .= "        LEFT JOIN bulletins ON arc_expl_bulletin = bulletins.bulletin_id) ";
             $sql .= "        LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id) ";
             $sql .= "        LEFT JOIN docs_type ON docs_type.idtyp_doc = pret_archive.arc_expl_typdoc, ";
             $sql .= "        empr ";
             $sql .= "WHERE empr.id_empr = arc_id_empr and arc_id_empr='{$empr_id}' ";
             $sql .= "group by arc_expl_notice, arc_expl_bulletin, tit, not_id ";
             $sql .= "order by arc_debut desc";
             $res = mysql_query($sql, $dbh);
             while ($row = mysql_fetch_assoc($res)) {
                 $expl_object = new exemplaire('', $row["arc_expl_id"]);
                 $expl_libelle = "";
                 if ($expl_object->id_bulletin) {
                     $bulletin_display = new bulletinage_display($expl_object->id_bulletin);
                     $expl_libelle = $bulletin_display->header;
                 } else {
                     $notice_display = new mono_display($expl_object->id_notice, 0);
                     $expl_libelle = $notice_display->header;
                 }
                 $aresult = array("empr_id" => $empr_id, "notice_id" => $expl_object->id_notice, "bulletin_id" => $expl_object->id_bulletin, "expl_id" => $row["arc_expl_id"], "expl_cb" => utf8_normalize($expl_object->cb), "expl_support" => utf8_normalize($row["tdoc_libelle"]), "expl_location_id" => $expl_object->location_id, "expl_location_caption" => utf8_normalize($expl_object->location), "expl_section_id" => $expl_object->section_id, "expl_section_caption" => utf8_normalize($expl_object->section), "expl_libelle" => utf8_normalize($expl_libelle), "loan_startdate" => $row["aff_pret_debut"], "loan_returndate" => $row["aff_pret_fin"]);
                 $results[] = $aresult;
             }
             break;
     }
     return $results;
 }