empr_id = $empr_id+0; $this->fetch_data(); } protected function fetch_data(){ $this->serialcirc_list = array(); $alone = "select distinct id_serialcirc from serialcirc_diff join serialcirc on num_serialcirc_diff_serialcirc = id_serialcirc where num_serialcirc_diff_empr = ".$this->empr_id; $group = "select distinct id_serialcirc from serialcirc_diff join serialcirc on num_serialcirc_diff_serialcirc = id_serialcirc join serialcirc_group on num_serialcirc_group_diff = id_serialcirc_diff where num_serialcirc_group_empr = ".$this->empr_id; $query = $alone." union ".$group; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ while($row = pmb_mysql_fetch_object($result)){ $this->serialcirc_list[] = $row->id_serialcirc; $diff = new serialcirc_diff($row->id_serialcirc); $this->info[$row->id_serialcirc] = $diff->serial_info; } } $already_start = "select distinct num_serialcirc_circ_serialcirc as id_serialcirc, num_serialcirc_circ_expl as expl_id from serialcirc_circ where num_serialcirc_circ_empr = ".$this->empr_id; $result = pmb_mysql_query($already_start); if(pmb_mysql_num_rows($result)){ while($row = pmb_mysql_fetch_object($result)){ if(!in_array($row->id_serialcirc,$this->serialcirc_circ_list)){ $this->serialcirc_circ_list[] = $row->id_serialcirc; } if(!isset($this->info[$row->id_serialcirc]) || !$this->info[$row->id_serialcirc]){ $diff = new serialcirc_diff($row->id_serialcirc); $this->info[$row->id_serialcirc] = $diff->serial_info; } $this->info[$row->id_serialcirc]['expls'][] = $row->expl_id; } } } public function get_list(){ global $msg,$charset,$dbh; global $empr_serialcirc_tmpl,$empr_serialcirc_tmpl_item; global $empr_serialcirc_circ_tmpl,$empr_serialcirc_circ_tmpl_item; $tpl = ""; if(count($this->serialcirc_list) || count($this->serialcirc_circ_list)){ $tpl=$empr_serialcirc_tmpl; $items=""; $query = "select empr_cb from empr where id_empr = ".$this->empr_id; $result = pmb_mysql_query($query,$dbh); $cb = pmb_mysql_result($result,0,0); $circ_list = $this->serialcirc_circ_list; $seriallist_ids=""; for($i=0; $iserialcirc_list) ; $i++){ $diff_id=$this->serialcirc_list[$i]; if($seriallist_ids) $seriallist_ids.="|"; $expls = ""; $seriallist_ids.=$diff_id; foreach($circ_list as $j => $id){ if ($id == $diff_id){ $expls = ""; foreach($this->info[$diff_id]['expls'] as $expl){ $query = "select expl_cb,expl_notice, expl_bulletin from exemplaires where expl_id = ".$expl; $result =pmb_mysql_query($query,$dbh); if(pmb_mysql_num_rows($result)){ $row = pmb_mysql_fetch_object($result); if($row->expl_notice){ $notice = new mono_display($row->expl_notice); $libelle = $notice->header; }else{ $bulletin = new bulletinage_display($row->expl_bulletin); $libelle = $bulletin->display; } if($expls)$expls.="
"; $expls.= "".$libelle.""; } } unset($circ_list[$j]); } } $item=$empr_serialcirc_tmpl_item; $css_class = ($i%2 == 0 ? "odd" :"even"); $item = str_replace("!!periodique!!","".htmlentities($this->info[$diff_id]['serial_name'],ENT_QUOTES,$charset)."",$item); $item=str_replace('!!abt!!', "".htmlentities($this->info[$diff_id]['abt_name'],ENT_QUOTES,$charset)."" , $item); $item=str_replace('!!bulletinage_see!!', "".htmlentities($msg['link_notice_to_bulletinage'],ENT_QUOTES,$charset)."" , $item); $item=str_replace('!!exemplaire_see!!', $expls , $item); $item=str_replace('!!id!!',$diff_id,$item); $items.=$item; } if(count($circ_list)){ for($i=0; $iinfo[$diff_id]['expls'] as $expl){ $query = "select expl_cb,expl_notice, expl_bulletin from exemplaires where expl_id = ".$expl; $result =pmb_mysql_query($query,$dbh); if(pmb_mysql_num_rows($result)){ $row = pmb_mysql_fetch_object($result); if($row->expl_notice){ $notice = new mono_display($row->expl_notice); $libelle = $notice->header; }else{ $bulletin = new bulletinage_display($row->expl_bulletin); $libelle = $bulletin->display; } if($expls)$expls.="
"; $expls.= "".$libelle.""; } } $item=$empr_serialcirc_circ_tmpl_item; $css_class = ($i%2 == 0 ? "odd" :"even"); if(!isset($this->info[$diff_id]['serial_link'])) $this->info[$diff_id]['serial_link'] = ''; if(!isset($this->info[$diff_id]['serial_name'])) $this->info[$diff_id]['serial_name'] = ''; if(!isset($this->info[$diff_id]['abt_name'])) $this->info[$diff_id]['abt_name'] = ''; if(!isset($this->info[$diff_id]['bulletinage_link'])) $this->info[$diff_id]['bulletinage_link'] = ''; if(!isset($this->info[$diff_id]['serialcirc_link'])) $this->info[$diff_id]['serialcirc_link'] = ''; $item = str_replace("!!periodique!!","".htmlentities($this->info[$diff_id]['serial_name'],ENT_QUOTES,$charset)."",$item); $item=str_replace('!!abt!!', "".htmlentities($this->info[$diff_id]['abt_name'],ENT_QUOTES,$charset)."" , $item); $item=str_replace('!!bulletinage_see!!', "".htmlentities($msg['link_notice_to_bulletinage'],ENT_QUOTES,$charset)."" , $item); $item=str_replace('!!exemplaire_see!!', $expls , $item); $item=str_replace('!!id!!',$diff_id,$item); $items.=$item; } } $tpl = str_replace("!!empr_cb!!",$cb,$tpl); $tpl = str_replace("!!serialcirc_empr_ids_list!!",$seriallist_ids,$tpl); $tpl = str_replace("!!serialcirc_empr_list!!",$items,$tpl); } return $tpl; } public function unsbuscribe($serialscirc=array()){ global $dbh,$msg; $error_message = array(); for($i=0 ; $i".htmlentities($row->name, ENT_QUOTES, $charset).""); } } return array('messages'=>$message,'errors'=>$error_message); } protected function duplicate($serialcirc, $new_empr_id) { global $dbh; $query = 'select * from serialcirc_diff where num_serialcirc_diff_serialcirc = '.($serialcirc*1).' and num_serialcirc_diff_empr = '.$this->empr_id; $result = pmb_mysql_query($query, $dbh); while ($row = pmb_mysql_fetch_assoc($result)) { $query = 'select max(serialcirc_diff_order) from serialcirc_diff where num_serialcirc_diff_serialcirc = '.($serialcirc*1); $order = pmb_mysql_result(pmb_mysql_query($query, $dbh), 0, 0)+1; $query = 'insert into serialcirc_diff set num_serialcirc_diff_empr = '.($new_empr_id*1).', serialcirc_diff_order = '.$order; foreach ($row as $column => $value) { if (($column == 'id_serialcirc_diff') || ($column == 'num_serialcirc_diff_empr') || ($column == 'serialcirc_diff_order')) { continue; } $query.= ', '.$column.' = "'.$value.'"'; } pmb_mysql_query($query, $dbh); } $query = 'select serialcirc_group.* from serialcirc_group join serialcirc_diff on num_serialcirc_group_diff = id_serialcirc_diff where num_serialcirc_diff_serialcirc = '.($serialcirc*1).' and num_serialcirc_group_empr = '.$this->empr_id; $result = pmb_mysql_query($query, $dbh); while ($row = pmb_mysql_fetch_assoc($result)) { $query = 'select max(serialcirc_group_order) from serialcirc_group join serialcirc_diff on num_serialcirc_group_diff = id_serialcirc_diff where num_serialcirc_diff_serialcirc = '.($serialcirc*1); $order = pmb_mysql_result(pmb_mysql_query($query, $dbh), 0, 0)+1; $query = 'insert into serialcirc_group set num_serialcirc_group_empr = '.($new_empr_id*1).', serialcirc_group_order = '.$order; foreach ($row as $column => $value) { if (($column == 'id_serialcirc_group') || ($column == 'num_serialcirc_group_empr') || ($column == 'serialcirc_group_order') || ($column == 'serialcirc_group_responsable')) { continue; } $query.= ', '.$column.' = "'.$value.'"'; } pmb_mysql_query($query, $dbh); } } } // class end