* @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['diff'] = array();
//$_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 ID 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;
?>
>
'));" >
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) ".$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;
?>
>
'));" >
clearsenderinfos();
}
/**
* 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['nature'] = array();
$_SESSION['quartiers'] = array();
$_SESSION['tycketName'] = '';
$_SESSION['mail'] = array();
$_SESSION['print_sep_mode'] = array();
$increment = 0;
foreach($xmlfile->CIVILITE as $CIVILITE)
{
foreach($CIVILITE-> CIV as $CIV)
{
$_SESSION['civilite'][$increment] = utf8_decode((string) $CIV);
$increment++;
}
}
$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 as $MAIL)
{
foreach($MAIL->children() as $FIELD)
{
$value = (string) $FIELD;
if( !empty($value) )
$_SESSION['mail'][$FIELD->getName()] = utf8_decode ($value);
}
}
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) );
}
}
}
}
/**
* 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 process basket documents
*
* @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 mail_process($listarr, $nb_total, $title, $name)
{
$func = new functions();
//$_SESSION['diff'] = array();
$_SESSION['error'] = '';
// show the document list in result of the search
$page_list1 = "";
$page_list2 = "";
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);
}
$_SESSION['m_admin']['services']['listmodel'] = array();
$this->query("select SEQUENCE, USER_ID from ".$_SESSION['tablename']['listmodel']." where RES_TABLE = 'res_x' and ID = '".$_SESSION['m_admin']['services']['ID']."' order by SEQUENCE asc ");
while($line = $this->fetch_object())
{
$_SESSION['m_admin']['services']['listmodel'][$line->SEQUENCE -1]['USER_ID'] = $line->USER_ID;
}
for($i=0; $i < count($_SESSION['m_admin']['services']['listmodel']); $i++)
{
$this->query("SELECT FIRSTNAME, LASTNAME, DEPARTMENT, MAIL FROM ".$_SESSION['tablename']['users']." WHERE USER_ID='".$_SESSION['m_admin']['services']['listmodel'][ $i]['USER_ID']."'");
//$this->show();
$line = $this->fetch_object();
$_SESSION['m_admin']['services']['listmodel'][$i]['FIRSTNAME'] = $line->FIRSTNAME;
$_SESSION['m_admin']['services']['listmodel'][$i]['LASTNAME'] = $line->LASTNAME;
$_SESSION['m_admin']['services']['listmodel'][$i]['DEPARTMENT'] = $line->DEPARTMENT;
$_SESSION['m_admin']['services']['listmodel'][$i]['MAIL'] = $line->MAIL;
}
}
}
if ($_SESSION['config']['collectivities'] =="true")
{
include_once($_SESSION['config']['includedir']."/addon_collectivities.php");
$entities = get_xml_value();
}
?>
wash($_REQUEST['civility'], "no", _CIVILITY.' ');
}
if(isset($_REQUEST['prenom']) && !empty($_REQUEST['prenom']))
{
$_SESSION['m_admin']['emet']['PRENOM'] = $func->wash($_REQUEST['prenom'], "no", _THE_FIRSTNAME.' ');
}
$_SESSION['m_admin']['emet']['NAME'] = $func->wash($_REQUEST['name'], "no", _THE_LASTNAME.' ');
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();
$_SESSION['m_admin']['sender']['NAME'] = $func->wash($_REQUEST['name'], "no", _THE_LASTNAME.' ');
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'] = '';
}
}
/**
* 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;
}
}
}
/**
* Form to modify a emettor
*
* @param $string $mode up or add
* @param int $id $id of the department to change
*/
public function formemet($mode,$id = "")
{
$func = new functions();
$state = true;
if(!isset($_SESSION['m_admin']['emet']))
{
$this->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;
}
}
?>
";
}
$_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']."'");
$this->query("Delete from ".$_SESSION['tablename']['listmodel']." where RES_TABLE ='res_x' and 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);
}
for($i=0; $i < count($_SESSION['m_admin']['services']['listmodel']);$i++)
{
$seq = $i+1;
$this->query("insert into ".$_SESSION['tablename']['listmodel']." ( RES_TABLE , ID, SEQUENCE, USER_ID ) VALUES ('res_x', '".$_SESSION['m_admin']['services']['ID']."', ".$seq.", '".$_SESSION['m_admin']['services']['listmodel'][ $i]['USER_ID']."')");
}
if($_REQUEST['mode'] == "up")
{
$_SESSION['error'] = _DEPARTMENT_MODIF;
if($_SESSION['history']['servicesup'] == "true")
{
require("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("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']);
}
}
$this->query("Delete from ".$_SESSION['tablename']['listmodel']." where RES_TABLE ='res_x' and ID = '".$_SESSION['m_admin']['services']['ID']."'");
for($i=0; $i < count($_SESSION['m_admin']['services']['listmodel']);$i++)
{
$seq = $i+1;
$this->query("insert into ".$_SESSION['tablename']['listmodel']." ( RES_TABLE , ID, SEQUENCE, USER_ID ) VALUES ('res_x', '".$_SESSION['m_admin']['services']['ID']."', ".$seq.", '".$_SESSION['m_admin']['services']['listmodel'][ $i]['USER_ID']."')");
}
$_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.'
';
$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."
";
}
?>
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();
?>
:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
-
connect();
$this->query("select count(*) as total from ".$table_name." ".$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 = '
'._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." order by label asc limit ".$this->the_start.",".$nb_show);
echo '
'.$title.'
';
$this->modelslistletters();
echo $page_list1;
?>
connect();
$color = "line1";
while($line = $this->fetch_object())
{
if($color == ' class="col"')
{
$color = '';
}
else
{
$color = ' class="col"';
}
$db->query("select ID, LABEL, COMMENT from ".$table_name." where ID ='".$line->ID."'");
$desc = "";
$line2 = $db->fetch_object();
$desc = $line2->LABEL;
$comment = $line2->COMMENT;
?>
>
'));" >
clearmodelinfos();
$_SESSION['services'] = array();
$this->query("select ID, SERVICE from ".$_SESSION['tablename']['services']." where ENABLED = 'Y'");
while($line = $this->fetch_object())
{
array_push($_SESSION['services'], array("ID"=>$line->ID, "LABEL" => $line->SERVICE));
}
$_SESSION['chosen_services'] = array();
}
/**
* Clear the session variables of the model administration
*
*/
private function clearmodelinfos()
{
// clear the session variable for the models
$_SESSION['m_admin']['model'] = array();
$_SESSION['m_admin']['model']['ID'] = "";
$_SESSION['m_admin']['model']['LABEL'] = "";
$_SESSION['m_admin']['model']['COMMENT'] = "";
$_SESSION['m_admin']['model']['DATE'] = "";
$_SESSION['m_admin']['model']['CONTENT'] = "";
$_SESSION['m_admin']['model']['SERVICES'] = array();
}
/**
* Form to add or modify a model
*
* @param string $mode up or add
* @param string $id identifier of the model to modify
*/
public function formmodel($mode,$id = "")
{
$func = new functions();
$state = true;
if(!isset($_SESSION['m_admin']['model']))
{
$this->clearmodelinfos();
}
if( $mode <> "add" && empty($_SESSION['error']))
{
$this->connect();
$this->query("select * from ".$_SESSION['tablename']['models']." where ID = '".$id."'");
if($this->nb_result() == 0)
{
$_SESSION['error'] = _MODEL.' '._UNKNOWN;
$state = false;
}
else
{
$_SESSION['m_admin']['model'] = array();
$line = $this->fetch_object();
$_SESSION['m_admin']['model']['ID'] = $line->ID;
$_SESSION['m_admin']['model']['LABEL'] = trim($line->LABEL);
$_SESSION['m_admin']['model']['COMMENT'] = trim($line->COMMENT);
$_SESSION['m_admin']['model']['DATE'] = $line->CREATION_DATE;
$_SESSION['m_admin']['model']['CONTENT'] = stripslashes($line->CONTENT);
//$_SESSION['m_admin']['model']['CONTENT'] = str_replace("\'", "'",$line->CONTENT);
//$_SESSION['m_admin']['model']['CONTENT'] = str_replace('\"', '"' ,$line->CONTENT);
//$_SESSION['m_admin']['model']['CONTENT'] = $line->CONTENT;
$_SESSION['m_admin']['model']['SERVICES'] = array();
$this->query("select s.ID, s.SERVICE from ".$_SESSION['tablename']['model_service']." ms, ".$_SESSION['tablename']['services']." s where ms.ID_MODEL = ".$_SESSION['m_admin']['model']['ID']." and s.ID = ms.ID_SERVICE");
//$this->show();
while($res = $this->fetch_object())
{
array_push($_SESSION['m_admin']['model']['SERVICES'] , array('ID' =>$res->ID, 'LABEL' => $res->SERVICE));
}
}
}
?>
";
}
$allowedTags='
';
$allowedTags.='';
if($_REQUEST['model_content']!='')
{
$_SESSION['m_admin']['model']['CONTENT'] = strip_tags(addslashes(trim($_REQUEST['model_content'])),$allowedTags);
}
else
{
$_SESSION['m_admin']['model']['CONTENT'] = '';
//$_SESSION['error'] .= _MODEL_EMPTY.". ";
}
$_SESSION['m_admin']['model']['LABEL'] = $func->wash($_REQUEST['model_name'], "no", _THE_WORDING);
$_SESSION['m_admin']['model']['LABEL'] = trim(stripslashes($_SESSION['m_admin']['model']['LABEL']));
$_SESSION['m_admin']['model']['COMMENT'] = "";
if(!empty($_REQUEST['model_comment']) && isset($_REQUEST['model_comment']))
{
$_SESSION['m_admin']['model']['COMMENT'] = trim(stripslashes($_REQUEST['model_comment']));
}
if($_REQUEST['mode'] == "up")
{
$_SESSION['m_admin']['model']['ID'] = $func->wash($_REQUEST['model_id'], "no", _ID);
}
//if(count($_SESSION['m_admin']['model']['SERVICES']) < 1)
//{
// $_SESSION['error'] .= _ATTACH_MODEL_TO_DEP.". ";
//}
}
/**
* Update the database with the model data
*
*/
public function upmodel()
{
$this->modelinfo();
if(!empty($_SESSION['error']))
{
if($_REQUEST['mode'] == "up")
{
if(!empty($_SESSION['m_admin']['model']['ID']))
{
header("location: index.php?page=model_up&id=".$_SESSION['m_admin']['label']['ID']);
exit;
}
else
{
header("location: index.php?page=models");
exit;
}
}
elseif($_REQUEST['mode'] == "add" )
{
header("location: index.php?page=model_add");
exit;
}
}
else
{
$this->connect();
if( $_REQUEST['mode'] <> "add")
{
$this->query("update `".$_SESSION['tablename']['models']."` set LABEL = '".addslashes($_SESSION['m_admin']['model']['LABEL'])."' , COMMENT = '".addslashes($_SESSION['m_admin']['model']['COMMENT'])."', CONTENT = '".$_SESSION['m_admin']['model']['CONTENT']."' where ID = '".$_SESSION['m_admin']['model']['ID']."'");
$this->query("Delete from ".$_SESSION['tablename']['model_service']." where ID_MODEL = '".$_SESSION['m_admin']['model']['ID']."'");
for($i=0; $i < count($_SESSION['m_admin']['model']['SERVICES']);$i++)
{
$this->query("insert into ".$_SESSION['tablename']['model_service']." ( ID_SERVICE, ID_MODEL ) VALUES ( '".$_SESSION['m_admin']['model']['SERVICES'][$i]['ID']."', ".$_SESSION['m_admin']['model']['ID'].")");
}
if($_REQUEST['mode'] == "up")
{
$_SESSION['error'] = _MODEL_MODIFICATION;
if($_SESSION['history']['modelsup'] == "true")
{
require("class_history.php");
$users = new history();
$users->add($_SESSION['tablename']['models'], $_SESSION['m_admin']['model']['ID'],"UP",_MODEL_MODIFICATION." : ".$_SESSION['m_admin']['model']['LABEL']);
}
}
$this->clearmodelinfos();
header("location: index.php?page=models");
exit;
}
else
{
$this->query("select LABEL from ".$_SESSION['tablename']['models']." where LABEL = '".addslashes($_SESSION['m_admin']['model']['LABEL'])."'");
if($this->nb_result() > 0)
{
$_SESSION['error'] = _THE_MODEL.' '.$_SESSION['m_admin']['model']['LABEL'].' '._ALREADY_EXISTS;
header("location: index.php?page=model_add");
exit;
}
else
{
require("class_history.php");
$users = new history();
if( $_REQUEST['mode'] == "add")
{
$this->query("INSERT INTO ".$_SESSION['tablename']['models']." ( LABEL, CREATION_DATE, COMMENT, CONTENT ) VALUES ( '".addslashes($_SESSION['m_admin']['model']['LABEL'])."', now(),'".addslashes($_SESSION['m_admin']['model']['COMMENT'])."', '".$_SESSION['m_admin']['model']['CONTENT']."')");
$this->query("select ID from ".$_SESSION['tablename']['models']." where LABEL = '".addslashes($_SESSION['m_admin']['model']['LABEL'])."' and COMMENT = '".addslashes($_SESSION['m_admin']['model']['COMMENT'])."' and CONTENT = '".$_SESSION['m_admin']['model']['CONTENT']."'");
$res = $this->fetch_object();
$_SESSION['m_admin']['model']['ID'] = $res->ID;
if($_SESSION['history']['modelsadd'] == "true")
{
$users->add($_SESSION['tablename']['models'], $_SESSION['m_admin']['model']['ID'],"ADD", _MODEL_ADDED." : ".$_SESSION['m_admin']['model']['LABEL']);
}
}
// $this->query("Delete from ".$_SESSION['tablename']['model_service']." where ID = ".$_SESSION['m_admin']['model']['ID']);
for($i=0; $i < count($_SESSION['m_admin']['model']['SERVICES']);$i++)
{
$this->query("insert into ".$_SESSION['tablename']['model_service']." (ID_MODEL, ID_SERVICE ) VALUES (".$_SESSION['m_admin']['model']['ID'].", '".$_SESSION['m_admin']['model']['SERVICES'][$i]['ID']."' )");
}
$_SESSION['error'] = _MODEL_ADDED;
}
$_SESSION['error'] = "";
}
if ($_REQUEST['mode'] == "add")
{
$url = "index.php?page=models";
}
$this->clearmodelinfos();
header("location: ".$url);
exit;
}
}
/**
* replace the defined fields in the instance of the model
*
* @param string $content model content
*/
public function fields_replace($content)
{
$content = str_replace("[REF_COURRIER]", $_SESSION['courrier']['identifier'], $content);
$content = str_replace("[NO_AFFAIRE]", $_SESSION['courrier']['res_id'], $content);
$content = str_replace("[CIV_EMETTEUR]", $_SESSION['courrier']['civ'], $content);
$content = str_replace("[NOM_EMETTEUR]", $_SESSION['courrier']['author'], $content);
$content = str_replace("[PRENOM_EMETTEUR]", $_SESSION['courrier']['prenom'], $content);
$content = str_replace("[SOCIETE_EMETTEUR]", $_SESSION['courrier']['societe'], $content);
$content = str_replace("[OBJET]", $_SESSION['courrier']['description'], $content);
$content = str_replace("[TYPE]", $_SESSION['courrier']['type_id'], $content);
$content = str_replace("[DATE_LIM]", $_SESSION['courrier']['date_limite'], $content);
$content = str_replace("[DATE_ARRIVEE]", $_SESSION['courrier']['date_arrivee'], $content);
$content = str_replace("[NATURE]", $_SESSION['courrier']['nature'], $content);
$this->query("select SERVICE from ".$_SESSION['tablename']['services']." where ID = '".$_SESSION['courrier']['service']."'");
$res = $this->fetch_object();
$content = str_replace("[SERVICE]", $res->SERVICE, $content);
$content = str_replace("[NEW_EMETTEUR]", $_SESSION['user']['FirstName'].' '.$_SESSION['user']['LastName'], $content);
$content = str_replace("[PHONE_EMETTEUR]", $_SESSION['user']['Phone'], $content);
$content = str_replace("[MAIL_EMETTEUR]", $_SESSION['user']['Mail'], $content);
$content = str_replace("[DEP_EMETTEUR]", $_SESSION['user']['department'], $content);
$content = str_replace("[REP_COURRIER_SIMPLE]", $_SESSION['courrier']['rep_courrier_simple'], $content);
$content = str_replace("[REP_DIRECT]", $_SESSION['courrier']['rep_direct'], $content);
$content = str_replace("[REP_MAIL]", $_SESSION['courrier']['rep_mail'], $content);
$content = str_replace("[REP_AR]", $_SESSION['courrier']['rep_AR'], $content);
$content = str_replace("[REP_FAX]", $_SESSION['courrier']['rep_fax'], $content);
$content = str_replace("[REP_AUTRE]", $_SESSION['courrier']['rep_autre'], $content);
$content = str_replace("[NOTES_TRAIT]", $_SESSION['courrier']['notes'], $content);
$content = str_replace("[QUALITE]", $_SESSION['courrier']['qualite'], $content);
$content = str_replace("[NUM_RUE]", $_SESSION['courrier']['num_rue'], $content);
$content = str_replace("[RUE]", $_SESSION['courrier']['rue'], $content);
$content = str_replace("[VILLE]", $_SESSION['courrier']['ville'], $content);
$content = str_replace("[CODE_POSTAL]", $_SESSION['courrier']['code'], $content);
$content = str_replace("[DATE_TODAY]", date("d-m-Y"), $content);
return $content;
}
/**
* delete a model in the database
*
* @param string $id model identifier
*/
public function delmodel($id)
{
if(!empty($_SESSION['error']))
{
header("location: index.php?page=models");
exit;
}
else
{
$this->connect();
$this->query("select ID, LABEL from ".$_SESSION['tablename']['models']." where ID = ".$id);
if($this->nb_result() == 0)
{
$_SESSION['error'] = _MODEL.' '._UNKNOWN;
header("location: index.php?page=models");
exit;
}
else
{
$res = $this->fetch_object();
$label = $res->LABEL;
$this->query("delete from ".$_SESSION['tablename']['models']." where ID = ".$id);
$this->query("delete from ".$_SESSION['tablename']['model_service']." where ID_MODEL = ".$id);
if($_SESSION['history']['modelsdel'])
{
require("class_history.php");
$users = new history();
$users->add($_SESSION['tablename']['models'], $id,"DEL",_MODEL_DELETION." : ".$label);
}
$_SESSION['error'] = _DELETED_MODEL;
header("location: index.php?page=models");
exit;
}
}
}
/**
* delete a model in the database
*
* @param string $id model identifier
*/
public function delemet($id)
{
if(!empty($_SESSION['error']))
{
header("location: index.php?page=emet");
exit;
}
else
{
$this->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 = ''
)
{
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 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;
}
}
?>