. */ /** * @brief Contains functions to manage contacts * * * @file * @date $date$ * @version $Revision$ * @ingroup apps */ abstract class contacts_v2_Abstract extends Database { /** * 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, 'no', 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); $db = new Database(); $stmt = $db->query($query['query'], $query['params']); if($stmt->rowCount() > 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){ $query = ''; if($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'N'){ $query = "SELECT contact_id, contact_type, society, contact_firstname, contact_lastname, contact_enabled FROM view_contacts WHERE lower(contact_firstname) = lower(?) and lower(contact_lastname) = lower(?)"; $arrayPDO = array($_SESSION['m_admin']['contact']['FIRSTNAME'], $_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, contact_enabled FROM view_contacts WHERE lower(society) = lower(?)"; $arrayPDO = array($_SESSION['m_admin']['contact']['SOCIETY']); } if ($mode == 'up'){ $query .= " and contact_id <> ?"; $arrayPDO = array_merge($arrayPDO, array($_SESSION['m_admin']['contact']['ID'])); } return array("query" => $query, "params" => $arrayPDO); } /** * Add ou modify contact in the database * * @param string $mode up or add */ public function addupcontact($mode, $admin = true, $confirm = 'N', $mycontact = 'N') { $db = new Database(); // 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 { 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, current_timestamp)"; $db->query($query, array($_SESSION['m_admin']['contact']['CONTACT_TYPE'], $_SESSION['m_admin']['contact']['LASTNAME'], $_SESSION['m_admin']['contact']['FIRSTNAME'] , $_SESSION['m_admin']['contact']['SOCIETY'], $_SESSION['m_admin']['contact']['SOCIETY_SHORT'], $_SESSION['m_admin']['contact']['FUNCTION'], $_SESSION['m_admin']['contact']['OTHER_DATA'] , $_SESSION['m_admin']['contact']['TITLE'], $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'], $_SESSION['user']['UserId'], $entity_id)); if($_SESSION['history']['contactadd']) { $stmt = $db->query("SELECT contact_id, creation_date FROM ".$_SESSION['tablename']['contacts_v2'] ." WHERE lastname = ? and firstname = ? and society = ? and function = ? and is_corporate_person = ? order by creation_date desc" , array($_SESSION['m_admin']['contact']['LASTNAME'], $_SESSION['m_admin']['contact']['FIRSTNAME'], $_SESSION['m_admin']['contact']['SOCIETY'] , $_SESSION['m_admin']['contact']['FUNCTION'], $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'])); $res = $stmt->fetchObject(); $id = $res->contact_id; if($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') { $msg = _CONTACT_ADDED.' : '.functions::protect_string_db($_SESSION['m_admin']['contact']['SOCIETY']); } else { $msg = _CONTACT_ADDED.' : '.functions::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']); } $stmt = $db->query("SELECT contact_id, creation_date FROM ".$_SESSION['tablename']['contacts_v2'] ." WHERE lastname = ? and firstname = ? and society = ? and function = ? and is_corporate_person = ? order by creation_date desc" , array($_SESSION['m_admin']['contact']['LASTNAME'], $_SESSION['m_admin']['contact']['FIRSTNAME'], $_SESSION['m_admin']['contact']['SOCIETY'] , $_SESSION['m_admin']['contact']['FUNCTION'], $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'])); $res = $stmt->fetchObject(); $id = $res->contact_id; $_SESSION['contact']['current_contact_id'] = $id; $_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 = ?, lastname = ?, firstname = ?,society = ?,society_short = ?,function = ?, other_data = ?, title = ?, is_corporate_person = ?"; $query .= " WHERE contact_id = ?"; $arrayPDO = array($_SESSION['m_admin']['contact']['CONTACT_TYPE'], $_SESSION['m_admin']['contact']['LASTNAME'], $_SESSION['m_admin']['contact']['FIRSTNAME'] , $_SESSION['m_admin']['contact']['SOCIETY'], $_SESSION['m_admin']['contact']['SOCIETY_SHORT'], $_SESSION['m_admin']['contact']['FUNCTION'] , $_SESSION['m_admin']['contact']['OTHER_DATA'], $_SESSION['m_admin']['contact']['TITLE'], $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'], $_SESSION['m_admin']['contact']['ID']); $db->query($query, $arrayPDO); if($_SESSION['history']['contactup']) { if($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') { $msg = _CONTACT_MODIFIED.' : '.functions::protect_string_db($_SESSION['m_admin']['contact']['SOCIETY']); } else { $msg = _CONTACT_MODIFIED.' : '.functions::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) { $db = new Database(); 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") { $query = "SELECT * FROM ".$_SESSION['tablename']['contacts_v2']." WHERE contact_id = ?"; $stmt = $db->query($query, array($id)); if($stmt->rowCount() == 0) { $_SESSION['error'] = _THE_CONTACT.' '._ALREADY_EXISTS; $state = false; } else { $_SESSION['m_admin']['contact'] = array(); $line = $stmt->fetchObject(); $_SESSION['m_admin']['contact']['ID'] = $line->contact_id; $_SESSION['m_admin']['contact']['TITLE'] = functions::show_string($line->title); $_SESSION['m_admin']['contact']['LASTNAME'] = functions::show_string($line->lastname); $_SESSION['m_admin']['contact']['FIRSTNAME'] = functions::show_string($line->firstname); $_SESSION['m_admin']['contact']['SOCIETY'] = functions::show_string($line->society); $_SESSION['m_admin']['contact']['SOCIETY_SHORT'] = functions::show_string($line->society_short); $_SESSION['m_admin']['contact']['FUNCTION'] = functions::show_string($line->function); $_SESSION['m_admin']['contact']['OTHER_DATA'] = functions::show_string($line->other_data); $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] = functions::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'])) { $stmt = $db->query("SELECT lastname, firstname FROM ".$_SESSION['tablename']['users']." WHERE user_id = ?", array($_SESSION['m_admin']['contact']['OWNER'])); $res = $stmt->fetchObject(); $_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']; if($iframe != true){ echo '

'; if($mode == "up") { ?>
'; }else{ echo '

'; if($mode == "up") { echo _CONTACT; } elseif($mode == "add") { echo _ADD_NEW_CONTACT; } elseif($mode == "view") { ?>'; } ?>



"._THE_CONTACT." "._UNKOWN."



"; } else { $can_add_contact = ($admin ? "" : "Y"); $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, '');setContactType('corporate', '')" id="corpo_yes"> checked="checked" onclick="javascript:show_admin_contacts( false, '');setContactType('no_corporate', '')" id="corpo_no">                                  
 
:
 
 
:
 
 
 
 :  

()

onclick="self.close();" onclick="new Effect.BlindUp(parent.document.getElementById('create_contact_div_attach'));new Effect.BlindUp(parent.document.getElementById('info_contact_div_attach'));simpleAjax('index.php?display=true&page=unsetAttachmentContact');return false;" onclick="new Effect.BlindUp(parent.document.getElementById('show_tab'));new Effect.BlindUp(parent.document.getElementById('info_contact_div'));return false;" />


'; } } public function chooseContact($clean = true){ $db = new Database(); if ($clean) { $this->clearcontactinfos(); } ?>




query("SELECT res_id FROM ".$_SESSION['collections'][0]['view'] . " WHERE exp_contact_id = ? or dest_contact_id = ?", array($id, $id)); if($stmt->rowCount() > 0)$nb_docs = $nb_docs + $stmt->rowCount(); $stmt = $db->query("SELECT contact_id FROM contacts_res WHERE contact_id = ?", array($id)); if($stmt->rowCount() > 0)$nb_docs = $nb_docs + $stmt->rowCount(); if ($nb_docs == 0) { $query = "SELECT contact_id FROM ".$_SESSION['tablename']['contacts_v2']." WHERE contact_id = ? "; $arrayPDO = array($id); if(!$admin) { $query .= " and user_id = ?"; $arrayPDO = array_merge($arrayPDO, array($_SESSION['user']['UserId'])); } $stmt = $db->query($query, $arrayPDO); if($stmt->rowCount() == 0) { $_SESSION['error'] = _CONTACT.' '._UNKNOWN; } else { $res = $stmt->fetchObject(); $db->query("DELETE FROM " . $_SESSION['tablename']['contacts_v2'] . " WHERE contact_id = ?", array($id)); $db->query("DELETE FROM " . $_SESSION['tablename']['contact_addresses'] . " WHERE contact_id = ?", array($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'));"/>

"._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 = "") { $db = new Database(); 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") { $query = "SELECT * FROM ".$_SESSION['tablename']['contact_addresses']." WHERE id = ?"; $arrayPDO = array($id); $core_tools = new core_tools(); if(!$admin && !$core_tools->test_service('update_contacts', 'apps', false)) { $query .= " and user_id = ?"; $arrayPDO = array_merge($arrayPDO, array($_SESSION['user']['UserId'])); } $stmt = $db->query($query, $arrayPDO); if($stmt->rowCount() == 0) { $_SESSION['error'] = _THE_ADDRESS.' '._ALREADY_EXISTS; $state = false; } else { if (!isset($_SESSION['address_up_error'])) { $_SESSION['m_admin']['address'] = array(); $line = $stmt->fetchObject(); $_SESSION['m_admin']['address']['ID'] = $line->id; $_SESSION['m_admin']['address']['CONTACT_ID'] = $line->contact_id; $_SESSION['m_admin']['address']['TITLE'] = functions::show_string($line->title); $_SESSION['m_admin']['address']['LASTNAME'] = functions::show_string($line->lastname); $_SESSION['m_admin']['address']['FIRSTNAME'] = functions::show_string($line->firstname); $_SESSION['m_admin']['address']['FUNCTION'] = functions::show_string($line->function); $_SESSION['m_admin']['address']['OTHER_DATA'] = functions::show_string($line->other_data); $_SESSION['m_admin']['address']['OWNER'] = $line->user_id; $_SESSION['m_admin']['address']['DEPARTEMENT'] = functions::show_string($line->departement); $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $line->contact_purpose_id; $_SESSION['m_admin']['address']['OCCUPANCY'] = functions::show_string($line->occupancy); $_SESSION['m_admin']['address']['ADD_NUM'] = functions::show_string($line->address_num); $_SESSION['m_admin']['address']['ADD_STREET'] = functions::show_string($line->address_street); $_SESSION['m_admin']['address']['ADD_COMP'] = functions::show_string($line->address_complement); $_SESSION['m_admin']['address']['ADD_TOWN'] = functions::show_string($line->address_town); $_SESSION['m_admin']['address']['ADD_CP'] = functions::show_string($line->address_postal_code); $_SESSION['m_admin']['address']['ADD_COUNTRY'] = functions::show_string($line->address_country); $_SESSION['m_admin']['address']['PHONE'] = functions::show_string($line->phone); $_SESSION['m_admin']['address']['MAIL'] = functions::show_string($line->email); $_SESSION['m_admin']['address']['WEBSITE'] = functions::show_string($line->website); $_SESSION['m_admin']['address']['IS_PRIVATE'] = functions::show_string($line->is_private); $_SESSION['m_admin']['address']['SALUTATION_HEADER'] = functions::show_string($line->salutation_header); $_SESSION['m_admin']['address']['SALUTATION_FOOTER'] = functions::show_string($line->salutation_footer); } else { unset($_SESSION['address_up_error']); } if($admin && !empty($_SESSION['m_admin']['address']['OWNER'])) { $stmt = $db->query("SELECT lastname, firstname FROM ".$_SESSION['tablename']['users']." WHERE user_id = ?", array($_SESSION['m_admin']['address']['OWNER'])); $res = $stmt->fetchObject(); $_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(); $stmt = $db->query("SELECT id, label FROM ".$_SESSION['tablename']['contact_purposes']); while($res = $stmt->fetchObject()){ $contact_purposes[$res->id] = functions::show_string($res->label); } if($iframe != true){ echo '

'; if($mode == "up") {?> '; }else{ echo '

'; if($mode == "up") { echo _MODIFY_ADDRESS; } elseif($mode == "add") { echo _ADDITION_ADDRESS; } echo '

'; } if($iframe != true){ echo '
'; }else{ echo '
'; } if($state == false) { echo "



"._THE_ADDRESS." "._UNKOWN."



"; } else { $this->get_contact_form(); $action = $_SESSION['config']['businessappurl']."index.php?display=true&page=contact_addresses_up_db"; $fieldAddressClass = "address_modification_field"; $fieldSalutationClass = "salutation_modification_field"; 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"; $fieldAddressClass = "address_modification_field_frame"; $fieldSalutationClass = "salutation_modification_field_frame"; } 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="'.functions::xssafe($this->get_label_contact($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'],$_SESSION['tablename']['contact_purposes'])).'"'; } else { echo 'value="'._MAIN_ADDRESS.'"'; } ?> />
'') { echo 'value="'.functions::xssafe($_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']; if ($_SESSION['AttachmentContact'] == "1") { ?> test_service('my_contacts', 'apps', false)){ ?>onclick="new Effect.BlindUp(parent.document.getElementById('create_contact_div_attach'));new Effect.BlindUp(parent.document.getElementById('info_contact_div_attach'));simpleAjax('index.php?display=true&page=unsetAttachmentContact');return false;" onclick="new Effect.BlindUp(parent.document.getElementById('info_contact_div_attach'));simpleAjax('index.php?display=true&page=unsetAttachmentContact');return false;" /> test_service('my_contacts', 'apps', false)){ ?>onclick="new Effect.BlindUp(parent.document.getElementById('create_contact_div'));new Effect.BlindUp(parent.document.getElementById('info_contact_div'));return false;" onclick="new Effect.BlindUp(parent.document.getElementById('info_contact_div'));return false;" />

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 { if ($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] == "") { $stmt = $db->query("SELECT id FROM contact_purposes WHERE label = ?", array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); if ($stmt->rowCount() == 0) { $db->query("INSERT INTO contact_purposes (label) VALUES (?)", array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); $stmt = $db->query("SELECT id FROM contact_purposes WHERE label = ?", array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); } $res_purpose = $stmt->fetchObject(); $_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'] <> ""){ $stmt = $db->query("SELECT id FROM contact_purposes WHERE label = ?", array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); $res_purpose = $stmt->fetchObject(); if ($res_purpose->id != $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID']) { $db->query("INSERT INTO contact_purposes (label) VALUES (?)", array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); $stmt = $db->query("SELECT id FROM contact_purposes WHERE label = ?", array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); $res_purpose = $stmt->fetchObject(); $_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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $arrayPDO = array($_SESSION['contact']['current_contact_id'], $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'], $_SESSION['m_admin']['address']['DEPARTEMENT'], $_SESSION['m_admin']['address']['LASTNAME'], $_SESSION['m_admin']['address']['FIRSTNAME'], $_SESSION['m_admin']['address']['FUNCTION'], $_SESSION['m_admin']['address']['PHONE'], $_SESSION['m_admin']['address']['MAIL'], $_SESSION['m_admin']['address']['ADD_NUM'], $_SESSION['m_admin']['address']['ADD_STREET'], $_SESSION['m_admin']['address']['ADD_COMP'], $_SESSION['m_admin']['address']['ADD_TOWN'], $_SESSION['m_admin']['address']['ADD_CP'], $_SESSION['m_admin']['address']['ADD_COUNTRY'], $_SESSION['m_admin']['address']['OTHER_DATA'], $_SESSION['m_admin']['address']['TITLE'], $_SESSION['m_admin']['address']['IS_PRIVATE'], $_SESSION['m_admin']['address']['WEBSITE'], $_SESSION['m_admin']['address']['OCCUPANCY'], $_SESSION['user']['UserId'], $entity_id, $_SESSION['m_admin']['address']['SALUTATION_HEADER'], $_SESSION['m_admin']['address']['SALUTATION_FOOTER']); $db->query($query, $arrayPDO); if($_SESSION['history']['addressadd']) { $stmt = $db->query("SELECT id FROM ".$_SESSION['tablename']['contact_addresses']." WHERE lastname = ? and firstname = ? and society = ? and function = ? and is_corporate_person = ?", array($_SESSION['m_admin']['address']['LASTNAME'], $_SESSION['m_admin']['address']['FIRSTNAME'], $_SESSION['m_admin']['address']['SOCIETY'], $_SESSION['m_admin']['address']['FUNCTION'], $_SESSION['m_admin']['address']['IS_CORPORATE_PERSON'])); $res = $stmt->fetchObject(); $id = $res->contact_id; if($_SESSION['m_admin']['address']['IS_CORPORATE_PERSON'] == 'Y') { $msg = _ADDRESS_ADDED.' : '.functions::protect_string_db($_SESSION['m_admin']['address']['SOCIETY']); } else { $msg = _ADDRESS_ADDED.' : '.functions::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 = ? , departement = ? , firstname = ? , lastname = ? , title = ? , function = ? , phone = ? , email = ? , occupancy = ? , address_num = ? , address_street = ? , address_complement = ? , address_town = ? , address_postal_code = ? , address_country = ? , website = ? , other_data = ? , is_private = ? , salutation_header = ? , salutation_footer = ?"; $query .=" WHERE id = ?"; $arrayPDO = array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'], $_SESSION['m_admin']['address']['DEPARTEMENT'], $_SESSION['m_admin']['address']['FIRSTNAME'], $_SESSION['m_admin']['address']['LASTNAME'], $_SESSION['m_admin']['address']['TITLE'], $_SESSION['m_admin']['address']['FUNCTION'], $_SESSION['m_admin']['address']['PHONE'], $_SESSION['m_admin']['address']['MAIL'], $_SESSION['m_admin']['address']['OCCUPANCY'], $_SESSION['m_admin']['address']['ADD_NUM'], $_SESSION['m_admin']['address']['ADD_STREET'], $_SESSION['m_admin']['address']['ADD_COMP'], $_SESSION['m_admin']['address']['ADD_TOWN'], $_SESSION['m_admin']['address']['ADD_CP'], $_SESSION['m_admin']['address']['ADD_COUNTRY'], $_SESSION['m_admin']['address']['WEBSITE'], $_SESSION['m_admin']['address']['OTHER_DATA'], $_SESSION['m_admin']['address']['IS_PRIVATE'], $_SESSION['m_admin']['address']['SALUTATION_HEADER'], $_SESSION['m_admin']['address']['SALUTATION_FOOTER'], $_SESSION['m_admin']['address']['ID']); $db->query($query, $arrayPDO); if($_SESSION['history']['contactup']) { $msg = _ADDRESS_EDITED.' : '.functions::protect_string_db($_SESSION['m_admin']['address']['SOCIETY']).' '.functions::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'], 'phone', _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){ $db = new Database(); $stmt = $db->query('SELECT label FROM '.$table . ' WHERE id = ?',array($contact_type_id)); $res = $stmt->fetchObject(); return functions::show_string($res->label); } public function get_civility_contact($title){ // $core = new core_tools(); if (file_exists( $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'entreprise.xml' ) ) { $path = $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'entreprise.xml'; } else { $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'entreprise.xml'; } $xml = simplexml_load_file($path); // $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=(string)$value2->label; } } } } return functions::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; $db = new Database(); $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') { $stmt = $db->query("SELECT contact_id FROM ".$_SESSION['tablename']['contacts_v2'] . " WHERE contact_type = ?", array($id)); } else if ($mode == 'contact_purpose'){ $stmt = $db->query("SELECT id FROM ".$_SESSION['tablename']['contact_addresses'] . " WHERE contact_purpose_id = ?", array($id)); } else if ($mode == 'contact_address'){ $stmt = $db->query("SELECT address_id FROM mlb_coll_ext WHERE address_id = ?", array($id)); } if($stmt->rowCount() > 0)$nb_elements = $nb_elements + $stmt->rowCount(); if ($mode == 'contact_address'){ $stmt = $db->query("SELECT address_id FROM contacts_res WHERE address_id = ?", array($id)); if($stmt->rowCount() > 0)$nb_elements = $nb_elements + $stmt->rowCount(); } ?>

query("DELETE FROM ".$tablename." WHERE id = ?", array($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 = ?", array($_SESSION['contact']['current_contact_id'])); while($line = $stmt->fetchObject()) { $CurrentContact = $this->get_label_contact($line->contact_type, $_SESSION['tablename']['contact_types']) . ' : '; if($line->is_corporate_person == 'N'){ $CurrentContact = functions::show_string($line->lastname)." ".functions::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 <> ?", array($id)); while ($res = $stmt->fetchObject()) { $array[$res->id] = functions::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" />
 :                       
 :  
query("UPDATE contacts_v2 SET enabled = ? WHERE contact_id = ?", array($mode, $userId)); $db->query("UPDATE contact_addresses SET enabled = ? WHERE contact_id = ?", array($mode, $userId)); } function addressEnabled($addressId, $mode) { $db = new Database(); $db->query("UPDATE contact_addresses SET enabled = ? WHERE id = ?", array($mode, $addressId)); } } ?>