$values .= ", expl_typdoc='{$expl_typdoc}'";
     $values .= ", expl_cote='{$expl_cote}'";
     $values .= ", expl_section='{$expl_section}'";
     $values .= ", expl_statut='{$expl_statut}'";
     $values .= ", expl_location='{$expl_location}' {$transfert_origine} ";
     $values .= ", expl_codestat='{$expl_codestat}'";
     $values .= ", expl_note='{$expl_note}'";
     $values .= ", expl_comment='{$expl_comment}'";
     $values .= ", expl_prix='{$expl_prix}'";
     $values .= ", expl_owner='{$expl_owner}'";
     $values .= ", type_antivol='{$type_antivol}'";
     $values .= ", expl_nbparts='{$f_ex_nbparts}'";
     $requete = "UPDATE exemplaires SET {$values} WHERE expl_id={$expl_id} AND expl_notice=0 LIMIT 1";
     $myQuery = pmb_mysql_query($requete, $dbh);
     $audit->get_new_infos("SELECT expl_statut, expl_location, transfert_location_origine, transfert_statut_origine, transfert_section_origine, expl_owner FROM exemplaires WHERE expl_cb='{$expl_cb}' ");
     $audit->save_info_modif(AUDIT_EXPL, $expl_id, "bul_expl_update.inc.php");
 } else {
     // insertion d'un nouvel exemplaire
     $values = "expl_cb='{$expl_cb}'";
     $values .= ", expl_notice='0'";
     $values .= ", expl_bulletin='{$expl_bulletin}'";
     $values .= ", expl_typdoc='{$expl_typdoc}'";
     $values .= ", expl_cote='{$expl_cote}'";
     $values .= ", expl_section='{$expl_section}'";
     $values .= ", expl_statut='{$expl_statut}'";
     $values .= ", expl_location='{$expl_location}' {$transfert_origine} ";
     $values .= ", expl_codestat='{$expl_codestat}'";
     $values .= ", expl_note='{$expl_note}'";
     $values .= ", expl_comment='{$expl_comment}'";
     $values .= ", expl_prix='{$expl_prix}'";
     $values .= ", expl_owner='{$expl_owner}'";
Exemple #2
0
 function save()
 {
     global $dbh;
     $this->error = false;
     if (trim($this->cb) !== '' && ($this->id_notice || $this->id_bulletin) && $this->typdoc_id && trim($this->cote) !== '' && $this->location_id && $this->section_id && $this->codestat_id && $this->owner_id && $this->statut_id) {
         if ($this->expl_id) {
             $q = "update exemplaires set ";
         } else {
             $q = "insert into exemplaires set ";
         }
         $q .= "expl_cb = '" . $this->cb . "', ";
         $q .= "expl_notice = '" . $this->id_notice . "', ";
         if ($this->id_notice) {
             $q .= "expl_bulletin = '0', ";
         } else {
             $q .= "expl_bulletin = '" . $this->id_bulletin . "', ";
         }
         if ($this->expl_id) {
             $rqt = "SELECT id_transfert FROM transferts, transferts_demande WHERE num_transfert=id_transfert and etat_transfert=0 AND num_expl='" . $this->expl_id . "' ";
             $res = pmb_mysql_query($rqt);
             if (!pmb_mysql_num_rows($res)) {
                 // pas de transfert en cours, on met à jour transfert_location_origine
                 $transfert_origine = ", transfert_location_origine='" . $this->location_id . "', transfert_statut_origine='" . $this->statut_id . "', transfert_section_origine='" . $this->section_id . "' ";
             }
         } else {
             // en création
             $transfert_origine = ", transfert_location_origine='" . $this->location_id . "', transfert_statut_origine='" . $this->statut_id . "', transfert_section_origine='" . $this->section_id . "' ";
         }
         if ($this->expl_id) {
             $audit = new audit();
             $audit->get_old_infos("SELECT expl_statut, expl_location, transfert_location_origine, transfert_statut_origine, transfert_section_origine, expl_owner FROM exemplaires WHERE expl_cb='" . $this->cb . "' ");
         }
         $q .= "expl_typdoc = '" . $this->typdoc_id . "', ";
         $q .= "expl_cote = '" . trim($this->cote) . "', ";
         $q .= "expl_section = '" . $this->section_id . "', ";
         $q .= "expl_statut =  '" . $this->statut_id . "', ";
         $q .= "expl_location = '" . $this->location_id . "' {$transfert_origine} , ";
         $q .= "expl_codestat = '" . $this->codestat_id . "', ";
         $q .= "expl_date_depot = '" . $this->date_depot . "', ";
         $q .= "expl_date_retour = '" . $this->date_retour . "', ";
         $q .= "expl_note = '" . $this->note . "', ";
         $q .= "expl_prix = '" . $this->prix . "', ";
         $q .= "expl_owner = '" . $this->owner_id . "', ";
         $q .= "expl_lastempr = '" . $this->lastempr . "', ";
         $q .= "last_loan_date = '" . $this->last_loan_date . "', ";
         $q .= "create_date = '" . $this->create_date . "', ";
         $q .= "type_antivol = '" . $this->type_antivol . "', ";
         $q .= "expl_comment = '" . $this->expl_comment . "', ";
         $q .= "expl_nbparts = '" . $this->nbparts . "', ";
         $q .= "expl_retloc = '" . $this->expl_retloc . "' ";
         if ($this->expl_id) {
             $q .= "where expl_id='" . $this->expl_id . "' ";
         }
         $r = pmb_mysql_query($q, $dbh);
         if ($r) {
             if (!$this->expl_id) {
                 $this->expl_id = pmb_mysql_insert_id($dbh);
             } else {
                 $audit->get_new_infos("SELECT expl_statut, expl_location, transfert_location_origine, transfert_statut_origine, transfert_section_origine, expl_owner FROM exemplaires WHERE expl_cb='" . $this->cb . "' ");
                 $audit->save_info_modif(AUDIT_EXPL, $this->expl_id, "expl.class.php");
             }
         } else {
             $this->error = true;
         }
     } else {
         $this->error = true;
     }
     return !$this->error;
 }