load_lang(); $db = new dbquery(); $db->connect(); $db2 = new dbquery(); $db2->connect(); $return = ''; if ($_REQUEST['society_label'] <> '') { $selectDuplicates = "SELECT contact_id, user_id, society, lower(society) as lowsoc, society_short," . "is_corporate_person, lastname, firstname " . "from contacts_v2 " . "WHERE lower(society) in (" . "SELECT lower(society) FROM contacts_v2 GROUP BY lower(society) " . " HAVING Count(lower(society)) > 1 and lower(society) <> '' ) and contact_id <> " . $_REQUEST['contact_id'] . " and lower(society) = '" . mb_strtolower($db->protect_string_db($_REQUEST['society_label']), 'utf-8') . "' " . "order by lower(society)"; } if ($_REQUEST['name'] <> '') { $selectDuplicates = "SELECT contact_id, lower(lastname||' '||firstname) as lastname_firstname, society, society_short," . "is_corporate_person, lastname, firstname, title " . "from contacts_v2 " . "WHERE lower(lastname||' '||firstname) in (" . "SELECT lower(lastname||' '||firstname) as lastname_firstname FROM contacts_v2 GROUP BY lastname_firstname, contact_type " . " HAVING Count(lower(lastname||' '||firstname)) > 1 and lower(lastname||' '||firstname) <> ' ') and contact_id <> " . $_REQUEST['contact_id'] . " and lower(lastname||' '||firstname) = '" . mb_strtolower($db->protect_string_db($_REQUEST['name']), 'utf-8') . "' " . "order by lower(lastname||' '||firstname)"; } if (isset($_REQUEST['contact_id'])) { //test if res attached to the contact $query = "select res_id from res_view_letterbox where (exp_contact_id = " . $_REQUEST['contact_id'] . " or dest_contact_id = " . $_REQUEST['contact_id'] . ") and status <> 'DEL'"; $db->query($query); $flagResAttached = false; $return_db = $db->fetch_object(); if ($return_db->res_id <> '') { $flagResAttached = true; $db->query($selectDuplicates); //$db->show(); $contactList = array(); array_push($contactList, "Selectionner un contact"); while($lineDoubl = $db->fetch_object()) { $db2->query("SELECT id FROM contact_addresses WHERE contact_id = " . $lineDoubl->contact_id); // $db2->show(); $result_address = $db2->fetch_object(); if ($result_address->id <> '') { array_push($contactList, $lineDoubl->contact_id); } } } if ($flagResAttached) { $return .= _RES_ATTACHED . '. ' . _SELECT_CONTACT_TO_REPLACE; $return .= ' :
'._NEW_CONTACT.' : '; $return .= '
' . _NEW_ADDRESS. ' : '; $return .= '
'; } $return .= _ARE_YOU_SURE_TO_DELETE_CONTACT; if ($flagResAttached) { $return .= ' '; } else { $return .= ' '; } $return .= ' '; $status = 0; } else { $status = 1; $return .= ''; $return .= '

'; $return .= 'Error loading documents'; $return .= '

'; $return .= ''; } echo "{status : " . $status . ", toShow : '" . addslashes($return) . "'}"; exit ();