record_id = $record_id; } $this->fetch_data(); } protected function fetch_data() { if ($this->record_id) { $query = "SELECT id_pnb_order FROM pnb_orders WHERE pnb_order_num_notice = '".$this->record_id."' ORDER BY pnb_order_offer_date"; $result = pmb_mysql_query($query); while ($row = pmb_mysql_fetch_assoc($result)) { $this->pnb_orders[] = new pnb_order($row['id_pnb_order']); } } } public function get_record_id() { return $this->record_id; } public function get_pnb_orders() { if (!isset($this->pnb_orders)) { $this->pnb_orders = array(); } return $this->pnb_orders; } public function get_display_orders () { global $pnb_record_orders_tpl; global $pnb_record_orders_tpl_line; $tpl = $pnb_record_orders_tpl; $lines = ''; foreach ($this->get_pnb_orders() as $order) { $line = $pnb_record_orders_tpl_line; $line = str_replace('!!order_id!!', $order->get_order_id(), $line); $line = str_replace('!!line_id!!', $order->get_line_id(), $line); $line = str_replace('!!loan_max_duration!!', $order->get_loan_max_duration(), $line); $line = str_replace('!!nb_loans!!', $this->get_loans_completed_number($order->get_line_id()). ' / ' .$order->get_nb_loans(), $line); $line = str_replace('!!nb_simultaneous_loans!!', $this->get_loans_in_progress($order->get_line_id())." / ".$order->get_nb_simultaneous_loans(), $line); $line = str_replace('!!nb_consult_in_situ!!', $order->get_nb_consult_in_situ(), $line); $line = str_replace('!!nb_consult_ex_situ!!', $order->get_nb_consult_ex_situ(), $line); $line = str_replace('!!offer_date!!', $order->get_offer_formated_date(), $line); $line = str_replace('!!offer_date_end!!', $order->get_offer_formated_date_end(), $line); $lines .= $line; } $tpl = str_replace('!!order_lines!!', $lines, $tpl); $tpl = str_replace('!!record_id!!', $this->record_id, $tpl); return $tpl; } public function get_orders_number() { return count($this->get_pnb_orders()); } /** * Retourne le nombre de jetons restant * @param string $line_id = order_line_id dans la table pnb_orders * @return mixed|string */ public function get_loans_completed_number($line_id) { if(!isset(self::$loans_infos[$line_id] )){ self::$loans_infos[$line_id] = dilicom::get_instance()->get_loan_status(array($line_id)); } if (isset(self::$loans_infos[$line_id] ['loanResponseLine'][0]['nta'])) { $query = "UPDATE pnb_orders SET pnb_current_nta = ".intval(self::$loans_infos[$line_id] ['loanResponseLine'][0]['nta'])." WHERE pnb_order_line_id = '".addslashes($line_id)."'"; pmb_mysql_query($query); return self::$loans_infos[$line_id] ['loanResponseLine'][0]['nta']; } return '0'; } protected function get_loans_in_progress($line_id) { if(!isset(self::$loans_infos[$line_id] )){ self::$loans_infos[$line_id] = dilicom::get_instance()->get_loan_status(array($line_id)); } if (isset(self::$loans_infos[$line_id] ['loanResponseLine'][0]['nus1'])) { return self::$loans_infos[$line_id] ['loanResponseLine'][0]['nus1']; } return '0'; } }