* @author Loic Vinet
*/
class LetterBox extends dbquery
{
/**
*
* @access private
* @var integer
*/
private $the_start;
/**
* XML Config PATH
* @access private
* @var string
*/
private $xml_config_path;
/**
* Redefinition of the LetterBox object constructor
*/
function __construct($xml_config_path="xml")
{
$this->xml_config_path = $xml_config_path;
// configure the sql argument order by
if(isset($_GET['start']))
{
$this->the_start = strip_tags($_GET['start']);
}
else
{
$this->the_start = 0;
}
}
/**
* Configure the sql argument order by
*
*/
public function define_order()
{
// configure the sql argument order by
$orderby = "";
if(isset($_GET['order']))
{
if($_GET['order'] == "arrivdesc")
{
$orderby = "order by CREATION_DATE desc";
}
elseif($_GET['order'] == "arrivasc")
{
$orderby = "order by CREATION_DATE asc";
}
if($_GET['order'] == "datedesc")
{
$orderby = "order by CREATION_DATE desc";
}
elseif($_GET['order'] == "dateasc")
{
$orderby = "order by CREATION_DATE asc";
}
if($_GET['order'] == "typedesc")
{
$orderby = "order by TYPE_ID desc";
}
elseif($_GET['order'] == "typeasc")
{
$orderby = "order by TYPE_ID asc";
}
if($_GET['order'] == "limdesc")
{
$orderby = "order by CUSTOM_D2 desc";
}
elseif($_GET['order'] == "limasc")
{
$orderby = "order by CUSTOM_D2 asc";
}
if($_GET['order'] == "expdesc")
{
$orderby = "order by AUTHOR desc";
}
elseif($_GET['order'] == "expasc")
{
$orderby = "order by AUTHOR asc";
}
if($_GET['order'] == "statusdesc")
{
$orderby = "order by STATUS desc";
}
elseif($_GET['order'] == "statusasc")
{
$orderby = "order by STATUS asc";
}
if($_GET['order'] == "residdesc")
{
$orderby = "order by RES_ID desc";
}
elseif($_GET['order'] == "residasc")
{
$orderby = "order by RES_ID asc";
}
if($_GET['order'] == "residdesc_copy")
{
$orderby = "order by r.RES_ID desc";
}
elseif($_GET['order'] == "residasc_copy")
{
$orderby = "order by r.RES_ID asc";
}
if($_GET['order'] == "objdesc")
{
$orderby = "order by DESCRIPTION desc";
}
elseif($_GET['order'] == "objasc")
{
$orderby = "order by DESCRIPTION asc";
}
if($_GET['order'] == "destdesc")
{
$orderby = "order by DEST_USER desc";
}
elseif($_GET['order'] == "destasc")
{
$orderby = "order by DEST_USER asc";
}
if($_GET['order'] == "limdesc")
{
$orderby = "order by CUSTOM_D2 desc";
}
elseif($_GET['order'] == "limasc")
{
$orderby = "order by CUSTOM_D2 asc";
}
if($_GET['order'] == "priodesc")
{
$orderby = "order by PRIORITY desc";
}
elseif($_GET['order'] == "prioasc")
{
$orderby = "order by PRIORITY asc";
}
if($_GET['order'] == "servdesc")
{
$orderby = "order by DESTINATION desc";
}
elseif($_GET['order'] == "servasc")
{
$orderby = "order by DESTINATION asc";
}
if($_GET['order'] == "socidesc")
{
$orderby = "order by SOCIETE desc";
}
elseif($_GET['order'] == "sociasc")
{
$orderby = "order by SOCIETE asc";
}
if($_GET['order'] == "vieweddesc")
{
$orderby = "order by VIEWED desc";
}
elseif($_GET['order'] == "viewedasc")
{
$orderby = "order by VIEWED asc";
}
}
return $orderby;
}
/**
* Show the list of mail to validate
*
* @param array $listarr array which contains all the data to show
* @param int $nb_total number of element to show
* @param string $title list title
* @param string $name page name
*/
public function validate_list($listarr, $nb_total, $title, $name)
{
//$_SESSION['resultat'] = "";
$_SESSION['error'] = '';
// show the document list in result of the search
$page_list1 = "";
$page_list2 = "";
//require_once("class_functions.php");
$func = new functions();
if(isset($_REQUEST['start']))
{
$start = strip_tags($_REQUEST['start']);
}
else
{
$start = 0;
}
if(isset($_GET['order']))
{
$orderby = strip_tags($_GET['order']);
}
else
{
$orderby = 0;
}
$link = "index.php?page=".$name;
// define the defaults values
$nb_show = $_SESSION['config']['nblinetoshow'];
$nb_pages = ceil($nb_total/$nb_show);
// if they are more than 1 page we do pagination with 2 forms
if($nb_pages > 1)
{
$next_start = 0;
$page_list1 = '";
}
?>
1)
{
$next_start = 0;
$page_list1 = '";
}
$this->connect();
?>
connect();
$this->query("select count(*) as total from ".$table_name." where ENABLED = 'Y' ".$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 = "index.php?page=".$page_name."&start=".$this->the_start."&order=".$this->orderby.$what;
if($nb_pages > 1)
{
$next_start = 0;
$page_list1 = '';
$page_list2 .= $previous." ".$next.'
';
}
}
$this->query("select distinct ID from ".$table_name." where ENABLED = 'Y' ".$where." order by SERVICE asc limit ".$this->the_start.",".$nb_show);
echo ' '.$title.'
';
$this->servicelistletters();
echo $page_list1;
?>
connect();
$color = "line1";
while($line = $this->fetch_object())
{
if($color == ' class="col"')
{
$color = '';
}
else
{
$color = ' class="col"';
}
$db->query("select ID, SERVICE from ".$table_name." where ID ='".$line->ID."'");
$desc = "";
$line2 = $db->fetch_object();
$desc = $line2->SERVICE;
?>
>
ID; ?>
clearserviceinfos();
}
/**
* Draw the departments list
*
* @param string $where sorting of the list (empty by default)
* @param string $what first letter of the name (empty by default)
*/
public function emetlist($where = "",$what = "")
{
// draw the services list
$func = new functions();
/* Configuration */
$title = _SHIPPER_LIST;
$page_name = "emet";
$table_name = $_SESSION['tablename']['senders'];
$res_table = $_SESSION['ressources'][0]['tablename'];
$nb_show = $_SESSION['config']['nblinetoshow'];
if(!empty($what))
{
$what = "&what=".$what;
}
/***********************/
$this->connect();
$this->query("select count(*) as total from ".$table_name." where (1=1) and (TOCONTACT <> 'EXT' or TOCONTACT is null) ".$where);
//$this->show();
$nb_total_1 = $this->fetch_object();
$nb_total = $nb_total_1->total;
// define the defaults values
$nb_pages = ceil($nb_total/$nb_show);
$link = "index.php?page=".$page_name."&start=".$this->the_start."&order=".$this->orderby.$what;
if($nb_pages > 1)
{
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$page_list2 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++)
{
$page_name = $i + 1;
$the_line = $i + 1;
if($this->the_start == $next_start)
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
else
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
$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 = ''._PREVIOUS.' ';
}
if($this->the_start <> $lastpage)
{
$start_next = $this->the_start + $nb_show;
$next = ''._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 distinct ID from ".$table_name." where (1=1) and (TOCONTACT <> 'EXT' or TOCONTACT is null) ".$where." order by LASTNAME, FIRSTNAME asc limit ".$this->the_start.",".$nb_show);
echo ' '.$title.'
';
$this->emetlistletters();
echo $page_list1;
?>
connect();
$color = "line1";
while($line = $this->fetch_object())
{
if($color == ' class="col"')
{
$color = '';
}
else
{
$color = ' class="col"';
}
$db->query("select ID, LASTNAME, FIRSTNAME, SOCIETY from ".$table_name." where ID ='".$line->ID."'");
$desc = "";
$line2 = $db->fetch_object();
$name = $line2->LASTNAME;
$prenom = $line2->FIRSTNAME;
$societe = $line2->SOCIETY;
//Fix : Affichage des sociétés
if (($societe == $name) && empty($prenom)){
$prenom = ''; $name = ''; }
?>
>
'));" >
clearemetinfos();
}
/**
* Draw the senders list
*
* @param string $where sorting of the list (empty by default)
* @param string $what first letter of the name (empty by default)
*/
public function senderlist($where = "",$what = "")
{
// draw the services list
$func = new functions();
/* Configuration */
$title = _SENDER_LIST;
$page_name = "sender";
$table_name = $_SESSION['tablename']['senders'];
$res_table = $_SESSION['ressources'][0]['tablename'];
$nb_show = $_SESSION['config']['nblinetoshow'];
if(!empty($what))
{
$what = "&what=".$what;
}
/***********************/
$this->connect();
$this->query("select count(*) as total from ".$table_name." where (1=1) and TOCONTACT = 'EXT' ".$where);
//$this->show();
$nb_total_1 = $this->fetch_object();
$nb_total = $nb_total_1->total;
// define the defaults values
$nb_pages = ceil($nb_total/$nb_show);
$link = "index.php?page=".$page_name."&start=".$this->the_start."&order=".$this->orderby.$what;
if($nb_pages > 1)
{
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$page_list2 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++)
{
$page_name = $i + 1;
$the_line = $i + 1;
if($this->the_start == $next_start)
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
else
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
$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 = ''._PREVIOUS.' ';
}
if($this->the_start <> $lastpage)
{
$start_next = $this->the_start + $nb_show;
$next = ''._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 distinct ID from ".$table_name." where (1=1) and TOCONTACT = 'EXT' ".$where." order by ID asc limit ".$this->the_start.",".$nb_show);
echo ' '.$title.'
';
$this->senderlistletters();
echo $page_list1;
?>
connect();
$color = "line1";
while($line = $this->fetch_object())
{
if($color == ' class="col"')
{
$color = '';
}
else
{
$color = ' class="col"';
}
$db->query("select ID, LASTNAME, FIRSTNAME, SOCIETY from ".$table_name." where ID ='".$line->ID."'");
$desc = "";
$line2 = $db->fetch_object();
$name = $line2->LASTNAME;
$prenom = $line2->FIRSTNAME;
$societe = $line2->SOCIETY;
//Fix : Affichage des sociétés
if (($societe == $name) && empty($prenom)){
$prenom = ''; $name = ''; }
?>
>
'));" >
clearsenderinfos();
}
/**
* Draw the senders list
*
* @param string $where sorting of the list (empty by default)
* @param string $what first letter of the name (empty by default)
*/
public function contactlist($where = "",$what = "")
{
// draw the services list
$func = new functions();
/* Configuration */
$title = _ADDRESS_BOOK;
$page_name = "sender2";
$table_name = $_SESSION['tablename']['senders'];
$res_table = $_SESSION['ressources'][0]['tablename'];
$nb_show = $_SESSION['config']['nblinetoshow'];
if(!empty($what)){
$what = "&what=".$what;
}
/***********************/
$this->connect();
$this->query("select count(*) as total from ".$table_name." where TOCONTACT = '".$_SESSION['user']['UserId']."' ".$where);
//$this->show();
$nb_total_1 = $this->fetch_object();
$nb_total = $nb_total_1->total;
// define the defaults values
$nb_pages = ceil($nb_total/$nb_show);
$link = "index.php?page=".$page_name."&start=".$this->the_start."&order=".$this->orderby.$what;
if($nb_pages > 1){
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$page_list2 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++){
$page_name = $i + 1;
$the_line = $i + 1;
if($this->the_start == $next_start){
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
else{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
$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 = ''._PREVIOUS.' ';
}
if($this->the_start <> $lastpage){
$start_next = $this->the_start + $nb_show;
$next = ''._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 distinct ID from ".$table_name." where TOCONTACT = '".$_SESSION['user']['UserId']."' ".$where." order by ID asc limit ".$this->the_start.",".$nb_show);
echo ' '.$title.'
';
$this->senderlistletters('sender2');
echo $page_list1;
?>
connect();
$color = "line1";
while($line = $this->fetch_object()){
if($color == ' class="col"'){
$color = '';
}
else{
$color = ' class="col"';
}
$db->query("select ID, LASTNAME, FIRSTNAME, SOCIETY, MAIL from ".$table_name." where ID ='".$line->ID."'");
$desc = "";
$line2 = $db->fetch_object();
$name = $line2->LASTNAME;
$prenom = $line2->FIRSTNAME;
$societe = $line2->SOCIETY;
$email = $line2->MAIL;
//Fix : Affichage des sociétés
if (($societe == $name) && empty($prenom)){
$prenom = ''; $name = ''; }
?>
>
'));" >
clearcontactinfos();
}
/**
* Load the data of the letterbox.xml file into session
*
*/
public function xmltosessionletterbox()
{
$xmlfile = simplexml_load_file("$this->xml_config_path/letterbox.xml");
$_SESSION['civilite'] = array();
$_SESSION['civilite']['physique'] = array();
$_SESSION['civilite']['morale'] = array();
$_SESSION['nature'] = array();
$_SESSION['quartiers'] = array();
$_SESSION['tycketName'] = '';
$_SESSION['mail'] = array();
$_SESSION['print_sep_mode'] = array();
foreach( $xmlfile->xpath('/ROOT/CIVILITE/PHYSIQUE/CIV') as $CIV )
{
$_SESSION['civilite']['physique'][] = utf8_decode((string) $CIV);
}
foreach( $xmlfile->xpath('/ROOT/CIVILITE/MORALE/CIV') as $CIV )
{
$_SESSION['civilite']['morale'][] = utf8_decode((string) $CIV);
}
$increment = 0;
foreach($xmlfile->NATURE as $NATURE)
{
foreach($NATURE-> NAT as $NAT)
{
$_SESSION['nature'][$increment] = utf8_decode((string) $NAT);
$increment++;
}
}
$increment = 0;
foreach($xmlfile->QUARTIERS as $QUARTIERS)
{
foreach($QUARTIERS->QUA as $QUA)
{
$_SESSION['quartiers'][$increment] = utf8_decode((string) $QUA);
$increment++;
}
}
foreach($xmlfile->PRIORITES as $PRIORITES)
{
$_SESSION['priority']['default'] = utf8_decode ((string) $PRIORITES->DEFAULT[0]);
foreach($PRIORITES->PRI as $PRI)
{
$_SESSION['priority'][utf8_decode ($PRI->ID)]['label'] = utf8_decode ((string) $PRI->LABEL);
}
}
foreach($xmlfile->BORDEREAU as $TICKET)
{
$_SESSION['tycketName'] = utf8_decode ((string) $TICKET->NAME);
}
foreach($xmlfile->MAIL_ACTION as $MAIL_ACTION)
{
$_SESSION['mail_action']['default_to'] = utf8_decode ((string) $MAIL_ACTION->DEFAULT_TO[0]);
$_SESSION['mail_action']['default_cc'] = utf8_decode ((string) $MAIL_ACTION->DEFAULT_CC[0]);
foreach($MAIL_ACTION->ACTION as $ACTION)
{
$_SESSION['mail_action'][utf8_decode ($ACTION->ID)]['label'] = utf8_decode ((string) $ACTION->LABEL);
}
}
foreach($xmlfile->MAIL as $MAIL)
{
foreach($MAIL->children() as $FIELD)
{
$value = (string) $FIELD;
if( !empty($value) )
$_SESSION['mail'][$FIELD->getName()] = utf8_decode ($value);
if( ( strcasecmp(trim($FIELD),"true") == 0 ) || ( strcasecmp(trim($FIELD),"false") == 0 ) )
{
if( strcasecmp(trim($FIELD),"false") == 0 )
$_SESSION['mail'][$FIELD->getName()] = false;
else
$_SESSION['mail'][$FIELD->getName()] = true;
}
else
{
$_SESSION['mail'][$FIELD->getName()] = utf8_decode ( trim($FIELD) );
}
}
}
foreach($xmlfile->PRINT_SEP as $PRINT_SEP)
{
foreach($PRINT_SEP->children() as $TYPE)
{
//Boolean
if( ( strcasecmp(trim($TYPE),"true") == 0 ) || ( strcasecmp(trim($TYPE),"false") == 0 ) )
{
if( strcasecmp(trim($TYPE),"true") == 0 )
{
$_SESSION['print_sep_mode'][$TYPE->getName()] = true;
}
else
{
$_SESSION['print_sep_mode'][$TYPE->getName()] = false;
}
}
//String
else
{
$_SESSION['print_sep_mode'][$TYPE->getName()] = utf8_decode ( trim($TYPE) );
}
}
}
foreach($xmlfile->STREET_COMMUNE_ID as $STREET_COMMUNE_ID)
{
foreach($STREET_COMMUNE_ID->children() as $ID)
{
$value = (string) $ID;
if( !empty($value) )
$_SESSION['street_commune_id'][] = utf8_decode ($value);
}
}
}
/**
* Load the rights on the departments in the database (used in the class_usergroups.php file)
*
*/
public function load_group_service()
{
if(count($_SESSION['services_choisis']) > 0)
{
$where = " DESTINATION IN ( ";
for($i=0; $i < count($_SESSION['services_choisis']); $i++)
{
$where .= " \'".trim($_SESSION['services_choisis'][$i])."\', ";
}
$where = ereg_replace(", $", " )", $where);
}
else
{
$where = " (1=-1) ";
}
$this->connect();
$this->query("DELETE FROM ".$_SESSION['tablename']['security'] ." where GROUP_ID = '".$_SESSION['m_admin']['groups']['GroupId']."'");
$this->query("INSERT INTO ".$_SESSION['tablename']['security']." VALUES ('".$_SESSION['m_admin']['groups']['GroupId']."', '".$_SESSION['ressources'][0]['tablename']."', '".$where."', '', 'N' , 'N')");
}
/**
* List of the mail for the view_and_redirect basketpage
*
* @param array $listarr contains the document index of the process basket
* @param int $nb_total number of document
* @param string $title title
* @param string $name page name
*/
public function view_and_redirect($listarr, $nb_total, $title, $name)
{
$_SESSION['error'] = '';
// show the document list in result of the search
$page_list1 = "";
$page_list2 = "";
$func = new functions();
if(isset($_REQUEST['start']))
{
$start = strip_tags($_REQUEST['start']);
}
else
{
$start = 0;
}
if(isset($_GET['order']))
{
$orderby = strip_tags($_GET['order']);
}
else
{
$orderby = 0;
}
$link = "index.php?page=".$name;
// define the defaults values
$nb_show = $_SESSION['config']['nblinetoshow'];
$nb_pages = ceil($nb_total/$nb_show);
// if they are more than 1 page we do pagination with 2 forms
if($nb_pages > 1)
{
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$page_list2 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++)
{
$page_name = $i + 1;
$the_line = $i + 1;
if($start == $next_start)
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
else
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
$next_start = $next_start + $nb_show;
$lastpage = $next_start;
}
$lastpage = $lastpage - $nb_show;
$previous = "";
$next = "";
if($start > 0)
{
$start_prev = $start - $nb_show;
$previous = "< "._PREVIOUS." ";
}
if($start <> $lastpage)
{
$start_next = $start + $nb_show;
$next = " "._NEXT." >";
}
$page_list1 = $page_list1." ".$previous." ".$next."
";
$page_list2 = $page_list2." ".$previous." ".$next."
";
}
?>
1)
{
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$page_list2 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++)
{
$page_name = $i + 1;
$the_line = $i + 1;
if($start == $next_start)
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
else
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
$next_start = $next_start + $nb_show;
$lastpage = $next_start;
}
$lastpage = $lastpage - $nb_show;
$previous = "";
$next = "";
if($start > 0)
{
$start_prev = $start - $nb_show;
$previous = "< "._PREVIOUS." ";
}
if($start <> $lastpage)
{
$start_next = $start + $nb_show;
$next = " "._NEXT." >";
}
$page_list1 = $page_list1." ".$previous." ".$next."
";
$page_list2 = $page_list2." ".$previous." ".$next."
";
}
?>
1)
{
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$page_list2 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++)
{
$page_name = $i + 1;
$the_line = $i + 1;
if($start == $next_start)
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
else
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
$next_start = $next_start + $nb_show;
$lastpage = $next_start;
}
$lastpage = $lastpage - $nb_show;
$previous = "";
$next = "";
if($start > 0)
{
$start_prev = $start - $nb_show;
$previous = "< "._PREVIOUS." ";
}
if($start <> $lastpage)
{
$start_next = $start + $nb_show;
$next = " "._NEXT." >";
}
$page_list1 = $page_list1." ".$previous." ".$next."
";
$page_list2 = $page_list2." ".$previous." ".$next."
";
}
?>
clearserviceinfos();
}
if( $mode <> "add" && empty($_SESSION['error']))
{
$this->connect();
$this->query("select * from ".$_SESSION['tablename']['services']." where ID = '".$id."'");
if($this->nb_result() == 0)
{
$_SESSION['error'] = _DEPARTMENT.' '._ALREADY_EXISTS;
$state = false;
}
else
{
$_SESSION['m_admin']['services'] = array();
$line = $this->fetch_object();
$_SESSION['m_admin']['services']['ID'] = $line->ID;
$_SESSION['m_admin']['services']['LABEL'] = $line->SERVICE;
$_SESSION['m_admin']['services']['VALIDATE'] = $line->ENABLED;
if ($_SESSION['config']['collectivities'] =="true")
{
include_once($_SESSION['config']['includedir']."/addon_collectivities.php");
$selected_entities = get_selected_entities($_SESSION['m_admin']['services']['ID'], $this);
}
}
}
if ($_SESSION['config']['collectivities'] =="true")
{
include_once($_SESSION['config']['includedir']."/addon_collectivities.php");
$entities = get_xml_value();
}
?>
"._DOCTYPE.' '._UNKOWN."
";
}
else
{
?>
:
"prop" && $mode <> "add")
{
echo $func->show($_SESSION['m_admin']['services']['ID']);
?>
*
:
show($_SESSION['m_admin']['services']['LABEL']); ?> *
";
include_once($_SESSION['config']['includedir']."/addon_collectivities.php");
show_entities_list_in_formservice($entities,$selected_entities);
echo " ";
}
?>
wash($_REQUEST['name'], "no", _THE_LASTNAME.' ');
}
if ($_REQUEST['society_tag'] == "society")
{
$_SESSION['m_admin']['emet']['SOCIETE'] = $func->wash($_REQUEST['societe'], "no", _THE_SOCIETY." ");
}
if(isset($_REQUEST['civility']) && !empty($_REQUEST['civility']))
{
$_SESSION['m_admin']['emet']['CIVILITY'] = $func->wash($_REQUEST['civility'], "no", _CIVILITY.' ');
}
if(isset($_REQUEST['prenom']) && !empty($_REQUEST['prenom']))
{
$_SESSION['m_admin']['emet']['PRENOM'] = $func->wash($_REQUEST['prenom'], "no", _THE_FIRSTNAME.' ');
}
if(isset($_REQUEST['prenom']) && !empty($_REQUEST['prenom']))
{
$_SESSION['m_admin']['emet']['PRENOM'] = $func->wash($_REQUEST['prenom'], "no", _THE_FIRSTNAME.' ');
}
$_SESSION['m_admin']['emet']['FONCTION'] = '';
if(isset($_REQUEST['fonction']) && !empty($_REQUEST['fonction']))
{
$_SESSION['m_admin']['emet']['FONCTION'] = $func->wash($_REQUEST['fonction'], "no", _THE_FUNCTION.' ');
}
if ($_REQUEST['societe'] <> '')
{
$_SESSION['m_admin']['emet']['SOCIETE'] = $func->wash($_REQUEST['societe'], "no", _THE_SOCIETY." ");
}
else
{
$_SESSION['m_admin']['emet']['SOCIETE'] = '';
}
if ($_REQUEST['street_num'] <> '')
{
$_SESSION['m_admin']['emet']['STREET_NUM'] = $func->wash($_REQUEST['street_num'], "no", _ROAD_NUM.' ');
}
else
{
$_SESSION['m_admin']['emet']['STREET_NUM'] = '';
}
if ($_REQUEST['street'] <> '')
{
$_SESSION['m_admin']['emet']['STREET'] = $func->wash($_REQUEST['street'], "no", _ADDRESS.' ');
}
else
{
$_SESSION['m_admin']['emet']['STREET'] = '';
}
if ($_REQUEST['town'] <> '')
{
$_SESSION['m_admin']['emet']['TOWN'] = $func->wash($_REQUEST['town'], "no", _TOWN.' ');
}
else
{
$_SESSION['m_admin']['emet']['TOWN'] = '';
}
if ($_REQUEST['cp'] <> '')
{
$_SESSION['m_admin']['emet']['CP'] = $func->wash($_REQUEST['cp'], "no", _POSTAL_CODE.' ');
}
else
{
$_SESSION['m_admin']['emet']['CP'] = '';
}
if ($_REQUEST['phone'] <> '')
{
$_SESSION['m_admin']['emet']['PHONE'] = $func->wash($_REQUEST['phone'], "num", _PHONE." ");
}
else
{
$_SESSION['m_admin']['emet']['PHONE'] = '';
}
if ($_REQUEST['phone2'] <> '')
{
$_SESSION['m_admin']['emet']['PHONE2'] = $func->wash($_REQUEST['phone2'], "num", _PHONE."2 ");
}
else
{
$_SESSION['m_admin']['emet']['PHONE2'] = '';
}
if ($_REQUEST['mobile'] <> '')
{
$_SESSION['m_admin']['emet']['MOBILE'] = $func->wash($_REQUEST['mobile'], "num", _MOBILE." ");
}
else
{
$_SESSION['m_admin']['emet']['MOBILE'] = '';
}
if ($_REQUEST['fax'] <> '')
{
$_SESSION['m_admin']['emet']['FAX'] = $func->wash($_REQUEST['fax'], "num", _FAX." ");
}
else
{
$_SESSION['m_admin']['emet']['FAX'] = '';
}
if ($_REQUEST['mail'] <> '')
{
$_SESSION['m_admin']['emet']['MAIL'] = $func->wash($_REQUEST['mail'], "mail", _MAIL);
}
else
{
$_SESSION['m_admin']['emet']['MAIL'] = '';
}
/* if ($_REQUEST['tocontact'] <> '')
{
$_SESSION['m_admin']['emet']['TOCONTACT'] = $func->wash($_REQUEST['tocontact'], "no", "Contact privilegi�");
}
else
{
$_SESSION['m_admin']['emet']['TOCONTACT'] = '';
}*/
}
/**
* Return the user information in sessions vars
*
* @param string $mode add or up
*/
public function senderinfo($mode)
{
require_once("class_usergroup_content.php");
// return the user information in sessions vars
$func = new functions();
//Hack : Pour les civilité morales, on duplique le champ societé dans Nom
if ($_REQUEST['society_tag'] == "society"){
$_REQUEST['name'] = $_REQUEST['societe'];
$_SESSION['m_admin']['sender']['NAME'] = $_REQUEST['societe'];
$_REQUEST['prenom'] = '';
}
if (!$_REQUEST['society_tag'])
{
$_SESSION['m_admin']['sender']['NAME'] = $func->wash($_REQUEST['name'], "no", _THE_LASTNAME.' ');
}
if ($_REQUEST['society_tag'] == "society"){
$_SESSION['m_admin']['sender']['SOCIETE'] = $func->wash($_REQUEST['societe'], "no", _THE_SOCIETY." ");
}
if(isset($_REQUEST['civility']) && !empty($_REQUEST['civility']))
{
$_SESSION['m_admin']['sender']['CIVILITY'] = $func->wash($_REQUEST['civility'], "no", _CIVILITY.' ');
}
if(isset($_REQUEST['prenom']) && !empty($_REQUEST['prenom']))
{
$_SESSION['m_admin']['sender']['PRENOM'] = $func->wash($_REQUEST['prenom'], "no", _THE_FIRSTNAME.' ');
}
$_SESSION['m_admin']['sender']['FONCTION'] = '';
if(isset($_REQUEST['fonction']) && !empty($_REQUEST['fonction']))
{
$_SESSION['m_admin']['sender']['FONCTION'] = $func->wash($_REQUEST['fonction'], "no", _THE_FUNCTION.' ');
}
if ($_REQUEST['societe'] <> '')
{
$_SESSION['m_admin']['sender']['SOCIETE'] = $func->wash($_REQUEST['societe'], "no", _THE_SOCIETY." ");
}
else
{
$_SESSION['m_admin']['sender']['SOCIETE'] = '';
}
if ($_REQUEST['street'] <> '')
{
$_SESSION['m_admin']['sender']['STREET'] = $func->wash($_REQUEST['street'], "no", _ADDRESS.' ');
}
else
{
$_SESSION['m_admin']['sender']['STREET'] = '';
}
if ($_REQUEST['street_num'] <> '')
{
$_SESSION['m_admin']['sender']['STREET_NUM'] = $func->wash($_REQUEST['street_num'], "no", _ROAD_NUM.' ');
}
else
{
$_SESSION['m_admin']['sender']['STREET_NUM'] = '';
}
if ($_REQUEST['town'] <> '')
{
$_SESSION['m_admin']['sender']['TOWN'] = $func->wash($_REQUEST['town'], "no", _TOWN.' ');
}
else
{
$_SESSION['m_admin']['sender']['TOWN'] = '';
}
if ($_REQUEST['cp'] <> '')
{
$_SESSION['m_admin']['sender']['CP'] = $func->wash($_REQUEST['cp'], "no", _POSTAL_CODE.' ');
}
else
{
$_SESSION['m_admin']['sender']['CP'] = '';
}
if ($_REQUEST['phone'] <> '')
{
$_SESSION['m_admin']['sender']['PHONE'] = $func->wash($_REQUEST['phone'], "num", _PHONE." ");
}
else
{
$_SESSION['m_admin']['sender']['PHONE'] = '';
}
if ($_REQUEST['phone2'] <> '')
{
$_SESSION['m_admin']['sender']['PHONE2'] = $func->wash($_REQUEST['phone2'], "num", _PHONE."2 ");
}
else
{
$_SESSION['m_admin']['sender']['PHONE2'] = '';
}
if ($_REQUEST['mobile'] <> '')
{
$_SESSION['m_admin']['sender']['MOBILE'] = $func->wash($_REQUEST['mobile'], "num", _MOBILE." ");
}
else
{
$_SESSION['m_admin']['sender']['MOBILE'] = '';
}
if ($_REQUEST['fax'] <> '')
{
$_SESSION['m_admin']['sender']['FAX'] = $func->wash($_REQUEST['fax'], "num", _FAX." ");
}
else
{
$_SESSION['m_admin']['sender']['FAX'] = '';
}
if ($_REQUEST['mail'] <> '')
{
$_SESSION['m_admin']['sender']['MAIL'] = $func->wash($_REQUEST['mail'], "mail", _MAIL);
}
else
{
$_SESSION['m_admin']['sender']['MAIL'] = '';
}
}
/**
* To allow to delete contacts
*
* @param integer $id contact identifier
* @param string $mode allow, ban or del
*/
public function admincontact($id, $mode, $redirect)
{
// To allow administrator to admin users
if(!empty($_SESSION['error'])){
if(!empty($redirect)){
?>
connect();
$this->query("select ID, LASTNAME, FIRSTNAME from ".$_SESSION['tablename']['senders']." where ID = '".$id."' and TOCONTACT = '".$_SESSION['user']['UserId']."'");
if($this->nb_result() == 0){
$_SESSION['error'] = _CONTACT.' '._UNKNOWN;
if(!empty($redirect)){
?>
fetch_object();
$theuser = $info->LastName." ".$info->FirstName;
if($mode == "del" ){
$this->query("delete from ".$_SESSION['tablename']['senders']." where ID = '".$id."' and TOCONTACT = '".$_SESSION['user']['UserId']."' ");
$_SESSION['error'] = _DELETED_CONTACT;
}
if(!empty($redirect)){
?>
wash($_REQUEST['name'], "no", _THE_LASTNAME.' ');
}
if ($_REQUEST['society_tag'] == "society"){
$_SESSION['m_admin']['sender']['SOCIETE'] = $func->wash($_REQUEST['societe'], "no", _THE_SOCIETY." ");
}
if(isset($_REQUEST['civility']) && !empty($_REQUEST['civility'])){
$_SESSION['user']['contact']['CIVILITY'] = $func->wash($_REQUEST['civility'], "no", _CIVILITY.' ');
}
if(isset($_REQUEST['prenom']) && !empty($_REQUEST['prenom'])){
$_SESSION['user']['contact']['PRENOM'] = $func->wash($_REQUEST['prenom'], "no", _THE_FIRSTNAME.' ');
}
$_SESSION['user']['contact']['FONCTION'] = '';
if(isset($_REQUEST['fonction']) && !empty($_REQUEST['fonction'])){
$_SESSION['user']['contact']['FONCTION'] = $func->wash($_REQUEST['fonction'], "no", _THE_FUNCTION.' ');
}
if ($_REQUEST['societe'] <> ''){
$_SESSION['user']['contact']['SOCIETE'] = $func->wash($_REQUEST['societe'], "no", _THE_SOCIETY." ");
}
else{
$_SESSION['user']['contact']['SOCIETE'] = '';
}
if ($_REQUEST['street'] <> ''){
$_SESSION['user']['contact']['STREET'] = $func->wash($_REQUEST['street'], "no", _ADDRESS.' ');
}
else{
$_SESSION['user']['contact']['STREET'] = '';
}
if ($_REQUEST['street_num'] <> ''){
$_SESSION['user']['contact']['STREET_NUM'] = $func->wash($_REQUEST['street_num'], "no", _ROAD_NUM.' ');
}
else{
$_SESSION['user']['contact']['STREET_NUM'] = '';
}
if ($_REQUEST['town'] <> ''){
$_SESSION['user']['contact']['TOWN'] = $func->wash($_REQUEST['town'], "no", _TOWN.' ');
}
else{
$_SESSION['user']['contact']['TOWN'] = '';
}
if ($_REQUEST['cp'] <> ''){
$_SESSION['user']['contact']['CP'] = $func->wash($_REQUEST['cp'], "no", _POSTAL_CODE.' ');
}
else{
$_SESSION['user']['contact']['CP'] = '';
}
if ($_REQUEST['phone'] <> ''){
$_SESSION['user']['contact']['PHONE'] = $func->wash($_REQUEST['phone'], "num", _PHONE." ");
}
else{
$_SESSION['user']['contact']['PHONE'] = '';
}
if ($_REQUEST['phone2'] <> ''){
$_SESSION['user']['contact']['PHONE2'] = $func->wash($_REQUEST['phone2'], "num", _PHONE."2 ");
}
else{
$_SESSION['m_admin']['sender']['PHONE2'] = '';
}
if ($_REQUEST['mobile'] <> ''){
$_SESSION['user']['contact']['MOBILE'] = $func->wash($_REQUEST['mobile'], "num", _MOBILE." ");
}
else{
$_SESSION['user']['contact']['MOBILE'] = '';
}
if ($_REQUEST['fax'] <> ''){
$_SESSION['user']['contact']['FAX'] = $func->wash($_REQUEST['fax'], "num", _FAX." ");
}
else{
$_SESSION['user']['contact']['FAX'] = '';
}
$_SESSION['user']['contact']['MAIL'] = $func->wash($_REQUEST['mail'], "mail", _MAIL);
/*if ($_REQUEST['mail'] <> ''){
$_SESSION['user']['contact']['MAIL'] = $func->wash($_REQUEST['mail'], "mail", _MAIL);
}
else{
$_SESSION['user']['contact']['MAIL'] = '';
}*/
}
/**
* Add ou modify emett in the database
*
* @param string $mode up or add
*/
public function addupemet($mode)
{
// add ou modify users in the database
$this->emetinfo($mode);
if(!empty($_SESSION['error']))
{
if($mode == "up")
{
if(!empty($_SESSION['m_admin']['emet']['ID']))
{
header("location: index.php?page=emet_up&id=".$_SESSION['m_admin']['emet']['ID']);
exit;
}
else
{
header("location: index.php?page=emet");
exit;
}
}
if($mode == "add")
{
header("location: index.php?page=emet_add");
exit;
}
}
else
{
$this->connect();
if($mode == "add")
{
$this->query("INSERT INTO `".$_SESSION['tablename']['senders']."` ( CIVILITY, LASTNAME , FIRSTNAME , SOCIETY, FUNCTION ,STREET_NUM, STREET, TOWN, CP, PHONE, PHONE2, MOBILE, FAX, MAIL )
VALUES ( '".$_SESSION['m_admin']['emet']['CIVILITY']."','".$_SESSION['m_admin']['emet']['NAME']."', '".$_SESSION['m_admin']['emet']['PRENOM']."',
'".$_SESSION['m_admin']['emet']['SOCIETE']."', '".$_SESSION['m_admin']['emet']['FONCTION']."', '".$_SESSION['m_admin']['emet']['STREET_NUM']."','".$_SESSION['m_admin']['emet']['STREET']."', '".$_SESSION['m_admin']['emet']['TOWN']."',
'".$_SESSION['m_admin']['emet']['CP']."', '".$_SESSION['m_admin']['emet']['PHONE']."', '".$_SESSION['m_admin']['emet']['PHONE2']."', '".$_SESSION['m_admin']['emet']['MOBILE']."',
'".$_SESSION['m_admin']['emet']['FAX']."','".$_SESSION['m_admin']['emet']['MAIL']."' )");
$this->clearemetinfos();
$_SESSION['error'] = _SHIPPER_ADDED;
header("location: index.php?page=emet");
exit;
}
elseif($mode == "up")
{
$this->query("update `".$_SESSION['tablename']['senders']."` set `CIVILITY` = '".$_SESSION['m_admin']['emet']['CIVILITY']."',`LASTNAME` = '".$_SESSION['m_admin']['emet']['NAME']."', `FIRSTNAME` = '".$_SESSION['m_admin']['emet']['PRENOM']."',
`FUNCTION` = '".$_SESSION['m_admin']['emet']['FONCTION']."', `SOCIETY` = '".$_SESSION['m_admin']['emet']['SOCIETE']."', `STREET` = '".$_SESSION['m_admin']['emet']['STREET']."', `STREET_NUM` = '".$_SESSION['m_admin']['emet']['STREET_NUM']."',
`TOWN` = '".$_SESSION['m_admin']['emet']['TOWN']."', `CP` = '".$_SESSION['m_admin']['emet']['CP']."' , `PHONE` = '".$_SESSION['m_admin']['emet']['PHONE']."', `PHONE2` = '".$_SESSION['m_admin']['emet']['PHONE2']."',
`MOBILE` = '".$_SESSION['m_admin']['emet']['MOBILE']."',`FAX` = '".$_SESSION['m_admin']['emet']['FAX']."',`MAIL` = '".$_SESSION['m_admin']['emet']['MAIL']."' where ID = '".$_SESSION['m_admin']['emet']['ID']."'");
$this->clearemetinfos();
$_SESSION['error'] = _SHIPPER_UPDATED;
header("location: index.php?page=emet");
exit;
}
}
}
/**
* Add ou modify a sender in the database
*
* @param string $mode up or add
*/
public function addupsender($mode)
{
// add ou modify users in the database
$this->senderinfo($mode);
if(!empty($_SESSION['error']))
{
if($mode == "up")
{
if(!empty($_SESSION['m_admin']['sender']['ID']))
{
header("location: index.php?page=sender_up&id=".$_SESSION['m_admin']['sender']['ID']);
exit;
}
else
{
header("location: index.php?page=sender");
exit;
}
}
if($mode == "add")
{
header("location: index.php?page=sender_add");
exit;
}
}
else
{
$this->connect();
if($mode == "add")
{
$this->query("INSERT INTO `".$_SESSION['tablename']['senders']."` ( CIVILITY, LASTNAME , FIRSTNAME , SOCIETY, FUNCTION , STREET_NUM, STREET, TOWN, CP, PHONE, PHONE2, MOBILE, FAX, MAIL, TOCONTACT )
VALUES ( '".$_SESSION['m_admin']['sender']['CIVILITY']."','".$_SESSION['m_admin']['sender']['NAME']."', '".$_SESSION['m_admin']['sender']['PRENOM']."',
'".$_SESSION['m_admin']['sender']['SOCIETE']."', '".$_SESSION['m_admin']['sender']['FONCTION']."', '".$_SESSION['m_admin']['sender']['STREET_NUM']."', '".$_SESSION['m_admin']['sender']['STREET']."', '".$_SESSION['m_admin']['sender']['TOWN']."',
'".$_SESSION['m_admin']['sender']['CP']."', '".$_SESSION['m_admin']['sender']['PHONE']."', '".$_SESSION['m_admin']['sender']['PHONE2']."', '".$_SESSION['m_admin']['sender']['MOBILE']."',
'".$_SESSION['m_admin']['sender']['FAX']."','".$_SESSION['m_admin']['sender']['MAIL']."','EXT')");
$this->clearsenderinfos();
$_SESSION['error'] = _SENDER_ADDED;
header("location: index.php?page=sender");
exit;
}
elseif($mode == "up")
{
$this->query("update `".$_SESSION['tablename']['senders']."` set `CIVILITY` = '".$_SESSION['m_admin']['sender']['CIVILITY']."',`LASTNAME` = '".$_SESSION['m_admin']['sender']['NAME']."', `FIRSTNAME` = '".$_SESSION['m_admin']['sender']['PRENOM']."',
`FUNCTION` = '".$_SESSION['m_admin']['sender']['FONCTION']."', `SOCIETY` = '".$_SESSION['m_admin']['sender']['SOCIETE']."', `STREET` = '".$_SESSION['m_admin']['sender']['STREET']."', `STREET_NUM` = '".$_SESSION['m_admin']['sender']['STREET_NUM']."',
`TOWN` = '".$_SESSION['m_admin']['sender']['TOWN']."', `CP` = '".$_SESSION['m_admin']['sender']['CP']."' , `PHONE` = '".$_SESSION['m_admin']['sender']['PHONE']."', `PHONE2` = '".$_SESSION['m_admin']['sender']['PHONE2']."',
`MOBILE` = '".$_SESSION['m_admin']['sender']['MOBILE']."',`FAX` = '".$_SESSION['m_admin']['sender']['FAX']."',`MAIL` = '".$_SESSION['m_admin']['sender']['MAIL']."',`TOCONTACT` = 'EXT' where ID = '".$_SESSION['m_admin']['sender']['ID']."'");
$this->clearsenderinfos();
$_SESSION['error'] = _SENDER_UPDATED;
header("location: index.php?page=sender");
exit;
}
}
}
/**
* Add ou modify a sender in the database
*
* @param string $mode up or add
*/
public function addupcontact($mode, $redirect)
{
// add ou modify users in the database
$this->contactinfo($mode);
if(!empty($_SESSION['error'])){
if($mode == "up"){
if(!empty($_SESSION['user']['contact']['ID'])){
if(!empty($redirect)){
?>
connect();
if($mode == "add"){
$this->query("INSERT INTO `".$_SESSION['tablename']['senders']."` ( CIVILITY, LASTNAME , FIRSTNAME , SOCIETY, FUNCTION , STREET_NUM, STREET, TOWN, CP, PHONE, PHONE2, MOBILE, FAX, MAIL, TOCONTACT )
VALUES ( '".$_SESSION['user']['contact']['CIVILITY']."','".$_SESSION['user']['contact']['NAME']."', '".$_SESSION['user']['contact']['PRENOM']."',
'".$_SESSION['user']['contact']['SOCIETE']."', '".$_SESSION['user']['contact']['FONCTION']."', '".$_SESSION['user']['contact']['STREET_NUM']."', '".$_SESSION['user']['contact']['STREET']."', '".$_SESSION['user']['contact']['TOWN']."',
'".$_SESSION['user']['contact']['CP']."', '".$_SESSION['user']['contact']['PHONE']."', '".$_SESSION['user']['contact']['PHONE2']."', '".$_SESSION['user']['contact']['MOBILE']."',
'".$_SESSION['user']['contact']['FAX']."','".$_SESSION['user']['contact']['MAIL']."','".$_SESSION['user']['UserId']."')");
$this->clearcontactinfos();
$_SESSION['error'] = _CONTACT_ADDED;
//header("location: index.php?page=sender");
if(!empty($redirect)){
?>
query("update `".$_SESSION['tablename']['senders']."` set `CIVILITY` = '".$_SESSION['user']['contact']['CIVILITY']."',`LASTNAME` = '".$_SESSION['user']['contact']['NAME']."', `FIRSTNAME` = '".$_SESSION['user']['contact']['PRENOM']."',
`FUNCTION` = '".$_SESSION['user']['contact']['FONCTION']."', `SOCIETY` = '".$_SESSION['user']['contact']['SOCIETE']."', `STREET` = '".$_SESSION['user']['contact']['STREET']."', `STREET_NUM` = '".$_SESSION['user']['contact']['STREET_NUM']."',
`TOWN` = '".$_SESSION['user']['contact']['TOWN']."', `CP` = '".$_SESSION['user']['contact']['CP']."' , `PHONE` = '".$_SESSION['user']['contact']['PHONE']."', `PHONE2` = '".$_SESSION['user']['contact']['PHONE2']."',
`MOBILE` = '".$_SESSION['user']['contact']['MOBILE']."',`FAX` = '".$_SESSION['user']['contact']['FAX']."',`MAIL` = '".$_SESSION['user']['contact']['MAIL']."',`TOCONTACT` = '".$_SESSION['user']['UserId']."' where ID = '".$_SESSION['user']['contact']['ID']."'");
$this->clearcontactinfos();
$_SESSION['error'] = _CONTACT_UPDATED;
if(!empty($redirect)){
?>
clearemetinfos();
}
if( $mode <> "add" && empty($_SESSION['error']))
{
$this->connect();
$this->query("select * from ".$_SESSION['tablename']['senders']." where ID = '".$id."'");
if($this->nb_result() == 0)
{
$_SESSION['error'] = _THE_SHIPPER.' '._ALREADY_EXISTS;
$state = false;
}
else
{
$_SESSION['m_admin']['emet'] = array();
$line = $this->fetch_object();
$_SESSION['m_admin']['emet']['CIVILITY'] = $line->CIVILITY;
$_SESSION['m_admin']['emet']['ID'] = $line->ID;
$_SESSION['m_admin']['emet']['NAME'] = $line->LASTNAME;
$_SESSION['m_admin']['emet']['PRENOM'] = $line->FIRSTNAME;
$_SESSION['m_admin']['emet']['SOCIETE'] = $line->SOCIETY;
$_SESSION['m_admin']['emet']['FONCTION'] = $line->FUNCTION;
$_SESSION['m_admin']['emet']['STREET_NUM'] = $line->STREET_NUM;
$_SESSION['m_admin']['emet']['STREET'] = $line->STREET;
$_SESSION['m_admin']['emet']['TOWN'] = $line->TOWN;
$_SESSION['m_admin']['emet']['CP'] = $line->CP;
$_SESSION['m_admin']['emet']['PHONE'] = $line->PHONE;
$_SESSION['m_admin']['emet']['PHONE2'] = $line->PHONE2;
$_SESSION['m_admin']['emet']['MOBILE'] = $line->MOBILE;
$_SESSION['m_admin']['emet']['FAX'] = $line->FAX;
$_SESSION['m_admin']['emet']['MAIL'] = $line->MAIL;
$_SESSION['m_admin']['emet']['TOCONTACT'] = $line->TOCONTACT;
}
}
?>
clearsenderinfos();
}
if( $mode <> "add" && empty($_SESSION['error']))
{
$this->connect();
$this->query("select * from ".$_SESSION['tablename']['senders']." where ID = '".$id."'");
if($this->nb_result() == 0)
{
$_SESSION['error'] = _THE_SENDER.' '._ALREADY_EXISTS;
$state = false;
}
else
{
$_SESSION['m_admin']['sender'] = array();
$line = $this->fetch_object();
$_SESSION['m_admin']['sender']['ID'] = $line->ID;
$_SESSION['m_admin']['sender']['CIVILITY'] = $line->CIVILITY;
$_SESSION['m_admin']['sender']['NAME'] = $line->LASTNAME;
$_SESSION['m_admin']['sender']['PRENOM'] = $line->FIRSTNAME;
$_SESSION['m_admin']['sender']['SOCIETE'] = $line->SOCIETY;
$_SESSION['m_admin']['sender']['FONCTION'] = $line->FUNCTION;
$_SESSION['m_admin']['sender']['STREET_NUM'] = $line->STREET_NUM;
$_SESSION['m_admin']['sender']['STREET'] = $line->STREET;
$_SESSION['m_admin']['sender']['TOWN'] = $line->TOWN;
$_SESSION['m_admin']['sender']['CP'] = $line->CP;
$_SESSION['m_admin']['sender']['PHONE'] = $line->PHONE;
$_SESSION['m_admin']['sender']['PHONE2'] = $line->PHONE2;
$_SESSION['m_admin']['sender']['MOBILE'] = $line->MOBILE;
$_SESSION['m_admin']['sender']['FAX'] = $line->FAX;
$_SESSION['m_admin']['sender']['MAIL'] = $line->MAIL;
$_SESSION['m_admin']['sender']['TOCONTACT'] = $line->TOCONTACT;
}
}
?>
clearcontactinfos();
}
if( $mode <> "add" && empty($_SESSION['error'])){
$this->connect();
$this->query("select * from ".$_SESSION['tablename']['senders']." where ID = '".$id."'");
if($this->nb_result() == 0) {
$_SESSION['error'] = _CONTACT.' '._ALREADY_EXISTS;
$state = false;
}
else{
$_SESSION['user']['contact'] = array();
$line = $this->fetch_object();
$_SESSION['user']['contact']['ID'] = $line->ID;
$_SESSION['user']['contact']['CIVILITY'] = $line->CIVILITY;
$_SESSION['user']['contact']['NAME'] = $line->LASTNAME;
$_SESSION['user']['contact']['PRENOM'] = $line->FIRSTNAME;
$_SESSION['user']['contact']['SOCIETE'] = $line->SOCIETY;
$_SESSION['user']['contact']['FONCTION'] = $line->FUNCTION;
$_SESSION['user']['contact']['STREET_NUM'] = $line->STREET_NUM;
$_SESSION['user']['contact']['STREET'] = $line->STREET;
$_SESSION['user']['contact']['TOWN'] = $line->TOWN;
$_SESSION['user']['contact']['CP'] = $line->CP;
$_SESSION['user']['contact']['PHONE'] = $line->PHONE;
$_SESSION['user']['contact']['PHONE2'] = $line->PHONE2;
$_SESSION['user']['contact']['MOBILE'] = $line->MOBILE;
$_SESSION['user']['contact']['FAX'] = $line->FAX;
$_SESSION['user']['contact']['MAIL'] = $line->MAIL;
//$_SESSION['user']['contact']['TOCONTACT'] = $line->TOCONTACT;
}
}
?>
";
}
$_SESSION['m_admin']['services']['LABEL'] = $func->wash($_REQUEST['label'], "no", _THE_WORDING);
$_SESSION['m_admin']['services']['ID'] = $func->wash($_REQUEST['id'], "no", _ID);
}
/**
* Update or insert trhe database with the department info
*/
public function upservices()
{
$this->servicesinfo();
if(!empty($_SESSION['error']))
{
if($_REQUEST['mode'] == "up")
{
if(!empty($_SESSION['m_admin']['services']['ID']))
{
header("location: index.php?page=service_up&id=".$_SESSION['m_admin']['services']['ID']);
exit;
}
else
{
header("location: index.php?page=liste");
exit;
}
}
elseif($_REQUEST['mode'] == "add" )
{
header("location: index.php?page=service_add");
exit;
}
}
else
{
$this->connect();
if( $_REQUEST['mode'] <> "add")
{
$this->query("update `".$_SESSION['tablename']['services']."` set `SERVICE` = '".addslashes($_SESSION['m_admin']['services']['LABEL'])."' , `ENABLED` = 'Y' where ID = '".$_SESSION['m_admin']['services']['ID']."'");
if($_SESSION['config']['collectivities'] == "true")
{
include_once($_SESSION['config']['includedir']."/addon_collectivities.php");
up_collectivity($_REQUEST['entities'], $_SESSION['m_admin']['services']['ID'],$this);
}
if($_REQUEST['mode'] == "up")
{
$_SESSION['error'] = _DEPARTMENT_MODIF;
if($_SESSION['history']['servicesup'] == "true")
{
require_once("class_history.php");
$users = new history();
$users->add($_SESSION['tablename']['services'], $_SESSION['m_admin']['services']['ID'],"UP",_DEPARTMENT_MODIF." : ".$_SESSION['m_admin']['services']['LABEL']);
}
}
$this->clearserviceinfos();
header("location: index.php?page=liste");
exit;
}
else
{
$this->query("select ID from `".$_SESSION['tablename']['services']."` where ID = '".$_SESSION['m_admin']['services']['ID']."'");
if($this->nb_result() > 0)
{
$_SESSION['error'] = _THE_DEPARTMENT.' '.$_SESSION['m_admin']['services']['ID'].' '._ALREADY_EXISTS;
header("location: index.php?page=service_add&show=false");
exit;
}
else
{
require_once("class_history.php");
$users = new history();
if( $_REQUEST['mode'] == "add")
{
$this->query("INSERT INTO `".$_SESSION['tablename']['services']."` ( `ID` , `SERVICE`,`ENABLED` ) VALUES ('".$_SESSION['m_admin']['services']['ID']."', '".$_SESSION['m_admin']['services']['LABEL']."','Y')");
if($_SESSION['config']['collectivities'] == "true")
{
include_once($_SESSION['config']['includedir']."/addon_collectivities.php");
add_collectivity($_REQUEST['entities'], $_SESSION['m_admin']['services']['ID'],$this);
}
if($_SESSION['history']['servicesadd'] == "true")
{
$users->add($_SESSION['tablename']['services'], $_SESSION['m_admin']['services']['ID'],"ADD", _DEPARTMENT_ADDED." : ".$_SESSION['m_admin']['services']['LABEL']);
}
}
$_SESSION['error'] = _DEPARTMENT_ADDED;
}
$_SESSION['error'] = "";
}
if ($_REQUEST['mode'] == "add")
{
$url = "index.php?page=liste";
}
$this->clearserviceinfos();
header("location: ".$url);
exit;
}
}
/**
* List of the mail in copy
*
* @param array $listarr contains the document index of the mail in copy
* @param int $nb_total number of document
* @param string $title title
* @param string $name page name
*/
public function list_copy_mail($listarr, $nb_total, $title,$name )
{
$page_list1 = "";
$page_list2 = "";
$func = new functions();
if(isset($_REQUEST['start']))
{
$start = strip_tags($_REQUEST['start']);
}
else
{
$start = 0;
}
if(isset($_GET['order']))
{
$orderby = strip_tags($_GET['order']);
}
else
{
$orderby = 0;
}
$link = "index.php?page=".$name;
// define the defaults values
$nb_show = $_SESSION['config']['nblinetoshow'];
$nb_pages = ceil($nb_total/$nb_show);
// if they are more 1 page we do pagination with 2 forms
if($nb_pages > 1)
{
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$page_list2 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++)
{
$page_name = $i + 1;
$the_line = $i + 1;
if($start == $next_start)
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
else
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
$next_start = $next_start + $nb_show;
$lastpage = $next_start;
}
$lastpage = $lastpage - $nb_show;
$previous = "";
$next = "";
if($start > 0)
{
$start_prev = $start - $nb_show;
$previous = "< "._PREVIOUS." ";
}
if($start <> $lastpage)
{
$start_next = $start + $nb_show;
$next = " "._NEXT." >";
}
$page_list1 = $page_list1." ".$previous." ".$next."
";
$page_list2 = $page_list2." ".$previous." ".$next."
";
}
?>
0)
{
echo '';
}
?>
>
dateformat($listarr[$theline]['CREATION_DATE']);
}
else
{
if("0000-00-00" == $listarr[$theline]['ARRIVEE'] || "00-00-0000" == $listarr[$theline]['ARRIVEE'])
{
echo $this->dateformat($listarr[$theline]['CREATION_DATE']);
}
else
{
echo $this->dateformat($listarr[$theline]['ARRIVEE']);
}
}?>
show($listarr[$theline]['ID']); ?>
show($listarr[$theline]['NOM']); ?>
show($listarr[$theline]['OBJET']); ?>
show($listarr[$theline]['TYPE']); ?>
show($listarr[$theline]['DEST']); ?>
0)
{
echo ' ';
}
echo "
";
echo "
"._CLICK_LINE_VIEW." ";
if ($_SESSION['user']['print_rights'] == true)
{
?>
";
}
/**
* List of the mail in the autorized departments
*
* @param array $listarr contains the document index
* @param int $nb_total number of document
* @param string $title title
* @param string $name page name
*/
public function dep_mail_list($listarr, $nb_total, $title, $service, $status )
{
$page_list1 = "";
$page_list2 = "";
$func = new functions();
if(isset($_REQUEST['start']))
{
$start = strip_tags($_REQUEST['start']);
}
else
{
$start = 0;
}
if(isset($_GET['order']))
{
$orderby = strip_tags($_GET['order']);
}
else
{
$orderby = 0;
}
$link = "dep_result.php";
// define the defaults values
$nb_show = $_SESSION['config']['nblinetoshow'];
$nb_pages = ceil($nb_total/$nb_show);
// if they are more 1 page we do pagination with 2 forms
if($nb_pages > 1)
{
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$page_list2 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++)
{
$page_name = $i + 1;
$the_line = $i + 1;
if($start == $next_start)
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
else
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
$next_start = $next_start + $nb_show;
$lastpage = $next_start;
}
$lastpage = $lastpage - $nb_show;
$previous = "";
$next = "";
if($start > 0)
{
$start_prev = $start - $nb_show;
$previous = "< "._PREVIOUS." ";
}
if($start <> $lastpage)
{
$start_next = $start + $nb_show;
$next = " "._NEXT." >";
}
$page_list1 = $page_list1." ".$previous." ".$next."
";
$page_list2 = $page_list2." ".$previous." ".$next."
";
}
//exit();
?>
connect();
$this->query("select ID from ".$_SESSION['tablename']['senders']." where ID = ".$id);
if($this->nb_result() == 0)
{
$_SESSION['error'] = _SHIPPER.' '._UNKNOWN;
header("location: index.php?page=emet");
exit;
}
else
{
$res = $this->fetch_object();
$label = $res->LABEL;
$this->query("delete from ".$_SESSION['tablename']['senders']." where ID = ".$id);
$_SESSION['error'] = _SHIPPER." ".strtolower(_DELETED);
header("location: index.php?page=emet");
exit;
}
}
}
/**
* delete a model in the database
*
* @param string $id model identifier
*/
public function delsender($id)
{
if(!empty($_SESSION['error']))
{
header("location: index.php?page=sender");
exit;
}
else
{
$this->connect();
$this->query("select ID from ".$_SESSION['tablename']['senders']." where ID = ".$id);
if($this->nb_result() == 0)
{
$_SESSION['error'] = _SENDER.' '._UNKNOWN;
header("location: index.php?page=sender");
exit;
}
else
{
$res = $this->fetch_object();
$label = $res->LABEL;
$this->query("delete from ".$_SESSION['tablename']['senders']." where ID = ".$id);
$_SESSION['error'] = _SENDER." ".strtolower(_DELETED);
header("location: index.php?page=sender");
exit;
}
}
}
/**
* List of the out mail basket
*
* @param array $listarr contains the document index of the out basket
* @param int $nb_total number of document
* @param string $title title
* @param string $name page name
*/
public function mail_out($listarr, $nb_total, $title, $name)
{
//$_SESSION['diff'] = array();
$_SESSION['error'] = '';
// show the document list in result of the search
$page_list1 = "";
$page_list2 = "";
$func = new functions();
if(isset($_REQUEST['start']))
{
$start = strip_tags($_REQUEST['start']);
}
else
{
$start = 0;
}
if(isset($_GET['order']))
{
$orderby = strip_tags($_GET['order']);
}
else
{
$orderby = 0;
}
$link = "index.php?page=".$name;
// define the defaults values
$nb_show = $_SESSION['config']['nblinetoshow'];
$nb_pages = ceil($nb_total/$nb_show);
// if they are more than 1 page we do pagination with 2 forms
if($nb_pages > 1)
{
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$page_list2 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++)
{
$page_name = $i + 1;
$the_line = $i + 1;
if($start == $next_start)
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
else
{
$page_list1 .= "".$the_line." ";
$page_list2 .= "".$the_line." ";
}
$next_start = $next_start + $nb_show;
$lastpage = $next_start;
}
$lastpage = $lastpage - $nb_show;
$previous = "";
$next = "";
if($start > 0)
{
$start_prev = $start - $nb_show;
$previous = "< "._PREVIOUS." ";
}
if($start <> $lastpage)
{
$start_next = $start + $nb_show;
$next = " "._NEXT." >";
}
$page_list1 = $page_list1." ".$previous." ".$next."
";
$page_list2 = $page_list2." ".$previous." ".$next."
";
}
?>
query("select * from ".$_SESSION['tablename']['listinstance']." where res_id = ".$res_id);
if($this->nb_result() < 1)
{
$this->query("insert into ".$_SESSION['tablename']['listinstance']." (res_table, res_id, sequence, user_id, by_user_id) values ('res_x', ".$res_id.", 1, '".$user_id."','".$_SESSION['user']['UserId']."')");
//$this->show();
}
else
{
$this->query("update ".$_SESSION['tablename']['listinstance']." set user_id = '".$user_id."', by_user_id = '".$_SESSION['user']['UserId']."' where res_id = ".$res_id." and res_table = 'res_x' and sequence = 1");
//$this->show();
}
//exit();
}
/**
* delete a note in the database
*
* @param string $id note identifier
*/
public function delnote($id, $resid)
{
if(!empty($_SESSION['error']))
{
?>
connect();
$this->query("select ID from ".$_SESSION['tablename']['notes']." where ID = ".$id." and USER_ID = '".$_SESSION['user']['UserId']."'");
if($this->nb_result() == 0)
{
$_SESSION['error'] = _CANT_DELETE_NOTE;
header("location: index.php?page=details&id=".$resid);
exit;
}
else
{
$res = $this->fetch_object();
$label = $res->LABEL;
$this->query("delete from ".$_SESSION['tablename']['notes']." where ID = ".$id);
//Mise à jour de l'historique
if($_SESSION['history']['notesdel'])
{
require_once("class_history.php");
$hist = new history();
$hist->add($_SESSION['tablechoice'], $resid ,"DEL", _DELETION_NOTE);
}
header("location: notes_courrier.php?id=".$resid);
exit;
}
}
}
public function increment_viewed_var($res_table, $res_id, $user_id)
{
if(!empty($res_table) && !empty($res_id) && !empty($user_id))
{
$this->connect();
$this->query("select viewed from ".$_SESSION['tablename']['listinstance']." where res_table ='".$res_table."' and res_id = ".$res_id." and user_id = '".$user_id."'");
if($this->nb_result() == 0)
{
return false;
}
else
{
$res = $this->fetch_object();
$viewed = $res->viewed;
$viewed ++;
$this->query("update ".$_SESSION['tablename']['listinstance']." set viewed = ".$viewed." where res_table ='".$res_table."' and res_id = ".$res_id." and user_id = '".$user_id."'");
//$this->show();
return true;
}
}
else
{
return false;
}
}
public function release($res_id, $res_table)
{
$this->connect();
$this->query("DELETE FROM ".$_SESSION['tablename']['param']." where key1 = '".$res_table."' and key2 = '".$res_id."' and id = 'affaire_reservee'");
}
public function is_locked($res_id, $res_table, $time)
{
$nextime = time() + ($time * 60);
$this->connect();
$this->query("SELECT param_value_char as by_user_id, value as locktime from ".$_SESSION['tablename']['param']."
WHERE id = 'affaire_reservee'
AND key1 = '".$res_table."'
AND key2 = '".$res_id."'");
$locked = false;
if($res = $this->fetch_object())
{
if( $res->by_user_id == $_SESSION['user']['UserId'] )
{
$this->query("UPDATE ". $_SESSION['tablename']['param']."
SET value = '".$nextime."'
where key1 = '".$res_table."'
AND key2 = '".$res_id."'
AND id = 'affaire_reservee'");
}
else
{
$locked = true;
}
}
else
{
$this->query(" INSERT INTO ".$_SESSION['tablename']['param']."
(key1, key2, id, value,param_value_char) VALUES
('".$res_table."','".$res_id."','affaire_reservee','".$nextime."','".$_SESSION['user']['UserId']."')");
}
return $locked;
}
public function test_reserved_time($res_id, $res_table)
{
$this->connect();
$this->query("SELECT param_value_char as by_user_id, value as locktime from ".$_SESSION['tablename']['param']."
WHERE id = 'affaire_reservee'
AND key1 = '".$res_table."'
AND key2 = '".$res_id."'");
//Not reserved
$by_user_id = null;
if($res = $this->fetch_object())
{
//Reserved
// Reserved time expired
if( ($res->locktime - mktime( date("H") , date("i") , date("s") , date("m") , date("d") , date("Y"))) < 0 )
{
$this->query("DELETE FROM ".$_SESSION['tablename']['param']." where key1 = '".$res_table."' and key2 = '".$res_id."' and id = 'affaire_reservee'");
}
// Reserved time not yet expired
else
{
$by_user_id = $res->by_user_id;
}
}
return $by_user_id;
}
public function mail_attachement($to,
$cc='',
$cci='',
$subject,
$message,
$tabDocJoin ,
$reply ='',
$from = '',
$fromName = '',
$isHtml = false
)
{
require_once($_SESSION['config']['path_to_php_mailer']."/class.phpmailer.php");
require_once($_SESSION['config']['path_to_php_mailer']."/class.smtp.php");
$mail = new PHPMailer(true); // defaults to using php "mail()"
$mail->IsHTML($isHtml);
//Mail Is SMTP
if($_SESSION['config']['mail_is_smtp'] == "true")
{
$mail->IsSMTP();
$mail->Host = $_SESSION['config']['mail_host'];
if($_SESSION['config']['mail_smtp_auth'] == "true")
{
$mail->SMTPAuth = true;
$mail->Username = $_SESSION['config']['mail_user'];
$mail->Password = $_SESSION['config']['mail_password'];
}
else
{
$mail->SMTPAuth = false;
}
}
//$body = eregi_replace("[\]",'',$message);
$mail->AddReplyTo($reply);
$mail->CharSet = "utf-8";
$mail->From = $from;
$mail->FromName = $fromName;
$mail->AddAddress($to);
if (!empty($cc))
{
$mail->AddCC($cc);
}
if (!empty($cci))
{
$mail->AddBCC($cci);
}
$mail->Subject = $subject;
$mail->Body = $message;
//$mail->MsgHTML($body);
if (count($tabDocJoin) >0)
{
foreach ($tabDocJoin as $fichier)
{
$mail->AddAttachment($fichier['PATH'],$fichier['NAME'],'base64',$fichier['TYPEMIME']);
}
}
if (!$mail->Send())
{
return $mail->ErrorInfo;
}
else
{
return true;
}
}
public function getCountLetter($service_id)
{
$this->connect();
$this->query("SELECT COUNT(*) AS NBR_LETTER FROM res_x WHERE DESTINATION = '$service_id' AND (STATUS <> 'END' AND STATUS <> 'DEL' AND STATUS <> 'ATT' AND STATUS <> 'VAL') AND IS_FOLDER = 'Y' ");
$res = $this->fetch_object();
return $res->NBR_LETTER;
}
public function getBoroughLabel($borough_id)
{
$this->connect();
$this->query("SELECT BOROUGH_LABEL FROM ".$_SESSION['tablename']['borough']." WHERE BOROUGH_ID = '".$borough_id."' ");
$res = $this->fetch_object();
return $res->BOROUGH_LABEL;
}
public function getCantonLabel($canton_id)
{
$this->connect();
$this->query("SELECT CANTON_LABEL FROM ".$_SESSION['tablename']['cantons']." WHERE CANTON_ID = '".$canton_id."' ");
$res = $this->fetch_object();
return $res->CANTON_LABEL;
}
public function getEpciLabel($epci_id)
{
$this->connect();
$this->query("SELECT EPCI_LABEL FROM ".$_SESSION['tablename']['epci']." WHERE EPCI_ID = '".$epci_id."' ");
$res = $this->fetch_object();
return $res->EPCI_LABEL;
}
public function getCommuneLabel($commune_id)
{
$this->connect();
$this->query("SELECT COMMUNE_LABEL FROM ".$_SESSION['tablename']['communes']." WHERE COMMUNE_ID = '".$commune_id."' ");
$res = $this->fetch_object();
return $res->COMMUNE_LABEL;
}
public function get_file($res_id, $table)
{
$this->connect();
$this->query("SELECT IDENTIFIER from ".$table." where RES_ID = ".$res_id);
if($this->nb_result() < 1)
{
$_SESSION['error'] .= _DOC_NOT_FOUND.'
';
$the_file = false;
}
else
{
if($this->nb_result() > 1)
{
$_SESSION['error'] .= _DOUBLED_DOC.'
';
$the_file = false;
}
else
{
$this->query("SELECT RES_ID, DOCSERVER_ID, PATH, FILENAME, FORMAT FROM ".$table." where RES_ID = ".$res_id);
//$this->show();
$line = $this->fetch_object();
$docserver_id = $line->DOCSERVER_ID;
$path = $line->PATH;
$filename = $line->FILENAME;
$format = $line->FORMAT;
$this->query("select PATH_TEMPLATE from ".$_SESSION['tablename']['docservers']." where DOCSERVER_ID = '".$docserver_id."'");
//$this->show();
$line_doc = $this->fetch_object();
$docserver = $line_doc->PATH_TEMPLATE;
if ($docserver_id == 'aidocserver')
{
$file = $docserver.$path.strtoupper($filename);
}
else
{
$file = $docserver.$path.strtolower($filename);
}
$file = str_replace("#",DIRECTORY_SEPARATOR,$file);
//echo $file;
if(file_exists($file))
{
require("load_extensions.php");
$mime_type = '';
for($i=0;$i
';
$the_file = false;
}
}
}
return $the_file;
}
/**
* Check if a doc has some mails send
*
* @param int $res_id the resource identifier
*/
public function have_mail_send($res_id){
$table_name = "res_x";
$this->query("SELECT COUNT(i.RES_ID) AS TOTAL from ".$table_name." i WHERE RELATION = ".$res_id." AND STATUS = 'MEL' ");
$nbMail = $this->fetch_object();
if($nbMail->TOTAL > 0){
return true;
}
else{
return false;
}
}
/**
* List of the mails send
*
* @param array $listarr contains the document index of the mail send
* @param int $nb_total number of document
* @param string $title title
* @param string $name page name
*/
public function list_mail_send($listarr, $nb_total, $title, $name)
{
$page_list1 = "";
$page_list2 = "";
$func = new functions();
if(isset($_REQUEST['start'])){
$start = strip_tags($_REQUEST['start']);
}
else{
$start = 0;
}
if(isset($_GET['order'])){
$orderby = strip_tags($_GET['order']);
}
else{
$orderby = 0;
}
$link = "index.php?page=".$name;
// define the defaults values
$nb_show = $_SESSION['config']['nblinetoshow'];
$nb_pages = ceil($nb_total/$nb_show);
// if they are more 1 page we do pagination with 2 forms
if($nb_pages > 1){
$next_start = 0;
$page_list1 = '
'._GO_TO_PAGE.'
';
$lastpage = 0;
for($i = 0;$i <> $nb_pages; $i++){
$page_name = $i + 1;
$the_line = $i + 1;
if($start == $next_start){
$page_list1 .= "".$the_line." ";
}
else{
$page_list1 .= "".$the_line." ";
}
$next_start = $next_start + $nb_show;
$lastpage = $next_start;
}
$lastpage = $lastpage - $nb_show;
$previous = "";
$next = "";
if($start > 0){
$start_prev = $start - $nb_show;
$previous = "< ";
}
if($start <> $lastpage){
$start_next = $start + $nb_show;
$next = " "._NEXT." >";
}
$page_list1 = $page_list1." ".$previous." ".$next."
";
}
?>
";
/*
echo "
"._CLICK_LINE_VIEW." ";
if ($_SESSION['user']['print_rights'] == true){
?>
";
}
}
?>