* */ /** * Class history : Contains all the function to manage history of the maarch tables * * @author Claire Figueras * @license GPL * @package Maarch LetterBox 2.3 * @version 1.1 */ class history extends dbquery { /** * Redefinition of the history object constructor */ function __construct() { // construct the object and setup the variables if(isset($_GET['start'])) { $start = $_GET['start']; $this->the_start = strip_tags($_GET['start']); } else { $this->the_start = 0; } if(isset($_GET['order'])) { $this->orderby = strip_tags($_GET['order']); } else { $this->orderby = "datedesc"; } $this->sqlorderby = ""; if($this->orderby == "dateasc") { $this->sqlorderby = "order by EVENT_DATE asc"; } if($this->orderby == "datedesc") { $this->sqlorderby = "order by EVENT_DATE desc"; } if($this->orderby == "userasc") { $this->sqlorderby = "order by USER_ID asc"; } if($this->orderby == "userdesc") { $this->sqlorderby = "order by USER_ID desc"; } if($this->orderby == "actionasc") { $this->sqlorderby = "order by EVENT_TYPE asc"; } if($this->orderby == "actiondesc") { $this->sqlorderby = "order by EVENT_TYPE desc"; } if($this->orderby == "idasc") { $this->sqlorderby = "order by INFO asc"; } if($this->orderby == "iddesc") { $this->sqlorderby = "order by INFO desc"; } } /** * Insert a record in the history table * * @param integer $id identifier of the event to add * @param string $how event type * @param string $what event description */ public function add($where,$id,$how,$what) { // insert a record in the history table // $conn = new dbquery(); $this->connect(); $this->query("INSERT INTO `".$_SESSION['tablename']['history']."` (`TABLE_NAME`, `RECORD_ID` , `EVENT_TYPE` , `USER_ID` , `EVENT_DATE` , `INFO` ) VALUES ('".$where."', '".$id."', '".$how."', '".$_SESSION['user']['UserId']."', '".date("Y")."-".date("m")."-".date("d")." ".date("H:i:s")."', '".addslashes($what)."')"); $this->close; } /** * Insert a record in the history table from the class_diffusion * * @param integer $id identifier of the event to add * @param string $how event type * @param string $what event description */ public function add_from_diffusion($where,$id,$history,$diffusion = array() ) { //TYPE OF THE ENTRY IN THE HISTORY if( count($history) > 0 ) { $how = "RED"; if( $history["action"] == "redirect_to_service" ) $what = _REDIRECT_TO_SERVICE." : ".$history["service_info"]."\n"; else if( $history["action"] == "redirect_to_user" ) $what = _REDIRECT_TO_USER." : ".$history["user_info"]["FIRSTNAME"]." ".$history["user_info"]["LASTNAME"]."\n"; } else { $how = "DIF"; $what = _UPDATE_DIFFUSION."\n"; } //DESTINATION USER OR SERVICE $first = array_slice($diffusion, 0, 1); $first = $first[key($first)]; if( isset($first["USER"]) ) { $what .= "\n"._DESTINATION_USER." \n ".$first["USER"]["FIRSTNAME"]." ".$first["USER"]["LASTNAME"]." --> ".$_SESSION['mail_action'][$first["USER"]["MAIL_ACTION"]]['label']."\n"; } else if( isset($first["SERVICE"]) ) { $what .= "\n"._DESTINATION_SERVICE." \n ".$first["SERVICE"]["SERVICE"]." --> ".$_SESSION['mail_action'][$first["SERVICE"]["MAIL_ACTION"]]['label']."\n"; } $copy_users = array(); $copy_services = array(); //COPY USERS OR SERVICES foreach( array_slice($diffusion,1) as $next ) { if( isset($next["USER"]) ) { $copy_users[] = $next["USER"]; } else if( isset($next["SERVICE"]) ) { $copy_services[] = $next["SERVICE"]; } } //COPY SERVICES if( count($copy_services) > 0 ) { $what .= "\n"._COPY_SERVICES."\n"; foreach( $copy_services as $c_service ) { $what .= "-".$c_service["SERVICE"]." --> ".$_SESSION['mail_action'][$c_service["MAIL_ACTION"]]['label']."\n"; } } //COPY USERS if( count($copy_users) > 0 ) { $what .= "\n"._COPY_USERS."\n"; foreach( $copy_users as $c_user ) { $what .= "-".$c_user["FIRSTNAME"]." ".$c_user["LASTNAME"]." --> ".$_SESSION['mail_action'][$c_user["MAIL_ACTION"]]['label']."\n"; } } //Finally, call the function $this->add($where,$id,$how,$what); } /** * List all the rows of the history table * */ public function listhistory() { // List all the rows of the history table /* Configuration */ /* Just edit this part if you need it*/ $title = _HISTORY_TITLE; $ref_page = "index"; $page_name = "hist"; $page_name_up = $page_name."_up"; $page_name_del = $page_name."_del"; $page_name_validate = $page_name."_validate"; $table_name = $_SESSION['tablename']['history']; $nb_show = $_SESSION['config']['nblinetoshow']; if($_SESSION['history']['current_user'] == 'all' || $_SESSION['history']['current_user'] == '') { $where_user = ''; } else { $where_user = " AND USER_ID = '".$_SESSION['history']['current_user']."' "; } if($_SESSION['history']['current_action'] == 'all' || $_SESSION['history']['current_action'] == '') { $where_action = ''; } else { $where_action = " AND EVENT_TYPE = '".$_SESSION['history']['current_action']."' "; } if($_SESSION['history']['current_from'] <> '') { $where_from = " AND EVENT_DATE > '".str_replace('-', '',$this->inverse_date($_SESSION['history']['current_from']))."' "; } else { $where_from = ""; } if($_SESSION['history']['current_to'] <> '') { $where_to = " AND EVENT_DATE < '".str_replace('-', '',$this->inverse_date($_SESSION['history']['current_to']))."' "; } else { $where_to = ""; } $global_where = $where_user.$where_action.$where_from.$where_to; $this->connect(); $this->query("select count(*) as total from ".$table_name." where (1=1) ".$global_where); $nb_total_1 = $this->fetch_object(); $nb_total = $nb_total_1->total; // define the defaults values $nb_pages = ceil($nb_total/$nb_show); $link = $ref_page.".php?page=".$page_name; if($nb_pages > 1) { $next_start = 0; $page_list1 = '

'; $lastpage = 0; for($i = 0;$i <> $nb_pages; $i++) { $the_line = $i + 1; if($this->the_start == $next_start) { $page_list1 .= ""; $page_list2 .= ""; } else { $page_list1 .= ""; $page_list2 .= ""; } $next_start = $next_start + $nb_show; $lastpage = $next_start; } $lastpage = $lastpage - $nb_show; $previous = ""; $next = ""; if($this->the_start > 0) { $start_prev = $this->the_start - $nb_show; $previous = ''; } if($this->the_start <> $lastpage) { $start_next = $this->the_start + $nb_show; $next = ''; } $page_list1 = $page_list1.""; $page_list2 = $page_list2.""; if($previous <> '' || $next <> '') { if(empty($previous)) { $previous = " "; } if(empty($next)) { $next = " "; } $page_list1 .= $previous." ".$next.'

'; $page_list2 .= $previous." ".$next.'

'; } } $this->query("select * from ".$table_name." where (1=1) ".$global_where." ".$this->sqlorderby." limit ".$this->the_start.",".$nb_show); //echo '

'.$title.'

//
'; echo $page_list1; ?> fetch_object()) { if($color == ' class="col"') { $color = ''; } else { $color = ' class="col"'; } $func = new functions(); ?> >
<?php echo _DESC_SORT; ?> <?php echo _ASC_SORT; ?> <?php echo _DESC_SORT; ?> <?php echo _ASC_SORT; ?> <?php echo _DESC_SORT; ?> <?php echo _ASC_SORT; ?>
dateformat($line->EVENT_DATE); ?> show($line->USER_ID); ?> EVENT_TYPE == "ADD") { echo _ADDITION; } elseif($line-> EVENT_TYPE == "DEL") { echo _DELETION; } elseif($line-> EVENT_TYPE == "UP") { echo _MODIFICATION; } elseif($line-> EVENT_TYPE == "BAN") { echo _SUSPENSION; } elseif($line-> EVENT_TYPE == "VAL") { echo _VALIDATION; } elseif($line-> EVENT_TYPE == "DIF") { echo _DIFFUSION; } elseif($line-> EVENT_TYPE == "RED") { echo _REDIRECTION; } elseif($line-> EVENT_TYPE == "ABS") { echo _ABSENCE; } elseif($line-> EVENT_TYPE == "RET") { echo _RETURN_FROM_VACATION; } elseif($line-> EVENT_TYPE == "WAI") { echo _WAITINGDOC_HISTORY; } ?> show($line->INFO); ?>
'; } } ?>