* @author Loïc Vinet * */ /** * Class Contacts : Contains all the specific functions to manage Contacts * * @author Claire Figueras * @license GPL * @version 2.0 */ class contacts_v2 extends dbquery { /** * Return the contacts data in sessions vars * * @param string $mode add or up */ public function contactinfo($mode) { // return the user information in sessions vars $func = new functions(); $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = $_REQUEST['is_corporate']; if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') { $_SESSION['m_admin']['contact']['SOCIETY'] = $func->wash( $_REQUEST['society'], 'no', _STRUCTURE_ORGANISM . ' ', 'yes', 0, 255 ); $_SESSION['m_admin']['contact']['LASTNAME'] = ''; $_SESSION['m_admin']['contact']['FIRSTNAME'] = ''; $_SESSION['m_admin']['contact']['FUNCTION'] = ''; $_SESSION['m_admin']['contact']['TITLE'] = ''; } else { $_SESSION['m_admin']['contact']['LASTNAME'] = $func->wash( $_REQUEST['lastname'], 'no', _LASTNAME, 'yes', 0, 255 ); $_SESSION['m_admin']['contact']['FIRSTNAME'] = $func->wash( $_REQUEST['firstname'], 'no', _FIRSTNAME, 'yes', 0, 255 ); if ($_REQUEST['society'] <> '') { $_SESSION['m_admin']['contact']['SOCIETY'] = $func->wash( $_REQUEST['society'], 'no', _STRUCTURE_ORGANISM . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['contact']['SOCIETY'] = ''; } if ($_REQUEST['function'] <> '') { $_SESSION['m_admin']['contact']['FUNCTION'] = $func->wash( $_REQUEST['function'], 'no', _FUNCTION . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['contact']['FUNCTION'] = ''; } if ($_REQUEST['title'] <> '') { $_SESSION['m_admin']['contact']['TITLE'] = $func->wash( $_REQUEST['title'], 'no', _TITLE2 . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['contact']['TITLE'] = ''; } } if ($_REQUEST['society_short'] <> '') { $_SESSION['m_admin']['contact']['SOCIETY_SHORT'] = $func->wash( $_REQUEST['society_short'], 'no', _SOCIETY_SHORT . ' ', 'yes', 0, 32 ); } else { $_SESSION['m_admin']['contact']['SOCIETY_SHORT'] = ''; } $_SESSION['m_admin']['contact']['CONTACT_TYPE'] = $func->wash( $_REQUEST['contact_type'], 'no', _CONTACT_TYPE . ' ', 'yes', 0, 255 ); if ($_REQUEST['comp_data'] <> '') { $_SESSION['m_admin']['contact']['OTHER_DATA'] = $func->wash( $_REQUEST['comp_data'], 'no', _COMP_DATA . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['contact']['OTHER_DATA'] = ''; } if (isset($_REQUEST['owner']) && $_REQUEST['owner'] <> '') { if (preg_match('/\((.|\s|\d|\h|\w)+\)$/i', $_REQUEST['owner']) == 0) { $_SESSION['error'] = _CREATE_BY . ' ' . _WRONG_FORMAT . '.
' . _USE_AUTOCOMPLETION; } else { $_SESSION['m_admin']['contact']['OWNER'] = str_replace( ')', '', substr($_REQUEST['owner'], strrpos($_REQUEST['owner'],'(')+1) ); $_SESSION['m_admin']['contact']['OWNER'] = $func->wash( $_SESSION['m_admin']['contact']['OWNER'], 'no', _CREATE_BY . ' ', 'yes', 0, 32 ); } } else { $_SESSION['m_admin']['contact']['OWNER'] = ''; } $_SESSION['m_admin']['contact']['order'] = $_REQUEST['order']; $_SESSION['m_admin']['contact']['order_field'] = $_REQUEST['order_field']; $_SESSION['m_admin']['contact']['what'] = $_REQUEST['what']; $_SESSION['m_admin']['contact']['start'] = $_REQUEST['start']; } public function is_exists($mode, $mycontact){ $query = $this->query_contact_exists($mode); $this->query($query); if($this->nb_result() > 0){ if($mode <> 'up'){ $_SESSION['error'] = _THE_CONTACT.' '._ALREADY_EXISTS; } if($mycontact == 'iframe'){ $path_contacts_confirm = $_SESSION['config']['businessappurl'] . 'index.php?display=false&page=contacts_v2_confirm&popup'; } else { $path_contacts_confirm = $_SESSION['config']['businessappurl'] . 'index.php?page=contacts_v2_confirm'; } header( 'location: ' . $path_contacts_confirm.'&mode='.$mode.'&mycontact='.$mycontact ); exit; } } public function query_contact_exists($mode){ $this->connect(); $query = ''; if($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'N'){ $query = "SELECT contact_id, contact_type, society, contact_firstname, contact_lastname FROM view_contacts WHERE lower(contact_firstname) = lower('".$this->protect_string_db($_SESSION['m_admin']['contact']['FIRSTNAME'])."') and lower(contact_lastname) = lower('".$this->protect_string_db($_SESSION['m_admin']['contact']['LASTNAME'])."')"; } else if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y'){ $query = "SELECT contact_id, contact_type, society, contact_firstname, contact_lastname FROM view_contacts WHERE lower(society) = lower('".$this->protect_string_db($_SESSION['m_admin']['contact']['SOCIETY'])."')"; } if ($mode == 'up'){ $query .= " and contact_id <> " . $_SESSION['m_admin']['contact']['ID']; } return $query; } /** * Add ou modify contact in the database * * @param string $mode up or add */ public function addupcontact($mode, $admin = true, $confirm = 'N', $mycontact = 'N') { // add ou modify users in the database if($confirm == 'N'){ $this->contactinfo($mode); } if (empty($_SESSION['error']) && $confirm == 'N') { $this->is_exists($mode, $mycontact); } $order = $_SESSION['m_admin']['contact']['order']; $order_field = $_SESSION['m_admin']['contact']['order_field']; $what = $_SESSION['m_admin']['contact']['what']; $start = $_SESSION['m_admin']['contact']['start']; if ($mode == 'add') { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_add&order=' . $order . '&order_field=' . $order_field . '&start=' . $start . '&what=' . $what; } else { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?page=contacts_v2&order=' . $order . '&order_field=' . $order_field . '&start=' . $start . '&what=' . $what; } $path_contacts_add_errors = $_SESSION['config']['businessappurl'] . 'index.php?page=contacts_v2_add'; $path_contacts_up_errors = $_SESSION['config']['businessappurl'] . 'index.php?page=contacts_v2_up'; if (! $admin) { if ($mode == 'add') { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_add&mycontact=Y&order=' . $order . '&order_field=' . $order_field . '&start=' . $start . '&what=' . $what; } else { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?page=my_contacts&dir=my_contacts&load&order=' . $order . '&order_field=' . $order_field . '&start=' . $start . '&what=' . $what; } $path_contacts_add_errors = $_SESSION['config']['businessappurl'] . 'index.php?page=my_contact_add&dir=' . 'my_contacts&load'; $path_contacts_up_errors = $_SESSION['config']['businessappurl'] . 'index.php?page=my_contact_up&dir=' . 'my_contacts&load'; } if ($mycontact == 'iframe') { if ($mode == 'add') { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=create_address_iframe'; $path_contacts_add_errors = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=create_contact_iframe'; } else if ($mode == 'up') { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id'].'&created=Y'; $path_contacts_up_errors = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; } } if (! empty($_SESSION['error'])) { if ($mode == 'up') { if (! empty($_SESSION['m_admin']['contact']['ID'])) { header( 'location: ' . $path_contacts_up_errors . '&id=' . $_SESSION['m_admin']['contact']['ID'] ); exit; } else { header('location: ' . $path_contacts); exit; } } if ($mode == 'add') { header('location: ' . $path_contacts_add_errors); exit; } } else { $this->connect(); if ($mode == 'add') { if($_SESSION['user']['UserId'] == 'superadmin'){ $entity_id = 'SUPERADMIN'; } else { $entity_id = $_SESSION['user']['primaryentity']['id']; } $query = 'INSERT INTO ' . $_SESSION['tablename']['contacts_v2'] . ' ( contact_type, lastname , firstname , society , society_short, function , ' . 'other_data,' . " title, is_corporate_person, user_id, entity_id, creation_date) VALUES ( " . $_SESSION['m_admin']['contact']['CONTACT_TYPE'] . ", '" . $this->protect_string_db( $_SESSION['m_admin']['contact']['LASTNAME'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['contact']['FIRSTNAME'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['contact']['SOCIETY'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['contact']['SOCIETY_SHORT'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['contact']['FUNCTION'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['contact']['OTHER_DATA'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['contact']['TITLE'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] ) . "','" . $this->protect_string_db( $_SESSION['user']['UserId'] ) . "','" . $this->protect_string_db( $entity_id ) . "', current_timestamp)"; $this->query($query); if($_SESSION['history']['contactadd']) { $this->query("select contact_id, creation_date from ".$_SESSION['tablename']['contacts_v2'] ." where lastname = '".$this->protect_string_db($_SESSION['m_admin']['contact']['LASTNAME']) ."' and firstname = '".$this->protect_string_db($_SESSION['m_admin']['contact']['FIRSTNAME']) ."' and society = '".$this->protect_string_db($_SESSION['m_admin']['contact']['SOCIETY']) ."' and function = '".$this->protect_string_db($_SESSION['m_admin']['contact']['FUNCTION']) ."' and is_corporate_person = '".$this->protect_string_db($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON']) ."' order by creation_date desc"); $res = $this->fetch_object(); $id = $res->contact_id; if($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') { $msg = _CONTACT_ADDED.' : '.$this->protect_string_db($_SESSION['m_admin']['contact']['SOCIETY']); } else { $msg = _CONTACT_ADDED.' : '.$this->protect_string_db($_SESSION['m_admin']['contact']['LASTNAME'].' '.$_SESSION['m_admin']['contact']['FIRSTNAME']); } require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'); $hist = new history(); $hist->add($_SESSION['tablename']['contacts_v2'], $id,"ADD",'contacts_v2_add',$msg, $_SESSION['config']['databasetype']); } // if($mycontact = 'iframe'){ $this->query("select contact_id, creation_date from ".$_SESSION['tablename']['contacts_v2'] ." where lastname = '".$this->protect_string_db($_SESSION['m_admin']['contact']['LASTNAME']) ."' and firstname = '".$this->protect_string_db($_SESSION['m_admin']['contact']['FIRSTNAME']) ."' and society = '".$this->protect_string_db($_SESSION['m_admin']['contact']['SOCIETY']) ."' and function = '".$this->protect_string_db($_SESSION['m_admin']['contact']['FUNCTION']) ."' and is_corporate_person = '".$this->protect_string_db($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON']) ."' order by creation_date desc"); $res = $this->fetch_object(); $id = $res->contact_id; $_SESSION['contact']['current_contact_id'] = $id; // } else { // $this->clearcontactinfos(); // } $_SESSION['info'] = _CONTACT_ADDED; header("location: ".$path_contacts); exit; } elseif($mode == "up") { $query = "update ".$_SESSION['tablename']['contacts_v2']." set update_date = current_timestamp, contact_type = ".$_SESSION['m_admin']['contact']['CONTACT_TYPE'].", lastname = '".$this->protect_string_db($_SESSION['m_admin']['contact']['LASTNAME'])."', firstname = '".$this->protect_string_db($_SESSION['m_admin']['contact']['FIRSTNAME'])."',society = '".$this->protect_string_db($_SESSION['m_admin']['contact']['SOCIETY'])."',society_short = '".$this->protect_string_db($_SESSION['m_admin']['contact']['SOCIETY_SHORT'])."',function = '".$this->protect_string_db($_SESSION['m_admin']['contact']['FUNCTION'])."', other_data = '".$this->protect_string_db($_SESSION['m_admin']['contact']['OTHER_DATA'])."', title = '".$this->protect_string_db($_SESSION['m_admin']['contact']['TITLE'])."', is_corporate_person = '".$this->protect_string_db($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'])."'"; // if($admin) // { // $query .= ", user_id = '".$this->protect_string_db($_SESSION['m_admin']['contact']['OWNER'])."'"; // } $query .=" where contact_id = '".$_SESSION['m_admin']['contact']['ID']."'"; if(!$admin) { //$query .= " and user_id = '".$this->protect_string_db($_SESSION['user']['UserId'])."'"; } $this->query($query); if($_SESSION['history']['contactup']) { if($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') { $msg = _CONTACT_MODIFIED.' : '.$this->protect_string_db($_SESSION['m_admin']['contact']['SOCIETY']); } else { $msg = _CONTACT_MODIFIED.' : '.$this->protect_string_db($_SESSION['m_admin']['contact']['LASTNAME'].' '.$_SESSION['m_admin']['contact']['FIRSTNAME']); } require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'); $hist = new history(); $hist->add($_SESSION['tablename']['contacts_v2'], $_SESSION['m_admin']['contact']['ID'],"UP",'contacts_v2_up',$msg, $_SESSION['config']['databasetype']); } $this->clearcontactinfos(); $_SESSION['info'] = _CONTACT_MODIFIED; if (isset($_SESSION['fromContactTree']) && $_SESSION['fromContactTree'] == "yes") { unset($_SESSION['fromContactTree']); header("location: ".$_SESSION['config']['businessappurl']. 'index.php?page=view_tree_contacts'); exit(); } else { header("location: ".$path_contacts); exit(); } } } } /** * Form to modify a contact v2 * * @param $string $mode up or add * @param int $id $id of the contact to change */ public function formcontact($mode,$id = "", $admin = true, $iframe = false) { if (preg_match("/MSIE 6.0/", $_SERVER["HTTP_USER_AGENT"])) { $browser_ie = true; $display_value = 'block'; } elseif(preg_match('/msie/i', $_SERVER["HTTP_USER_AGENT"]) && !preg_match('/opera/i', $_SERVER["HTTP_USER_AGENT"]) ) { $browser_ie = true; $display_value = 'block'; } else { $browser_ie = false; $display_value = 'table-row'; } $func = new functions(); $state = true; if(!isset($_SESSION['m_admin']['contact'])) { $this->clearcontactinfos(); } if( $mode <> "add") { $this->connect(); $query = "select * from ".$_SESSION['tablename']['contacts_v2']." where contact_id = ".$id; if(!$admin) { //$query .= " and user_id = '".$this->protect_string_db($_SESSION['user']['UserId'])."'"; } $this->query($query); if($this->nb_result() == 0) { $_SESSION['error'] = _THE_CONTACT.' '._ALREADY_EXISTS; $state = false; } else { $_SESSION['m_admin']['contact'] = array(); $line = $this->fetch_object(); $_SESSION['m_admin']['contact']['ID'] = $line->contact_id; $_SESSION['m_admin']['contact']['TITLE'] = $this->show_string($line->title); $_SESSION['m_admin']['contact']['LASTNAME'] = $this->show_string($line->lastname); $_SESSION['m_admin']['contact']['FIRSTNAME'] = $this->show_string($line->firstname); $_SESSION['m_admin']['contact']['SOCIETY'] = $this->show_string($line->society); $_SESSION['m_admin']['contact']['SOCIETY_SHORT'] = $this->show_string($line->society_short); $_SESSION['m_admin']['contact']['FUNCTION'] = $this->show_string($line->function); $_SESSION['m_admin']['contact']['OTHER_DATA'] = $this->show_string($line->other_data); $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = $this->show_string($line->is_corporate_person); $_SESSION['m_admin']['contact']['CONTACT_TYPE'] = $line->contact_type; $_SESSION['m_admin']['contact']['OWNER'] = $line->user_id; if($admin && !empty($_SESSION['m_admin']['contact']['OWNER'])) { $this->query("select lastname, firstname from ".$_SESSION['tablename']['users']." where user_id = '".$_SESSION['m_admin']['contact']['OWNER']."'"); $res = $this->fetch_object(); $_SESSION['m_admin']['contact']['OWNER'] = $res->lastname.', '.$res->firstname.' ('.$_SESSION['m_admin']['contact']['OWNER'].')'; } } } else if($mode == 'add' && !isset($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'])) { $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = 'Y'; } require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_business_app_tools.php"); $business = new business_app_tools(); $tmp = $business->get_titles(); $titles = $tmp['titles']; $contact_types = array(); $this->connect(); $this->query("SELECT id, label FROM ".$_SESSION['tablename']['contact_types']." ORDER BY label"); while($res = $this->fetch_object()){ $contact_types[$res->id] = $this->show_string($res->label); } ?>




"._THE_CONTACT." "._UNKOWN."



"; } else { $action = $_SESSION['config']['businessappurl']."index.php?display=true&page=contacts_v2_up_db"; if(!$admin) { $action = $_SESSION['config']['businessappurl']."index.php?display=true&dir=my_contacts&page=my_contact_up_db"; if($iframe){ $action = $_SESSION['config']['businessappurl']."index.php?display=true&dir=my_contacts&page=my_contact_up_db&mycontact=iframe"; } } ?>
"") { ?>
:   checked="checked"/ onclick="javascript:show_admin_contacts( true, '');"> checked="checked" onclick="javascript:show_admin_contacts( false, '');"/>  
 
 
  *
 
  *
:  
   
  *
  *
   
 :    

()

onclick="self.close();" onclick="new Effect.BlindUp(parent.document.getElementById('create_contact_div'));new Effect.BlindUp(parent.document.getElementById('info_contact_div'));return false;" />

connect(); $this->clearcontactinfos(); ?>




*
connect(); $this->query('select * from '.$_SESSION['tablename']['contacts']); while($res = $this->fetch_object()) { if($res->lastname <> '') array_push($contacts, "'".$res->lastname.", ".$res->firstname."[".$res->contact_id."]'"); else array_push($contacts, "'".$res->society."[".$res->contact_id."]'"); } return $contacts; } /** * delete a contact in the database * * @param string $id contact identifier */ public function delcontact($id, $admin = true) { $element_found = false; $nb_docs = 0; $tables = array(); $_SESSION['m_admin']['contact'] = array(); $this->connect(); $order = $_REQUEST['order']; $order_field = $_REQUEST['order_field']; $start = $_REQUEST['start']; $what = $_REQUEST['what']; $path_contacts = $_SESSION['config']['businessappurl']."index.php?page=contacts_v2&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what; if(!$admin) { $path_contacts = $_SESSION['config']['businessappurl']."index.php?page=my_contacts&dir=my_contacts&load&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what; } if(!empty($id)) { $this->query("select res_id from ".$_SESSION['collections'][0]['view'] . " where exp_contact_id = '".$this->protect_string_db($id) . "' or dest_contact_id = '".$this->protect_string_db($id) . "'"); // $this->show(); if($this->nb_result() > 0)$nb_docs = $nb_docs + $this->nb_result(); $this->query("select contact_id from contacts_res where contact_id = '". $this->protect_string_db($id)."'"); if($this->nb_result() > 0)$nb_docs = $nb_docs + $this->nb_result(); /* $this->query("select res_id from mlb_coll_ext where address_id in (select distinct id from ".$_SESSION['tablename']['contact_addresses'] . " where contact_id = '".$this->protect_string_db($id)."')" ); // $this->show(); if($this->nb_result() > 0)$nb_docs_address = $nb_docs_address + $this->nb_result();*/ if ($nb_docs == 0) { $this->connect(); $query = "select contact_id from ".$_SESSION['tablename']['contacts_v2']." where contact_id = ".$id; if(!$admin) { $query .= " and user_id = '".$this->protect_string_db($_SESSION['user']['UserId'])."'"; } $this->query($query); if($this->nb_result() == 0) { $_SESSION['error'] = _CONTACT.' '._UNKNOWN; } else { $res = $this->fetch_object(); $this->query("delete from " . $_SESSION['tablename']['contacts_v2'] . " where contact_id = " . $id); $this->query("delete from " . $_SESSION['tablename']['contact_addresses'] . " where contact_id = " . $id); if($_SESSION['history']['contactdel']) { require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'); $hist = new history(); $hist->add($_SESSION['tablename']['contacts_v2'], $id,"DEL","contactdel",_CONTACT_DELETED.' : '.$id, $_SESSION['config']['databasetype']); $hist->add($_SESSION['tablename']['contact_addresses'], $id,"DEL","contact_addresses_del", _ADDRESS_DEL." ".strtolower(_NUM).$id."", $_SESSION['config']['databasetype']); } $_SESSION['info'] = _CONTACT_DELETED; } } else { ?>


".$label."";?>

0) { echo "
- ".$nb_docs." "._DOC_SENDED_BY_CONTACT; ?>





?\n\r\n\r'));"/>

connect(); //For this 3 cases, we need to create a different string if ($category_id == 'incoming') { $prefix = ""._TO_CONTACT_C.""; $this->query("SELECT exp_user_id, exp_contact_id from ".$view." WHERE res_id = ".$res_id); $compar = $this->fetch_object(); if ($compar->exp_user_id <> '') { $column_title = "user_id"; $column_value = $compar->exp_user_id; $column_join = $_SESSION['tablename']['users']; } elseif ($compar->exp_contact_id <> '') { $column_title = "contact_id"; $column_value = $compar->exp_contact_id; $column_join = $_SESSION['tablename']['contacts']; } else { $stopthis = true; } } elseif ($category_id == 'outgoing' || $category_id == 'internal') { $prefix = ""._FOR_CONTACT_C.""; $this->query("SELECT dest_user_id, dest_contact_id from ".$view." WHERE res_id = ".$res_id); $compar = $this->fetch_object(); if ($compar->dest_user_id <> '') { $column_title = "user_id"; $column_value = $compar->dest_user_id; $column_join = $_SESSION['tablename']['users']; } elseif ($compar->dest_contact_id <> '') { $column_title = "contact_id"; $column_value = $compar->dest_contact_id; $column_join = $_SESSION['tablename']['contacts']; } else { $stopthis = true; } } else { $stopthis = true; $prefix = ''; } if($stopthis == true) { return false; } //If we need to find a contact, get the society first if ($column_join == $_SESSION['tablename']['contacts']) $fields = 'c.firstname, c.lastname, c.society '; elseif ($column_join == $_SESSION['tablename']['users']) $fields = 'c.firstname, c.lastname'; else $fields = ''; //Launching request to restore full contact string $this->query("SELECT ".$fields." from ".$column_join." c where ".$column_title." = '".$column_value."'"); $final = $this->fetch_object(); $firstname = $final->firstname; $lastname = $final->lastname; if ($final->society <> '') { if ($firstname =='' && $lastname == '') { $society = $final->society; } else { $society = " (".$final->society.") "; } } else $society = ""; $the_contact =$prefix." ".$firstname." ".$lastname." ".$society; return $the_contact; } function get_contact_information_from_view($category_id, $contact_lastname="", $contact_firstname="", $contact_society="", $user_lastname="", $user_firstname="") { if ($category_id == 'incoming') { $prefix = ""._TO_CONTACT_C.""; } elseif ($category_id == 'outgoing' || $category_id == 'internal') { $prefix = ""._FOR_CONTACT_C.""; } else { $prefix = ''; } if($contact_lastname <> "") { $lastname = $contact_lastname; $firstname = $contact_firstname; } else { $lastname = $user_lastname; $firstname = $user_firstname; } if($contact_society <> "") { if ($firstname =='' && $lastname == '') { $society = $contact_society; } else { $society = " (".$contact_society.") "; } } else $society = ""; $the_contact =$prefix." ".$firstname." ".$lastname." ".$society; return $the_contact; } /** * Form to modify or add an address v2 * * @param $string $mode up or add * @param int $id $id of the contact to change */ public function formaddress($mode,$id = "", $admin = true, $iframe = "") { if (preg_match("/MSIE 6.0/", $_SERVER["HTTP_USER_AGENT"])) { $browser_ie = true; $display_value = 'block'; } elseif(preg_match('/msie/i', $_SERVER["HTTP_USER_AGENT"]) && !preg_match('/opera/i', $_SERVER["HTTP_USER_AGENT"]) ) { $browser_ie = true; $display_value = 'block'; } else { $browser_ie = false; $display_value = 'table-row'; } $func = new functions(); $state = true; if(!isset($_SESSION['m_admin']['address']) && !isset($_SESSION['m_admin']['contact'])) { $this->clearcontactinfos(); } if( $mode <> "add") { $this->connect(); $query = "select * from ".$_SESSION['tablename']['contact_addresses']." where id = ".$id; $core_tools = new core_tools(); if(!$admin && !$core_tools->test_service('update_contacts', 'apps', false)) { $query .= " and user_id = '".$this->protect_string_db($_SESSION['user']['UserId'])."'"; } $this->query($query); if($this->nb_result() == 0) { $_SESSION['error'] = _THE_ADDRESS.' '._ALREADY_EXISTS; $state = false; } else { if (!isset($_SESSION['address_up_error'])) { $_SESSION['m_admin']['address'] = array(); $line = $this->fetch_object(); $_SESSION['m_admin']['address']['ID'] = $line->id; $_SESSION['m_admin']['address']['CONTACT_ID'] = $line->contact_id; $_SESSION['m_admin']['address']['TITLE'] = $this->show_string($line->title); $_SESSION['m_admin']['address']['LASTNAME'] = $this->show_string($line->lastname); $_SESSION['m_admin']['address']['FIRSTNAME'] = $this->show_string($line->firstname); $_SESSION['m_admin']['address']['FUNCTION'] = $this->show_string($line->function); $_SESSION['m_admin']['address']['OTHER_DATA'] = $this->show_string($line->other_data); $_SESSION['m_admin']['address']['OWNER'] = $line->user_id; $_SESSION['m_admin']['address']['DEPARTEMENT'] = $this->show_string($line->departement); $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $line->contact_purpose_id; $_SESSION['m_admin']['address']['OCCUPANCY'] = $this->show_string($line->occupancy); $_SESSION['m_admin']['address']['ADD_NUM'] = $this->show_string($line->address_num); $_SESSION['m_admin']['address']['ADD_STREET'] = $this->show_string($line->address_street); $_SESSION['m_admin']['address']['ADD_COMP'] = $this->show_string($line->address_complement); $_SESSION['m_admin']['address']['ADD_TOWN'] = $this->show_string($line->address_town); $_SESSION['m_admin']['address']['ADD_CP'] = $this->show_string($line->address_postal_code); $_SESSION['m_admin']['address']['ADD_COUNTRY'] = $this->show_string($line->address_country); $_SESSION['m_admin']['address']['PHONE'] = $this->show_string($line->phone); $_SESSION['m_admin']['address']['MAIL'] = $this->show_string($line->email); $_SESSION['m_admin']['address']['WEBSITE'] = $this->show_string($line->website); $_SESSION['m_admin']['address']['IS_PRIVATE'] = $this->show_string($line->is_private); $_SESSION['m_admin']['address']['SALUTATION_HEADER'] = $this->show_string($line->salutation_header); $_SESSION['m_admin']['address']['SALUTATION_FOOTER'] = $this->show_string($line->salutation_footer); } else { unset($_SESSION['address_up_error']); } if($admin && !empty($_SESSION['m_admin']['address']['OWNER'])) { $this->query("select lastname, firstname from ".$_SESSION['tablename']['users']." where user_id = '".$_SESSION['m_admin']['address']['OWNER']."'"); $res = $this->fetch_object(); $_SESSION['m_admin']['address']['OWNER'] = $res->lastname.', '.$res->firstname.' ('.$_SESSION['m_admin']['address']['OWNER'].')'; } } } else if($mode == 'add' && !isset($_SESSION['m_admin']['address']['IS_PRIVATE'])) { $_SESSION['m_admin']['address']['IS_PRIVATE'] = 'N'; } require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_business_app_tools.php"); $business = new business_app_tools(); $tmp = $business->get_titles(); $titles = $tmp['titles']; $contact_purposes = array(); $this->connect(); $this->query("SELECT id, label FROM ".$_SESSION['tablename']['contact_purposes']); while($res = $this->fetch_object()){ $contact_purposes[$res->id] = $this->show_string($res->label); } ?>




"._THE_ADDRESS." "._UNKOWN."



"; } else { $this->get_contact_form(); $action = $_SESSION['config']['businessappurl']."index.php?display=true&page=contact_addresses_up_db"; if(!$admin) { $action = $_SESSION['config']['businessappurl']."index.php?display=true&page=contact_addresses_up_db&mycontact=Y"; } if($iframe == "iframe"){ $action = $_SESSION['config']['businessappurl']."index.php?display=false&page=contact_addresses_up_db&mycontact=iframe"; } else if($iframe == "iframe_add_up") { $action = $_SESSION['config']['businessappurl']."index.php?display=false&page=contact_addresses_up_db&mycontact=iframe_add_up"; } else if($iframe == "fromContactIframe"){ $action = $_SESSION['config']['businessappurl']."index.php?display=false&page=contact_addresses_up_db&mycontact=fromContactIframe"; } if (isset($_SESSION['contact_address']['fromContactAddressesList']) && $_SESSION['contact_address']['fromContactAddressesList'] <> "") { $action = $_SESSION['config']['businessappurl'].'index.php?display=true&page=contact_addresses_up_db&fromContactAddressesList'; } ?>
  '') { echo 'value="'.$this->get_label_contact($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'],$_SESSION['tablename']['contact_purposes']).'"'; } else { echo 'value="'._MAIN_ADDRESS.'"'; } ?> />
'') { echo 'value="'.$_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'].'"'; } ?> />
*
  *
   
   
   
   
:   *
  *
  *
  *
 :   *
  *
  *
  *
  *
 :    
 :    
 :   checked="checked" /> 'Y'){?> checked="checked" />  
:   *
:   *

"") { $cancel_target = $_SESSION['config']['businessappurl'].'index.php?page=contact_addresses_list'; $_SESSION['contact_address']['fromContactAddressesList'] = ""; } if($iframe == 'iframe_add_up'){ $see_all_addresses = $_SESSION['config']['businessappurl'].'index.php?display=false&dir=my_contacts&page=info_contact_iframe&seeAllAddresses&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; ?>

addressinfo($mode); $order = $_SESSION['m_admin']['address']['order']; $order_field = $_SESSION['m_admin']['address']['order_field']; $what = $_SESSION['m_admin']['address']['what']; $start = $_SESSION['m_admin']['address']['start']; $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?page=contacts_v2_up&order=' . $order . '&order_field=' . $order_field . '&start=' . $start . '&what=' . $what; $path_contacts_add_errors = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_add'; $path_contacts_up_errors = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_up'; if (! $admin) { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?dir=my_contacts&page=my_contact_up&load&order=' . $order . '&order_field=' . $order_field . '&start=' . $start . '&what=' . $what; $path_contacts_add_errors = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_add&mycontact=Y'; $path_contacts_up_errors = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_up&mycontact=Y'; } if ($iframe) { if($mode == 'add') { if($iframe == 1){ $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=create_contact_iframe&created=Y'; $path_contacts_add_errors = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=create_address_iframe'; } else if($iframe == 2) { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; $path_contacts_add_errors = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=create_address_iframe&iframe=iframe_up_add'; } else if($iframe == 3) { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&created=add&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; $path_contacts_add_errors = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=create_address_iframe&iframe=iframe_up_add'; } } else if($mode == 'up') { if ($iframe == 3) { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&created=Y&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; } else { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&created=Y&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; } $path_contacts_up_errors = $_SESSION['config']['businessappurl'] . 'index.php?display=false&dir=my_contacts&page=update_address_iframe'; } } if (isset($_SESSION['contact_address']['fromContactAddressesList']) && $_SESSION['contact_address']['fromContactAddressesList'] <> "") { $path_contacts = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_list'; $path_contacts_up_errors = $_SESSION['config']['businessappurl'] . 'index.php?page=contact_addresses_up&fromContactAddressesList'; $_SESSION['contact_address']['fromContactAddressesList'] = ""; } if (! empty($_SESSION['error'])) { if ($mode == 'up') { if (! empty($_SESSION['m_admin']['address']['ID'])) { $_SESSION['address_up_error'] = "true"; header( 'location: ' . $path_contacts_up_errors . '&id=' . $_SESSION['m_admin']['address']['ID'] ); exit; } else { header('location: ' . $path_contacts); exit; } } if ($mode == 'add') { header('location: ' . $path_contacts_add_errors); exit; } } else { $this->connect(); if ($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] == "") { $this->query("SELECT id FROM contact_purposes WHERE label = '".$this->protect_string_db($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])."'"); if ($this->nb_result() == 0) { $this->query("INSERT INTO contact_purposes (label) VALUES ('".$this->protect_string_db($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])."')"); $this->query("SELECT id FROM contact_purposes WHERE label = '".$this->protect_string_db($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])."'"); } $res_purpose = $this->fetch_object(); $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $res_purpose->id; } else if($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] <> "" && $_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'] <> ""){ $this->query("SELECT id FROM contact_purposes WHERE label = '".$this->protect_string_db($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])."'"); $res_purpose = $this->fetch_object(); if ($res_purpose->id != $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID']) { $this->query("INSERT INTO contact_purposes (label) VALUES ('".$this->protect_string_db($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])."')"); $this->query("SELECT id FROM contact_purposes WHERE label = '".$this->protect_string_db($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])."'"); $res_purpose = $this->fetch_object(); $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $res_purpose->id; } } if ($mode == 'add') { if($_SESSION['user']['UserId'] == 'superadmin'){ $entity_id = 'SUPERADMIN'; } else { $entity_id = $_SESSION['user']['primaryentity']['id']; } $query = 'INSERT INTO ' . $_SESSION['tablename']['contact_addresses'] . ' ( contact_id, contact_purpose_id, departement, lastname , firstname , function , ' . 'phone , email , address_num, address_street, ' . 'address_complement, address_town, ' . 'address_postal_code, address_country, other_data,' . " title, is_private, website, occupancy, user_id, entity_id, salutation_header, salutation_footer) VALUES ( " . $_SESSION['contact']['current_contact_id'] . ", " . $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] . ", '" . $this->protect_string_db( $_SESSION['m_admin']['address']['DEPARTEMENT'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['address']['LASTNAME'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['address']['FIRSTNAME'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['address']['FUNCTION'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['address']['PHONE'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['address']['MAIL'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['address']['ADD_NUM'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['address']['ADD_STREET'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['address']['ADD_COMP'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['address']['ADD_TOWN'] ) . "', '" . $this->protect_string_db( $_SESSION['m_admin']['address']['ADD_CP'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['address']['ADD_COUNTRY'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['address']['OTHER_DATA'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['address']['TITLE'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['address']['IS_PRIVATE'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['address']['WEBSITE'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['address']['OCCUPANCY'] ) . "','" . $this->protect_string_db( $_SESSION['user']['UserId'] ) . "','" . $this->protect_string_db( $entity_id ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['address']['SALUTATION_HEADER'] ) . "','" . $this->protect_string_db( $_SESSION['m_admin']['address']['SALUTATION_FOOTER'] ) . "' )"; $this->query($query); if($_SESSION['history']['addressadd']) { $this->query("select id from ".$_SESSION['tablename']['contact_addresses']." where lastname = '".$this->protect_string_db($_SESSION['m_admin']['address']['LASTNAME'])."' and firstname = '".$this->protect_string_db($_SESSION['m_admin']['address']['FIRSTNAME'])."' and society = '".$this->protect_string_db($_SESSION['m_admin']['address']['SOCIETY'])."' and function = '".$this->protect_string_db($_SESSION['m_admin']['address']['FUNCTION'])."' and is_corporate_person = '".$this->protect_string_db($_SESSION['m_admin']['address']['IS_CORPORATE_PERSON'])."'"); $res = $this->fetch_object(); $id = $res->contact_id; if($_SESSION['m_admin']['address']['IS_CORPORATE_PERSON'] == 'Y') { $msg = _ADDRESS_ADDED.' : '.$this->protect_string_db($_SESSION['m_admin']['address']['SOCIETY']); } else { $msg = _ADDRESS_ADDED.' : '.$this->protect_string_db($_SESSION['m_admin']['address']['LASTNAME'].' '.$_SESSION['m_admin']['address']['FIRSTNAME']); } require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'); $hist = new history(); $hist->add($_SESSION['tablename']['contact_addresses'], $id,"ADD",'contact_addresses_add',$msg, $_SESSION['config']['databasetype']); } if($iframe){ $this->clearcontactinfos(); } $this->clearaddressinfos(); $_SESSION['info'] = _ADDRESS_ADDED; header("location: ".$path_contacts); exit; } elseif($mode == "up") { $query = "update ".$_SESSION['tablename']['contact_addresses']." set contact_purpose_id = '".$_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID']."' , departement = '".$this->protect_string_db($_SESSION['m_admin']['address']['DEPARTEMENT'])."' , firstname = '".$this->protect_string_db($_SESSION['m_admin']['address']['FIRSTNAME'])."' , lastname = '".$this->protect_string_db($_SESSION['m_admin']['address']['LASTNAME'])."' , title = '".$this->protect_string_db($_SESSION['m_admin']['address']['TITLE'])."' , function = '".$this->protect_string_db($_SESSION['m_admin']['address']['FUNCTION'])."' , phone = '".$this->protect_string_db($_SESSION['m_admin']['address']['PHONE'])."' , email = '".$this->protect_string_db($_SESSION['m_admin']['address']['MAIL'])."' , occupancy = '".$this->protect_string_db($_SESSION['m_admin']['address']['OCCUPANCY'])."' , address_num = '".$this->protect_string_db($_SESSION['m_admin']['address']['ADD_NUM'])."' , address_street = '".$this->protect_string_db($_SESSION['m_admin']['address']['ADD_STREET'])."' , address_complement = '".$this->protect_string_db($_SESSION['m_admin']['address']['ADD_COMP'])."' , address_town = '".$this->protect_string_db($_SESSION['m_admin']['address']['ADD_TOWN'])."' , address_postal_code = '".$this->protect_string_db($_SESSION['m_admin']['address']['ADD_CP'])."' , address_country = '".$this->protect_string_db($_SESSION['m_admin']['address']['ADD_COUNTRY'])."' , website = '".$this->protect_string_db($_SESSION['m_admin']['address']['WEBSITE'])."' , other_data = '".$this->protect_string_db($_SESSION['m_admin']['address']['OTHER_DATA'])."' , is_private = '".$this->protect_string_db($_SESSION['m_admin']['address']['IS_PRIVATE'])."' , salutation_header = '".$this->protect_string_db($_SESSION['m_admin']['address']['SALUTATION_HEADER'])."' , salutation_footer = '".$this->protect_string_db($_SESSION['m_admin']['address']['SALUTATION_FOOTER'])."'"; $query .=" where id = ".$_SESSION['m_admin']['address']['ID']; $this->query($query); if($_SESSION['history']['contactup']) { $msg = _ADDRESS_EDITED.' : '.$this->protect_string_db($_SESSION['m_admin']['address']['SOCIETY']).' '.$this->protect_string_db($_SESSION['m_admin']['address']['LASTNAME'].' '.$_SESSION['m_admin']['address']['FIRSTNAME']); require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'); $hist = new history(); $hist->add($_SESSION['tablename']['contacts_v2'], $_SESSION['m_admin']['address']['ID'],"UP",'contacts_v2_up',$msg, $_SESSION['config']['databasetype']); } $this->clearcontactinfos(); $_SESSION['info'] = _ADDRESS_EDITED; header("location: ".$path_contacts); exit(); } } } /** * Return the address data in sessions vars * * @param string $mode add or up */ public function addressinfo($mode) { // return the user information in sessions vars $func = new functions(); if ($_REQUEST['title'] <> '') { $_SESSION['m_admin']['address']['TITLE'] = $func->wash( $_REQUEST['title'], 'no', _TITLE2 . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['TITLE'] = ''; } if ($_REQUEST['contact_purposes'] <> '') { $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $func->wash( $_REQUEST['contact_purposes'], 'no', _CONTACT_PURPOSE . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = ''; } $_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'] = $func->wash( $_REQUEST['new_id'], 'no', _CONTACT_PURPOSE . ' ', 'yes', 0, 255 ); if ($_REQUEST['departement'] <> '') { $_SESSION['m_admin']['address']['DEPARTEMENT'] = $func->wash( $_REQUEST['departement'], 'no', _DEPARTEMENT . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['DEPARTEMENT'] = ''; } if ($_REQUEST['lastname'] <> '') { $_SESSION['m_admin']['address']['LASTNAME'] = $func->wash( $_REQUEST['lastname'], 'no', _LASTNAME . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['LASTNAME'] = ''; } if ($_REQUEST['firstname'] <> '') { $_SESSION['m_admin']['address']['FIRSTNAME'] = $func->wash( $_REQUEST['firstname'], 'no', _FIRSTNAME . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['FIRSTNAME'] = ''; } if ($_REQUEST['function'] <> '') { $_SESSION['m_admin']['address']['FUNCTION'] = $func->wash( $_REQUEST['function'], 'no', _FUNCTION . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['FUNCTION'] = ''; } if ($_REQUEST['num'] <> '') { $_SESSION['m_admin']['address']['ADD_NUM'] = $func->wash( $_REQUEST['num'], 'no', _NUM . ' ', 'yes', 0, 32 ); } else { $_SESSION['m_admin']['address']['ADD_NUM'] = ''; } if ($_REQUEST['street'] <> '') { $_SESSION['m_admin']['address']['ADD_STREET'] = $func->wash( $_REQUEST['street'], 'no', _STREET . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['ADD_STREET'] = ''; } if ($_REQUEST['add_comp'] <> '') { $_SESSION['m_admin']['address']['ADD_COMP'] = $func->wash( $_REQUEST['add_comp'], 'no', ADD_COMP . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['ADD_COMP'] = ''; } if ($_REQUEST['town'] <> '') { $_SESSION['m_admin']['address']['ADD_TOWN'] = $func->wash( $_REQUEST['town'], 'no', _TOWN . ' ', 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['ADD_TOWN'] = ''; } if ($_REQUEST['cp'] <> '') { $_SESSION['m_admin']['address']['ADD_CP'] = $func->wash( $_REQUEST['cp'], 'no', _POSTAL_CODE, 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['ADD_CP'] = ''; } if ($_REQUEST['country'] <> '') { $_SESSION['m_admin']['address']['ADD_COUNTRY'] = $func->wash( $_REQUEST['country'], 'no', _COUNTRY, 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['ADD_COUNTRY'] = ''; } if ($_REQUEST['phone'] <> '') { $_SESSION['m_admin']['address']['PHONE'] = $func->wash( $_REQUEST['phone'], 'num', _PHONE, 'yes', 0, 20 ); } else { $_SESSION['m_admin']['address']['PHONE'] = ''; } if ($_REQUEST['mail'] <> '') { $_SESSION['m_admin']['address']['MAIL'] = $func->wash( $_REQUEST['mail'], 'mail', _MAIL, 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['MAIL'] = ''; } if ($_REQUEST['comp_data'] <> '') { $_SESSION['m_admin']['address']['OTHER_DATA'] = $func->wash( $_REQUEST['comp_data'], 'no', _COMP_DATA, 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['OTHER_DATA'] = ''; } if ($_REQUEST['website'] <> '') { $_SESSION['m_admin']['address']['WEBSITE'] = $func->wash( $_REQUEST['website'], 'no', _WEBSITE, 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['WEBSITE'] = ''; } if ($_REQUEST['occupancy'] <> '') { $_SESSION['m_admin']['address']['OCCUPANCY'] = $func->wash( $_REQUEST['occupancy'], 'no', _OCCUPANCY, 'yes', 0, 1024 ); } else { $_SESSION['m_admin']['address']['occupancy'] = ''; } if ($_REQUEST['salutation_header'] <> '') { $_SESSION['m_admin']['address']['SALUTATION_HEADER'] = $func->wash( $_REQUEST['salutation_header'], 'no', _SALUTATION_HEADER, 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['SALUTATION_HEADER'] = ''; } if ($_REQUEST['salutation_footer'] <> '') { $_SESSION['m_admin']['address']['SALUTATION_FOOTER'] = $func->wash( $_REQUEST['salutation_footer'], 'no', _SALUTATION_FOOTER, 'yes', 0, 255 ); } else { $_SESSION['m_admin']['address']['SALUTATION_FOOTER'] = ''; } $_SESSION['m_admin']['address']['IS_PRIVATE'] = $_REQUEST['is_private']; if (isset($_REQUEST['owner']) && $_REQUEST['owner'] <> '') { if (preg_match('/\((.|\s|\d|\h|\w)+\)$/i', $_REQUEST['owner']) == 0) { $_SESSION['error'] = _OWNER . ' ' . _WRONG_FORMAT . '.
' . _USE_AUTOCOMPLETION; } else { $_SESSION['m_admin']['address']['OWNER'] = str_replace( ')', '', substr($_REQUEST['owner'], strrpos($_REQUEST['owner'],'(')+1) ); $_SESSION['m_admin']['address']['OWNER'] = $func->wash( $_SESSION['m_admin']['address']['OWNER'], 'no', _OWNER . ' ', 'yes', 0, 32 ); } } else { $_SESSION['m_admin']['address']['OWNER'] = ''; } $_SESSION['m_admin']['address']['order'] = $_REQUEST['order']; $_SESSION['m_admin']['address']['order_field'] = $_REQUEST['order_field']; $_SESSION['m_admin']['address']['what'] = $_REQUEST['what']; $_SESSION['m_admin']['address']['start'] = $_REQUEST['start']; } /** * Return the label from an id * * @param int $contact_type_id * @param string $table */ public function get_label_contact($contact_type_id, $table){ $this->connect(); $this->query('select label from '.$table . ' where id = '.$contact_type_id); $res = $this->fetch_object(); return $this->show_string($res->label); } public function get_civility_contact($title){ $xml = simplexml_load_file('apps'.DIRECTORY_SEPARATOR.'maarch_entreprise'.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'entreprise.xml'); if ($xml <> false) { $result = $xml->xpath('/ROOT/titles'); foreach ($result as $key => $value) { foreach ($value as $key2 => $value2) { if($value2->id==$title){ $title_value=$value2->label; } } } } return $this->show_string($title_value); } public function type_purpose_address_del($id, $admin = true, $tablename, $mode='contact_type', $deleted_sentence, $warning_sentence, $title, $reaffect_sentence, $new_sentence, $choose_sentence, $page_return, $page_del, $name){ $nb_elements = 0; $this->connect(); $order = $_REQUEST['order']; $order_field = $_REQUEST['order_field']; $start = $_REQUEST['start']; $what = $_REQUEST['what']; $path = $_SESSION['config']['businessappurl']."index.php?page=".$page_return."&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what; $path_del = $_SESSION['config']['businessappurl']."index.php?page=".$page_del."&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what; if(!$admin) { if ($mode == 'contact_address'){ $path = $_SESSION['config']['businessappurl']."index.php?page=my_contact_up&dir=my_contacts&load&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what; } } if(!empty($id)) { if ($mode == 'contact_type') { $this->query("select contact_id from ".$_SESSION['tablename']['contacts_v2'] . " where contact_type = ". $id ); } else if ($mode == 'contact_purpose'){ $this->query("select id from ".$_SESSION['tablename']['contact_addresses'] . " where contact_purpose_id = ". $id ); } else if ($mode == 'contact_address'){ $this->query("select address_id from mlb_coll_ext where address_id = ". $id ); } if($this->nb_result() > 0)$nb_elements = $nb_elements + $this->nb_result(); // $this->show(); if ($mode == 'contact_address'){ $this->query("select address_id from contacts_res where address_id = ". $id ); if($this->nb_result() > 0)$nb_elements = $nb_elements + $this->nb_result(); } ?>

query("DELETE FROM ".$tablename." WHERE id = ".$id); if($_SESSION['history'][$page_del] == "true") { require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php"); $users = new history(); $users->add($tablename, $id,"DEL",$page_del, $title." ".strtolower(_NUM).$id."", $_SESSION['config']['databasetype']); } $_SESSION['error'] = $deleted_sentence; unset($_SESSION['m_admin']); ?> 0) { ?>


".$label."";?>

0) { if ($mode == 'contact_type') { echo "
- ".$nb_elements." "._CONTACTS; } else if ($mode == 'contact_purpose'){ echo "
- ".$nb_elements." "._ADDRESSES; } else if ($mode == 'contact_address'){ echo "
- ".$nb_elements." "._DOC_S; } ?>

query("SELECT * FROM ".$_SESSION['tablename']['contacts_v2'] . " WHERE contact_id = ". $_SESSION['contact']['current_contact_id'] ); while($line = $this->fetch_object()) { $CurrentContact = $this->get_label_contact($line->contact_type, $_SESSION['tablename']['contact_types']) . ' : '; if($line->is_corporate_person == 'N'){ $CurrentContact = $this->show_string($line->lastname)." ".$this->show_string($line->firstname); if($line->society <> ''){ $CurrentContact .= ' ('.$line->society.')'; } } else { $CurrentContact .= $line->society; if($line->society_short <> ''){ $CurrentContact .= ' ('.$line->society_short.')'; } } } ?>


query("select id, label from ".$tablename." where id <> ".$id); while ($res = $this->fetch_object()) { $array[$res->id] = $this->protect_string_db($res->label); } ?>

?\n\r\n\r'));"/>









?\n\r\n\r'));"/> ?\n\r\n\r'));"/>



:   checked="checked" /> checked="checked" />    
:    
:    
:    
:    
:    
:    
:    
 :    
> > > >
     
 
:  
 
 
 
 :  
 
 
 
 :  
 
 
 
 
 :  
 :  
 :   checked="checked" /> 'Y'){?> checked="checked" />
 :                                
 :  
connect(); $this->query("UPDATE contacts_v2 SET enabled = '".$mode."' WHERE contact_id = '".$userId."'"); $this->query("UPDATE contact_addresses SET enabled = '".$mode."' WHERE contact_id = '".$userId."'"); } function addressEnabled($addressId, $mode) { $this->connect(); $this->query("UPDATE contact_addresses SET enabled = '".$mode."' WHERE id = '".$addressId."'"); } } ?>