code syntax contact directory
This commit is contained in:
parent
2642e1d1b3
commit
3b6d01ffae
@ -65,36 +65,44 @@ $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$object->getCanvas($id);
|
||||
$objcanvas = null;
|
||||
$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas"));
|
||||
if (!empty($canvas))
|
||||
{
|
||||
if (!empty($canvas)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
|
||||
$objcanvas = new Canvas($db, $action);
|
||||
$objcanvas->getCanvas('contact', 'contactcard', $canvas);
|
||||
}
|
||||
|
||||
if (GETPOST('actioncode', 'array'))
|
||||
{
|
||||
if (GETPOST('actioncode', 'array')) {
|
||||
$actioncode = GETPOST('actioncode', 'array', 3);
|
||||
if (!count($actioncode)) $actioncode = '0';
|
||||
if (!count($actioncode)) {
|
||||
$actioncode = '0';
|
||||
}
|
||||
} else {
|
||||
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
||||
}
|
||||
$search_agenda_label = GETPOST('search_agenda_label');
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
|
||||
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) $sortfield = 'a.datep, a.id';
|
||||
if (!$sortorder) $sortorder = 'DESC';
|
||||
if (!$sortfield) {
|
||||
$sortfield = 'a.datep, a.id';
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = 'DESC';
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('contactagenda', 'globalcard'));
|
||||
@ -106,20 +114,19 @@ $hookmanager->initHooks(array('contactagenda', 'globalcard'));
|
||||
|
||||
$parameters = array('id'=>$id, 'objcanvas'=>$objcanvas);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
|
||||
{
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
|
||||
$actioncode = '';
|
||||
$search_agenda_label = '';
|
||||
}
|
||||
@ -133,29 +140,30 @@ if (empty($reshook))
|
||||
$form = new Form($db);
|
||||
|
||||
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
|
||||
$title = $object->lastname;
|
||||
}
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
|
||||
if ($socid > 0)
|
||||
{
|
||||
if ($socid > 0) {
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($socid);
|
||||
}
|
||||
|
||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
{
|
||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
if (empty($object->error) && $id)
|
||||
{
|
||||
$object = new Contact($db);
|
||||
$result = $object->fetch($id);
|
||||
if ($result <= 0) dol_print_error('', $object->error);
|
||||
}
|
||||
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
|
||||
if (empty($object->error) && $id) {
|
||||
$object = new Contact($db);
|
||||
$result = $object->fetch($id);
|
||||
if ($result <= 0) {
|
||||
dol_print_error('', $object->error);
|
||||
}
|
||||
}
|
||||
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
|
||||
$objcanvas->display_canvas($action); // Show template
|
||||
} else {
|
||||
// -----------------------------------------
|
||||
@ -163,26 +171,27 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// -----------------------------------------
|
||||
|
||||
// Confirm deleting contact
|
||||
if ($user->rights->societe->contact->supprimer)
|
||||
{
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($user->rights->societe->contact->supprimer) {
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Onglets
|
||||
*/
|
||||
* Onglets
|
||||
*/
|
||||
$head = array();
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
// Si edition contact deja existant
|
||||
$object = new Contact($db);
|
||||
$res = $object->fetch($id, $user);
|
||||
if ($res < 0) { dol_print_error($db, $object->error); exit; }
|
||||
if ($res < 0) {
|
||||
dol_print_error($db, $object->error); exit;
|
||||
}
|
||||
$res = $object->fetch_optionals();
|
||||
if ($res < 0) { dol_print_error($db, $object->error); exit; }
|
||||
if ($res < 0) {
|
||||
dol_print_error($db, $object->error); exit;
|
||||
}
|
||||
|
||||
// Show tabs
|
||||
$head = contact_prepare_head($object);
|
||||
@ -190,13 +199,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||
}
|
||||
|
||||
if (!empty($id) && $action != 'edit' && $action != 'create')
|
||||
{
|
||||
if (!empty($id) && $action != 'edit' && $action != 'create') {
|
||||
$objsoc = new Societe($db);
|
||||
|
||||
/*
|
||||
* Fiche en mode visualisation
|
||||
*/
|
||||
* Fiche en mode visualisation
|
||||
*/
|
||||
|
||||
dol_htmloutput_errors($error, $errors);
|
||||
|
||||
@ -205,14 +213,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($object->socid);
|
||||
// Thirdparty
|
||||
$morehtmlref .= $langs->trans('ThirdParty').' : ';
|
||||
if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1);
|
||||
else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
if ($objsoc->id > 0) {
|
||||
$morehtmlref .= $objsoc->getNomUrl(1);
|
||||
} else {
|
||||
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
}
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
@ -238,29 +248,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
|
||||
$out = '';
|
||||
$permok = $user->rights->agenda->myactions->create;
|
||||
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
|
||||
{
|
||||
if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '');
|
||||
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
|
||||
if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') {
|
||||
$out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '');
|
||||
}
|
||||
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : ''));
|
||||
$out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog'));
|
||||
}
|
||||
|
||||
$newcardbutton = '';
|
||||
if (!empty($conf->agenda->enabled))
|
||||
{
|
||||
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
|
||||
{
|
||||
if (!empty($conf->agenda->enabled)) {
|
||||
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
|
||||
{
|
||||
print '<br>';
|
||||
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
|
||||
print '<br>';
|
||||
|
||||
$param = '&id='.$id;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.$contextpage;
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.$limit;
|
||||
}
|
||||
|
||||
print load_fiche_titre($langs->trans("ActionsOnContact"), $newcardbutton, '');
|
||||
//print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1);
|
||||
|
||||
@ -64,14 +64,16 @@ abstract class ActionsContactCardCommon
|
||||
{
|
||||
/*$ret = $this->getInstanceDao();
|
||||
|
||||
if (is_object($this->object) && method_exists($this->object,'fetch'))
|
||||
{
|
||||
if (! empty($id)) $this->object->fetch($id);
|
||||
}
|
||||
else
|
||||
{*/
|
||||
if (is_object($this->object) && method_exists($this->object,'fetch'))
|
||||
{
|
||||
if (! empty($id)) $this->object->fetch($id);
|
||||
}
|
||||
else
|
||||
{*/
|
||||
$object = new Contact($this->db);
|
||||
if (!empty($id)) $object->fetch($id);
|
||||
if (!empty($id)) {
|
||||
$object->fetch($id);
|
||||
}
|
||||
$this->object = $object;
|
||||
//}
|
||||
}
|
||||
@ -90,20 +92,19 @@ abstract class ActionsContactCardCommon
|
||||
global $conf, $langs, $user, $canvas;
|
||||
global $form, $formcompany, $objsoc;
|
||||
|
||||
if ($action == 'add' || $action == 'update') $this->assign_post();
|
||||
if ($action == 'add' || $action == 'update') {
|
||||
$this->assign_post();
|
||||
}
|
||||
|
||||
foreach ($this->object as $key => $value)
|
||||
{
|
||||
foreach ($this->object as $key => $value) {
|
||||
$this->tpl[$key] = $value;
|
||||
}
|
||||
|
||||
$this->tpl['error'] = $this->error;
|
||||
$this->tpl['errors'] = $this->errors;
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($action == 'create' || $action == 'edit') {
|
||||
if ($conf->use_javascript_ajax) {
|
||||
$this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery("#selectcountry_id").change(function() {
|
||||
@ -115,8 +116,7 @@ abstract class ActionsContactCardCommon
|
||||
</script>'."\n";
|
||||
}
|
||||
|
||||
if (is_object($objsoc) && $objsoc->id > 0)
|
||||
{
|
||||
if (is_object($objsoc) && $objsoc->id > 0) {
|
||||
$this->tpl['company'] = $objsoc->getNomUrl(1);
|
||||
$this->tpl['company_id'] = $objsoc->id;
|
||||
} else {
|
||||
@ -127,14 +127,25 @@ abstract class ActionsContactCardCommon
|
||||
$this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id);
|
||||
|
||||
// Predefined with third party
|
||||
if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS))
|
||||
{
|
||||
if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address;
|
||||
if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip;
|
||||
if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town;
|
||||
if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->phone;
|
||||
if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax;
|
||||
if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email;
|
||||
if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) {
|
||||
if (dol_strlen(trim($this->object->address)) == 0) {
|
||||
$this->tpl['address'] = $objsoc->address;
|
||||
}
|
||||
if (dol_strlen(trim($this->object->zip)) == 0) {
|
||||
$this->object->zip = $objsoc->zip;
|
||||
}
|
||||
if (dol_strlen(trim($this->object->town)) == 0) {
|
||||
$this->object->town = $objsoc->town;
|
||||
}
|
||||
if (dol_strlen(trim($this->object->phone_pro)) == 0) {
|
||||
$this->object->phone_pro = $objsoc->phone;
|
||||
}
|
||||
if (dol_strlen(trim($this->object->fax)) == 0) {
|
||||
$this->object->fax = $objsoc->fax;
|
||||
}
|
||||
if (dol_strlen(trim($this->object->email)) == 0) {
|
||||
$this->object->email = $objsoc->email;
|
||||
}
|
||||
}
|
||||
|
||||
// Zip
|
||||
@ -143,28 +154,33 @@ abstract class ActionsContactCardCommon
|
||||
// Town
|
||||
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
|
||||
|
||||
if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id;
|
||||
if (dol_strlen(trim($this->object->country_id)) == 0) {
|
||||
$this->object->country_id = $objsoc->country_id;
|
||||
}
|
||||
|
||||
// Country
|
||||
$this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
|
||||
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||
|
||||
if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
if ($user->admin) {
|
||||
$this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
|
||||
// State
|
||||
if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
|
||||
else $this->tpl['select_state'] = $countrynotdefined;
|
||||
if ($this->object->country_id) {
|
||||
$this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
|
||||
} else {
|
||||
$this->tpl['select_state'] = $countrynotdefined;
|
||||
}
|
||||
|
||||
// Public or private
|
||||
$selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
|
||||
$this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0);
|
||||
}
|
||||
|
||||
if ($action == 'view' || $action == 'edit' || $action == 'delete')
|
||||
{
|
||||
if ($action == 'view' || $action == 'edit' || $action == 'delete') {
|
||||
// Emailing
|
||||
if (!empty($conf->mailing->enabled))
|
||||
{
|
||||
if (!empty($conf->mailing->enabled)) {
|
||||
$langs->load("mails");
|
||||
$this->tpl['nb_emailing'] = $this->object->getNbOfEMailings();
|
||||
}
|
||||
@ -175,46 +191,41 @@ abstract class ActionsContactCardCommon
|
||||
|
||||
$this->object->load_ref_elements();
|
||||
|
||||
if (!empty($conf->commande->enabled))
|
||||
{
|
||||
if (!empty($conf->commande->enabled)) {
|
||||
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders");
|
||||
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder");
|
||||
$i++;
|
||||
}
|
||||
if (!empty($conf->propal->enabled))
|
||||
{
|
||||
if (!empty($conf->propal->enabled)) {
|
||||
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals");
|
||||
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal");
|
||||
$i++;
|
||||
}
|
||||
if (!empty($conf->contrat->enabled))
|
||||
{
|
||||
if (!empty($conf->contrat->enabled)) {
|
||||
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts");
|
||||
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract");
|
||||
$i++;
|
||||
}
|
||||
if (!empty($conf->facture->enabled))
|
||||
{
|
||||
if (!empty($conf->facture->enabled)) {
|
||||
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices");
|
||||
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Dolibarr user
|
||||
if ($this->object->user_id)
|
||||
{
|
||||
if ($this->object->user_id) {
|
||||
$dolibarr_user = new User($this->db);
|
||||
$result = $dolibarr_user->fetch($this->object->user_id);
|
||||
$this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
|
||||
} else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
|
||||
} else {
|
||||
$this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'view' || $action == 'delete')
|
||||
{
|
||||
if ($action == 'view' || $action == 'delete') {
|
||||
$this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id');
|
||||
|
||||
if ($this->object->socid > 0)
|
||||
{
|
||||
if ($this->object->socid > 0) {
|
||||
$objsoc = new Societe($this->db);
|
||||
|
||||
$objsoc->fetch($this->object->socid);
|
||||
@ -243,14 +254,13 @@ abstract class ActionsContactCardCommon
|
||||
$this->tpl['note'] = nl2br($this->object->note);
|
||||
}
|
||||
|
||||
if ($action == 'create_user')
|
||||
{
|
||||
if ($action == 'create_user') {
|
||||
// Full firstname and lastname separated with a dot : firstname.lastname
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$login = dol_buildlogin($this->object->lastname, $this->object->firstname);
|
||||
|
||||
$generated_password = getRandomPassword(false);
|
||||
$generated_password = getRandomPassword(false);
|
||||
$password = $generated_password;
|
||||
|
||||
// Create a form array
|
||||
@ -297,12 +307,10 @@ abstract class ActionsContactCardCommon
|
||||
$this->object->canvas = $_POST["canvas"];
|
||||
|
||||
// We set country_id, and country_code label of the chosen country
|
||||
if ($this->object->country_id)
|
||||
{
|
||||
if ($this->object->country_id) {
|
||||
$sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
|
||||
@ -16,8 +16,7 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || !is_object($conf))
|
||||
{
|
||||
if (empty($conf) || !is_object($conf)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -16,8 +16,7 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || !is_object($conf))
|
||||
{
|
||||
if (empty($conf) || !is_object($conf)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -16,8 +16,7 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || !is_object($conf))
|
||||
{
|
||||
if (empty($conf) || !is_object($conf)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
@ -30,8 +29,12 @@ echo $this->control->tpl['showhead'];
|
||||
|
||||
dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']);
|
||||
|
||||
if (!empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user'];
|
||||
if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?>
|
||||
if (!empty($this->control->tpl['action_create_user'])) {
|
||||
echo $this->control->tpl['action_create_user'];
|
||||
}
|
||||
if (!empty($this->control->tpl['action_delete'])) {
|
||||
echo $this->control->tpl['action_delete'];
|
||||
} ?>
|
||||
|
||||
<table class="border allwidth">
|
||||
|
||||
|
||||
@ -71,24 +71,26 @@ $socialnetworks = getArrayOfSocialNetworks();
|
||||
$object->getCanvas($id);
|
||||
$objcanvas = null;
|
||||
$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas"));
|
||||
if (!empty($canvas))
|
||||
{
|
||||
if (!empty($canvas)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
|
||||
$objcanvas = new Canvas($db, $action);
|
||||
$objcanvas->getCanvas('contact', 'contactcard', $canvas);
|
||||
}
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('contactcard', 'globalcard'));
|
||||
|
||||
if ($id > 0) $object->fetch($id);
|
||||
if ($id > 0) {
|
||||
$object->fetch($id);
|
||||
}
|
||||
|
||||
if (!($object->id > 0) && $action == 'view')
|
||||
{
|
||||
if (!($object->id > 0) && $action == 'view') {
|
||||
$langs->load("errors");
|
||||
print($langs->trans('ErrorRecordNotFound'));
|
||||
exit;
|
||||
@ -100,36 +102,32 @@ if (!($object->id > 0) && $action == 'view')
|
||||
|
||||
$parameters = array('id'=>$id, 'objcanvas'=>$objcanvas);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
|
||||
{
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Creation utilisateur depuis contact
|
||||
if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer)
|
||||
{
|
||||
if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) {
|
||||
// Recuperation contact actuel
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$db->begin();
|
||||
|
||||
// Creation user
|
||||
$nuser = new User($db);
|
||||
$result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha)
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha)
|
||||
if ($result2)
|
||||
{
|
||||
if ($result2) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$error = $nuser->error; $errors = $nuser->errors;
|
||||
@ -146,11 +144,9 @@ if (empty($reshook))
|
||||
|
||||
|
||||
// Confirmation desactivation
|
||||
if ($action == 'disable')
|
||||
{
|
||||
if ($action == 'disable') {
|
||||
$object->fetch($id);
|
||||
if ($object->setstatus(0) < 0)
|
||||
{
|
||||
if ($object->setstatus(0) < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
|
||||
@ -159,11 +155,9 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Confirmation activation
|
||||
if ($action == 'enable')
|
||||
{
|
||||
if ($action == 'enable') {
|
||||
$object->fetch($id);
|
||||
if ($object->setstatus(1) < 0)
|
||||
{
|
||||
if ($object->setstatus(1) < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
|
||||
@ -172,11 +166,12 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Add contact
|
||||
if ($action == 'add' && $user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($action == 'add' && $user->rights->societe->contact->creer) {
|
||||
$db->begin();
|
||||
|
||||
if ($canvas) $object->canvas = $canvas;
|
||||
if ($canvas) {
|
||||
$object->canvas = $canvas;
|
||||
}
|
||||
|
||||
$object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity);
|
||||
$object->socid = GETPOST("socid", 'int');
|
||||
@ -221,8 +216,7 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
if ($ret < 0)
|
||||
{
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
$action = 'create';
|
||||
}
|
||||
@ -233,8 +227,7 @@ if (empty($reshook))
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if (!empty($object->email) && !isValidEMail($object->email))
|
||||
{
|
||||
if (!empty($object->email) && !isValidEMail($object->email)) {
|
||||
$langs->load("errors");
|
||||
$error++;
|
||||
$errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha'));
|
||||
@ -279,11 +272,13 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($error) && $id > 0)
|
||||
{
|
||||
if (empty($error) && $id > 0) {
|
||||
$db->commit();
|
||||
if (!empty($backtopage)) $url = $backtopage;
|
||||
else $url = 'card.php?id='.$id;
|
||||
if (!empty($backtopage)) {
|
||||
$url = $backtopage;
|
||||
} else {
|
||||
$url = 'card.php?id='.$id;
|
||||
}
|
||||
header("Location: ".$url);
|
||||
exit;
|
||||
} else {
|
||||
@ -291,8 +286,7 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer)
|
||||
{
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) {
|
||||
$result = $object->fetch($id);
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
@ -313,10 +307,8 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'update' && empty($cancel) && $user->rights->societe->contact->creer)
|
||||
{
|
||||
if (!GETPOST("lastname", 'alpha'))
|
||||
{
|
||||
if ($action == 'update' && empty($cancel) && $user->rights->societe->contact->creer) {
|
||||
if (!GETPOST("lastname", 'alpha')) {
|
||||
$error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
|
||||
$action = 'edit';
|
||||
}
|
||||
@ -327,16 +319,14 @@ if (empty($reshook))
|
||||
$action = 'edit';
|
||||
}
|
||||
|
||||
if (!empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)))
|
||||
{
|
||||
if (!empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
|
||||
$langs->load("errors");
|
||||
$error++;
|
||||
$errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha'));
|
||||
$action = 'edit';
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$contactid = GETPOST("contactid", 'int');
|
||||
$object->fetch($contactid);
|
||||
$object->fetchRoles($contactid);
|
||||
@ -344,27 +334,22 @@ if (empty($reshook))
|
||||
// Photo save
|
||||
$dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos";
|
||||
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
||||
if (GETPOST('deletephoto') && $object->photo)
|
||||
{
|
||||
if (GETPOST('deletephoto') && $object->photo) {
|
||||
$fileimg = $dir.'/'.$object->photo;
|
||||
$dirthumbs = $dir.'/thumbs';
|
||||
dol_delete_file($fileimg);
|
||||
dol_delete_dir_recursive($dirthumbs);
|
||||
$object->photo = '';
|
||||
}
|
||||
if ($file_OK)
|
||||
{
|
||||
if (image_format_supported($_FILES['photo']['name']) > 0)
|
||||
{
|
||||
if ($file_OK) {
|
||||
if (image_format_supported($_FILES['photo']['name']) > 0) {
|
||||
dol_mkdir($dir);
|
||||
|
||||
if (@is_dir($dir))
|
||||
{
|
||||
if (@is_dir($dir)) {
|
||||
$newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
|
||||
|
||||
if (!$result > 0)
|
||||
{
|
||||
if (!$result > 0) {
|
||||
$errors[] = "ErrorFailedToSaveFile";
|
||||
} else {
|
||||
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
@ -377,8 +362,7 @@ if (empty($reshook))
|
||||
$errors[] = "ErrorBadImageFormat";
|
||||
}
|
||||
} else {
|
||||
switch ($_FILES['photo']['error'])
|
||||
{
|
||||
switch ($_FILES['photo']['error']) {
|
||||
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
|
||||
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
|
||||
$errors[] = "ErrorFileSizeTooLarge";
|
||||
@ -433,10 +417,11 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
if ($ret < 0) $error++;
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$result = $object->update($contactid, $user);
|
||||
|
||||
if ($result > 0) {
|
||||
@ -445,8 +430,7 @@ if (empty($reshook))
|
||||
$object->setCategories($categories);
|
||||
|
||||
// Update mass emailing flag into table mailing_unsubscribe
|
||||
if (GETPOSTISSET('no_email') && $object->email)
|
||||
{
|
||||
if (GETPOSTISSET('no_email') && $object->email) {
|
||||
$no_email = GETPOST('no_email', 'int');
|
||||
$result=$object->setNoEmail($no_email);
|
||||
if ($result<0) {
|
||||
@ -465,31 +449,31 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && empty($errors))
|
||||
{
|
||||
if (!empty($backtopage))
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
if (!$error && empty($errors)) {
|
||||
if (!empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer) {
|
||||
$object->fetch($id);
|
||||
$object->fk_prospectlevel = GETPOST('prospect_contact_level_id', 'alpha');
|
||||
$result = $object->update($object->id, $user);
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// set communication status
|
||||
if ($action == 'setstcomm')
|
||||
{
|
||||
if ($action == 'setstcomm') {
|
||||
$object->fetch($id);
|
||||
$object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact');
|
||||
$result = $object->update($object->id, $user);
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Actions to send emails
|
||||
@ -506,7 +490,9 @@ if (empty($reshook))
|
||||
|
||||
|
||||
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
|
||||
$title = $object->lastname;
|
||||
}
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
@ -515,24 +501,23 @@ $formcompany = new FormCompany($db);
|
||||
|
||||
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||
|
||||
if ($socid > 0)
|
||||
{
|
||||
if ($socid > 0) {
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($socid);
|
||||
}
|
||||
|
||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
{
|
||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
if (empty($object->error) && $id)
|
||||
{
|
||||
$object = new Contact($db);
|
||||
$result = $object->fetch($id);
|
||||
if ($result <= 0) dol_print_error('', $object->error);
|
||||
}
|
||||
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
|
||||
if (empty($object->error) && $id) {
|
||||
$object = new Contact($db);
|
||||
$result = $object->fetch($id);
|
||||
if ($result <= 0) {
|
||||
dol_print_error('', $object->error);
|
||||
}
|
||||
}
|
||||
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
|
||||
$objcanvas->display_canvas($action); // Show template
|
||||
} else {
|
||||
// -----------------------------------------
|
||||
@ -540,20 +525,17 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// -----------------------------------------
|
||||
|
||||
// Confirm deleting contact
|
||||
if ($user->rights->societe->contact->supprimer)
|
||||
{
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($user->rights->societe->contact->supprimer) {
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Onglets
|
||||
*/
|
||||
* Onglets
|
||||
*/
|
||||
$head = array();
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
// Si edition contact deja existant
|
||||
$object = new Contact($db);
|
||||
$res = $object->fetch($id, $user);
|
||||
@ -569,21 +551,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||
}
|
||||
|
||||
if ($user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($user->rights->societe->contact->creer) {
|
||||
if ($action == 'create') {
|
||||
/*
|
||||
* Fiche en mode creation
|
||||
*/
|
||||
* Fiche en mode creation
|
||||
*/
|
||||
$object->canvas = $canvas;
|
||||
|
||||
$object->state_id = GETPOST("state_id");
|
||||
|
||||
// We set country_id, country_code and label for the selected country
|
||||
$object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
|
||||
if ($object->country_id)
|
||||
{
|
||||
if ($object->country_id) {
|
||||
$tmparray = getCountry($object->country_id, 'all');
|
||||
$object->country_code = $tmparray['code'];
|
||||
$object->country = $tmparray['label'];
|
||||
@ -596,8 +575,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// Show errors
|
||||
dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print "\n".'<script type="text/javascript" language="javascript">'."\n";
|
||||
print 'jQuery(document).ready(function () {
|
||||
jQuery("#selectcountry_id").change(function() {
|
||||
@ -643,10 +621,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '</tr>';
|
||||
|
||||
// Company
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if ($socid > 0)
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
if ($socid > 0) {
|
||||
print '<tr><td><label for="socid">'.$langs->trans("ThirdParty").'</label></td>';
|
||||
print '<td colspan="3" class="maxwidthonsmartphone">';
|
||||
print $objsoc->getNomUrl(1, 'contact');
|
||||
@ -670,17 +646,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<td colspan="3"><input name="poste" id="title" type="text" class="minwidth100" maxlength="255" value="'.dol_escape_htmltag(GETPOSTISSET("poste") ?GETPOST("poste", 'alphanohtml') : $object->poste).'"></td>';
|
||||
|
||||
$colspan = 3;
|
||||
if ($conf->use_javascript_ajax && $socid > 0) $colspan = 2;
|
||||
if ($conf->use_javascript_ajax && $socid > 0) {
|
||||
$colspan = 2;
|
||||
}
|
||||
|
||||
// Address
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) {
|
||||
$object->address = $objsoc->address; // Predefined with third party
|
||||
}
|
||||
print '<tr><td><label for="address">'.$langs->trans("Address").'</label></td>';
|
||||
print '<td colspan="'.$colspan.'"><textarea class="flat quatrevingtpercent" name="address" id="address" rows="'.ROWS_2.'">'.(GETPOST("address", 'alpha') ?GETPOST("address", 'alpha') : $object->address).'</textarea></td>';
|
||||
|
||||
if ($conf->use_javascript_ajax && $socid > 0)
|
||||
{
|
||||
if ($conf->use_javascript_ajax && $socid > 0) {
|
||||
$rowspan = 3;
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++;
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
|
||||
$rowspan++;
|
||||
}
|
||||
|
||||
print '<td class="valignmiddle center" rowspan="'.$rowspan.'">';
|
||||
print '<a href="#" id="copyaddressfromsoc">'.$langs->trans('CopyAddressFromSoc').'</a>';
|
||||
@ -689,8 +670,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '</tr>';
|
||||
|
||||
// Zip / Town
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) {
|
||||
$object->zip = $objsoc->zip; // Predefined with third party
|
||||
}
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) {
|
||||
$object->town = $objsoc->town; // Predefined with third party
|
||||
}
|
||||
print '<tr><td><label for="zipcode">'.$langs->trans("Zip").'</label> / <label for="town">'.$langs->trans("Town").'</label></td><td colspan="'.$colspan.'" class="maxwidthonsmartphone">';
|
||||
print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ? GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' ';
|
||||
print $formcompany->select_ziptown((GETPOST("town", 'alpha') ? GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
|
||||
@ -700,21 +685,20 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<tr><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td colspan="'.$colspan.'" class="maxwidthonsmartphone">';
|
||||
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
|
||||
print $form->select_country((GETPOST("country_id", 'alpha') ? GETPOST("country_id", 'alpha') : $object->country_id), 'country_id');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
if ($user->admin) {
|
||||
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// State
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
|
||||
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) {
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('Region-State').'</label></td><td colspan="'.$colspan.'" class="maxwidthonsmartphone">';
|
||||
} else {
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('State').'</label></td><td colspan="'.$colspan.'" class="maxwidthonsmartphone">';
|
||||
}
|
||||
|
||||
if ($object->country_id)
|
||||
{
|
||||
if ($object->country_id) {
|
||||
print $formcompany->select_state(GETPOST("state_id", 'alpha') ? GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id');
|
||||
} else {
|
||||
print $countrynotdefined;
|
||||
@ -722,15 +706,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) {
|
||||
$object->phone_pro = $objsoc->phone; // Predefined with third party
|
||||
}
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) {
|
||||
$object->fax = $objsoc->fax; // Predefined with third party
|
||||
}
|
||||
|
||||
// Phone / Fax
|
||||
print '<tr><td>'.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).'</td>';
|
||||
print '<td>';
|
||||
print img_picto('', 'object_phoning');
|
||||
print '<input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" value="'.(GETPOSTISSET('phone_pro') ? GETPOST('phone_pro', 'alpha') : $object->phone_pro).'"></td>';
|
||||
if ($conf->browser->layout == 'phone') print '</tr><tr>';
|
||||
if ($conf->browser->layout == 'phone') {
|
||||
print '</tr><tr>';
|
||||
}
|
||||
print '<td>'.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).'</td>';
|
||||
print '<td>';
|
||||
print img_picto('', 'object_phoning');
|
||||
@ -740,14 +730,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<td>';
|
||||
print img_picto('', 'object_phoning_mobile');
|
||||
print '<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td>';
|
||||
if ($conf->browser->layout == 'phone') print '</tr><tr>';
|
||||
if ($conf->browser->layout == 'phone') {
|
||||
print '</tr><tr>';
|
||||
}
|
||||
print '<td>'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'</td>';
|
||||
print '<td>';
|
||||
print img_picto('', 'object_phoning_fax');
|
||||
print '<input type="text" name="fax" id="fax" class="maxwidth200" value="'.(GETPOSTISSET('fax') ? GETPOST('fax', 'alpha') : $object->fax).'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) {
|
||||
$object->email = $objsoc->email; // Predefined with third party
|
||||
}
|
||||
|
||||
// Email
|
||||
print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').'</td>';
|
||||
@ -757,10 +751,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '</tr>';
|
||||
|
||||
//Unsubscribe
|
||||
if (!empty($conf->mailing->enabled))
|
||||
{
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1)
|
||||
{
|
||||
if (!empty($conf->mailing->enabled)) {
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1) {
|
||||
print "\n".'<script type="text/javascript" language="javascript">'."\n";
|
||||
print '$(document).ready(function () {
|
||||
$("#email").keyup(function() {
|
||||
@ -773,8 +765,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
})'."\n";
|
||||
print '</script>'."\n";
|
||||
}
|
||||
if (!GETPOSTISSET("no_email") && !empty($object->email))
|
||||
{
|
||||
if (!GETPOSTISSET("no_email") && !empty($object->email)) {
|
||||
$result=$object->getNoEmail();
|
||||
if ($result<0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -829,8 +820,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3);
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
print $object->showOptionals($extrafields, 'edit', $parameters);
|
||||
}
|
||||
|
||||
@ -846,8 +836,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// Date To Birth
|
||||
print '<tr><td><label for="birthday">'.$langs->trans("DateOfBirth").'</label></td><td>';
|
||||
$form = new Form($db);
|
||||
if ($object->birthday)
|
||||
{
|
||||
if ($object->birthday) {
|
||||
print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0);
|
||||
} else {
|
||||
print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0);
|
||||
@ -855,8 +844,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '</td>';
|
||||
|
||||
print '<td><label for="birthday_alert">'.$langs->trans("Alert").'</label>: ';
|
||||
if ($object->birthday_alert)
|
||||
{
|
||||
if ($object->birthday_alert) {
|
||||
print '<input type="checkbox" name="birthday_alert" id="birthday_alert" checked>';
|
||||
} else {
|
||||
print '<input type="checkbox" name="birthday_alert" id="birthday_alert">';
|
||||
@ -870,8 +858,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" name="add" value="'.$langs->trans("Add").'">';
|
||||
if (!empty($backtopage))
|
||||
{
|
||||
if (!empty($backtopage)) {
|
||||
print ' ';
|
||||
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
} else {
|
||||
@ -883,12 +870,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print "</form>";
|
||||
} elseif ($action == 'edit' && !empty($id)) {
|
||||
/*
|
||||
* Fiche en mode edition
|
||||
*/
|
||||
* Fiche en mode edition
|
||||
*/
|
||||
|
||||
// We set country_id, and country_code label of the chosen country
|
||||
if (GETPOSTISSET("country_id") || $object->country_id)
|
||||
{
|
||||
if (GETPOSTISSET("country_id") || $object->country_id) {
|
||||
$tmparray = getCountry($object->country_id, 'all');
|
||||
$object->country_code = $tmparray['code'];
|
||||
$object->country = $tmparray['label'];
|
||||
@ -900,8 +886,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// Show errors
|
||||
dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print "\n".'<script type="text/javascript" language="javascript">'."\n";
|
||||
print 'jQuery(document).ready(function () {
|
||||
jQuery("#selectcountry_id").change(function() {
|
||||
@ -930,19 +915,20 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<input type="hidden" name="contactid" value="'.$object->id.'">';
|
||||
print '<input type="hidden" name="old_lastname" value="'.$object->lastname.'">';
|
||||
print '<input type="hidden" name="old_firstname" value="'.$object->firstname.'">';
|
||||
if (!empty($backtopage)) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
if (!empty($backtopage)) {
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
}
|
||||
|
||||
print dol_get_fiche_head($head, 'card', $title, 0, 'contact');
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// Ref/ID
|
||||
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
|
||||
print '<tr><td>'.$langs->trans("ID").'</td><td colspan="3">';
|
||||
print $object->ref;
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
// Lastname
|
||||
print '<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</label></td>';
|
||||
@ -955,8 +941,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '</tr>';
|
||||
|
||||
// Company
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
print '<tr><td><label for="socid">'.$langs->trans("ThirdParty").'</label></td>';
|
||||
print '<td colspan="3" class="maxwidthonsmartphone">';
|
||||
print img_picto('', 'company').$form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty"));
|
||||
@ -979,7 +964,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<div class="paddingrightonly valignmiddle inline-block quatrevingtpercent">';
|
||||
print '<textarea class="flat minwidth200 centpercent" name="address" id="address">'.(GETPOSTISSET("address") ? GETPOST("address", 'nohtml') : $object->address).'</textarea>';
|
||||
print '</div><div class="paddingrightonly valignmiddle inline-block">';
|
||||
if ($conf->use_javascript_ajax) print '<a href="#" id="copyaddressfromsoc">'.$langs->trans('CopyAddressFromSoc').'</a><br>';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print '<a href="#" id="copyaddressfromsoc">'.$langs->trans('CopyAddressFromSoc').'</a><br>';
|
||||
}
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
|
||||
@ -993,14 +980,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<tr><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td colspan="3" class="maxwidthonsmartphone">';
|
||||
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
|
||||
print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id") : $object->country_id, 'country_id');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
if ($user->admin) {
|
||||
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// State
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
|
||||
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) {
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('Region-State').'</label></td><td colspan="3" class="maxwidthonsmartphone">';
|
||||
} else {
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('State').'</label></td><td colspan="3" class="maxwidthonsmartphone">';
|
||||
@ -1034,8 +1021,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<td>';
|
||||
print img_picto('', 'object_email');
|
||||
print '<input type="text" name="email" id="email" class="maxwidth100onsmartphone quatrevingtpercent" value="'.(GETPOSTISSET('email') ?GETPOST('email', 'alpha') : $object->email).'"></td>';
|
||||
if (!empty($conf->mailing->enabled))
|
||||
{
|
||||
if (!empty($conf->mailing->enabled)) {
|
||||
$langs->load("mails");
|
||||
print '<td class="nowrap">'.$langs->trans("NbOfEMailingsSend").'</td>';
|
||||
print '<td>'.$object->getNbOfEMailings().'</td>';
|
||||
@ -1045,10 +1031,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '</tr>';
|
||||
|
||||
// Unsubscribe
|
||||
if (!empty($conf->mailing->enabled))
|
||||
{
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1)
|
||||
{
|
||||
if (!empty($conf->mailing->enabled)) {
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1) {
|
||||
print "\n".'<script type="text/javascript" language="javascript">'."\n";
|
||||
|
||||
print '
|
||||
@ -1067,8 +1051,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
})'."\n";
|
||||
print '</script>'."\n";
|
||||
}
|
||||
if (!GETPOSTISSET("no_email") && !empty($object->email))
|
||||
{
|
||||
if (!GETPOSTISSET("no_email") && !empty($object->email)) {
|
||||
$result=$object->getNoEmail();
|
||||
if ($result<0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -1145,36 +1128,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$parameters = array('colspan' => ' colspan="3"', 'cols'=> '3');
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
print $object->showOptionals($extrafields, 'edit', $parameters);
|
||||
}
|
||||
|
||||
$object->load_ref_elements();
|
||||
|
||||
if (!empty($conf->commande->enabled))
|
||||
{
|
||||
if (!empty($conf->commande->enabled)) {
|
||||
print '<tr><td>'.$langs->trans("ContactForOrders").'</td><td colspan="3">';
|
||||
print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder");
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (!empty($conf->propal->enabled))
|
||||
{
|
||||
if (!empty($conf->propal->enabled)) {
|
||||
print '<tr><td>'.$langs->trans("ContactForProposals").'</td><td colspan="3">';
|
||||
print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal");
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (!empty($conf->contrat->enabled))
|
||||
{
|
||||
if (!empty($conf->contrat->enabled)) {
|
||||
print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">';
|
||||
print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract");
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (!empty($conf->facture->enabled))
|
||||
{
|
||||
if (!empty($conf->facture->enabled)) {
|
||||
print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">';
|
||||
print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
|
||||
print '</td></tr>';
|
||||
@ -1182,12 +1160,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
|
||||
// Login Dolibarr
|
||||
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
|
||||
if ($object->user_id)
|
||||
{
|
||||
if ($object->user_id) {
|
||||
$dolibarr_user = new User($db);
|
||||
$result = $dolibarr_user->fetch($object->user_id);
|
||||
print $dolibarr_user->getLoginUrl(1);
|
||||
} else print $langs->trans("NoDolibarrAccess");
|
||||
} else {
|
||||
print $langs->trans("NoDolibarrAccess");
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Photo
|
||||
@ -1199,7 +1178,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print "<br>\n";
|
||||
}
|
||||
print '<table class="nobordernopadding">';
|
||||
if ($object->photo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||
if ($object->photo) {
|
||||
print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||
}
|
||||
//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
||||
print '</table>';
|
||||
@ -1226,8 +1207,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$action = 'presend';
|
||||
}
|
||||
|
||||
if (!empty($id) && $action != 'edit' && $action != 'create')
|
||||
{
|
||||
if (!empty($id) && $action != 'edit' && $action != 'create') {
|
||||
$objsoc = new Societe($db);
|
||||
|
||||
// View mode
|
||||
@ -1237,15 +1217,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
|
||||
print dol_get_fiche_head($head, 'card', $title, -1, 'contact');
|
||||
|
||||
if ($action == 'create_user')
|
||||
{
|
||||
if ($action == 'create_user') {
|
||||
// Full firstname and lastname separated with a dot : firstname.lastname
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
$login = dol_buildlogin($object->lastname, $object->firstname);
|
||||
|
||||
$generated_password = '';
|
||||
if (!$ldap_sid) // TODO ldap_sid ?
|
||||
{
|
||||
if (!$ldap_sid) { // TODO ldap_sid ?
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$generated_password = getRandomPassword(false);
|
||||
}
|
||||
@ -1258,10 +1236,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
//array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External')))
|
||||
);
|
||||
$text = $langs->trans("ConfirmCreateContact").'<br>';
|
||||
if (!empty($conf->societe->enabled))
|
||||
{
|
||||
if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser");
|
||||
else $text .= $langs->trans("UserWillBeInternalUser");
|
||||
if (!empty($conf->societe->enabled)) {
|
||||
if ($object->socid > 0) {
|
||||
$text .= $langs->trans("UserWillBeExternalUser");
|
||||
} else {
|
||||
$text .= $langs->trans("UserWillBeInternalUser");
|
||||
}
|
||||
}
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
|
||||
}
|
||||
@ -1269,13 +1249,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
$objsoc->fetch($object->socid);
|
||||
// Thirdparty
|
||||
$morehtmlref .= $langs->trans('ThirdParty').' : ';
|
||||
if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
|
||||
else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
if ($objsoc->id > 0) {
|
||||
$morehtmlref .= $objsoc->getNomUrl(1, 'contact');
|
||||
} else {
|
||||
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
}
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
@ -1297,16 +1279,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td>'.$object->poste.'</td></tr>';
|
||||
|
||||
// Email
|
||||
if (!empty($conf->mailing->enabled))
|
||||
{
|
||||
if (!empty($conf->mailing->enabled)) {
|
||||
$langs->load("mails");
|
||||
print '<tr><td>'.$langs->trans("NbOfEMailingsSend").'</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?filteremail='.urlencode($object->email).'">'.$object->getNbOfEMailings().'</a></td></tr>';
|
||||
}
|
||||
|
||||
// Unsubscribe opt-out
|
||||
if (!empty($conf->mailing->enabled))
|
||||
{
|
||||
if (!empty($conf->mailing->enabled)) {
|
||||
$result=$object->getNoEmail();
|
||||
if ($result<0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -1324,8 +1304,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
|
||||
if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3)
|
||||
{
|
||||
if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) {
|
||||
print '<br>';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
@ -1336,7 +1315,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('ProspectLevel');
|
||||
print '<td>';
|
||||
if ($action != 'editlevel' && $user->rights->societe->contact->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlevel&id='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>';
|
||||
if ($action != 'editlevel' && $user->rights->societe->contact->creer) {
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlevel&id='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editlevel') {
|
||||
@ -1354,8 +1335,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<div class="floatright">';
|
||||
foreach ($object->cacheprospectstatus as $key => $val) {
|
||||
$titlealt = 'default';
|
||||
if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
|
||||
if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
|
||||
if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
|
||||
$titlealt = $val['label'];
|
||||
}
|
||||
if ($object->stcomm_id != $val['id']) {
|
||||
print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
|
||||
}
|
||||
}
|
||||
print '</div></td></tr>';
|
||||
|
||||
@ -1391,45 +1376,48 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
|
||||
$object->load_ref_elements();
|
||||
|
||||
if (!empty($conf->propal->enabled))
|
||||
{
|
||||
if (!empty($conf->propal->enabled)) {
|
||||
print '<tr><td class="titlefield">'.$langs->trans("ContactForProposals").'</td><td colspan="3">';
|
||||
print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal");
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled))
|
||||
{
|
||||
if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) {
|
||||
print '<tr><td>';
|
||||
if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders");
|
||||
if (!empty($conf->expedition->enabled)) {
|
||||
print $langs->trans("ContactForOrdersOrShipments");
|
||||
} else {
|
||||
print $langs->trans("ContactForOrders");
|
||||
}
|
||||
print '</td><td colspan="3">';
|
||||
$none = $langs->trans("NoContactForAnyOrder");
|
||||
if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); }
|
||||
if (!empty($conf->expedition->enabled)) {
|
||||
$none = $langs->trans("NoContactForAnyOrderOrShipments");
|
||||
}
|
||||
print $object->ref_commande ? $object->ref_commande : $none;
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (!empty($conf->contrat->enabled))
|
||||
{
|
||||
if (!empty($conf->contrat->enabled)) {
|
||||
print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">';
|
||||
print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract");
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (!empty($conf->facture->enabled))
|
||||
{
|
||||
if (!empty($conf->facture->enabled)) {
|
||||
print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">';
|
||||
print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
|
||||
if ($object->user_id)
|
||||
{
|
||||
if ($object->user_id) {
|
||||
$dolibarr_user = new User($db);
|
||||
$result = $dolibarr_user->fetch($object->user_id);
|
||||
print $dolibarr_user->getLoginUrl(1);
|
||||
} else print $langs->trans("NoDolibarrAccess");
|
||||
} else {
|
||||
print $langs->trans("NoDolibarrAccess");
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>';
|
||||
@ -1452,11 +1440,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && $action != 'presend')
|
||||
{
|
||||
if (empty($reshook) && $action != 'presend') {
|
||||
if (empty($user->socid)) {
|
||||
if (!empty($object->email))
|
||||
{
|
||||
if (!empty($object->email)) {
|
||||
$langs->load("mails");
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
|
||||
} else {
|
||||
@ -1465,30 +1451,25 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($user->rights->societe->contact->creer) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
|
||||
if (!$object->user_id && $user->rights->user->user->creer)
|
||||
{
|
||||
if (!$object->user_id && $user->rights->user->user->creer) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
|
||||
}
|
||||
|
||||
// Activer
|
||||
if ($object->statut == 0 && $user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($object->statut == 0 && $user->rights->societe->contact->creer) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable">'.$langs->trans("Reactivate").'</a>';
|
||||
}
|
||||
// Desactiver
|
||||
if ($object->statut == 1 && $user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($object->statut == 1 && $user->rights->societe->contact->creer) {
|
||||
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=disable&id='.$object->id.'">'.$langs->trans("DisableUser").'</a>';
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($user->rights->societe->contact->supprimer)
|
||||
{
|
||||
if ($user->rights->societe->contact->supprimer) {
|
||||
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().''.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
@ -1500,8 +1481,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$action = 'presend';
|
||||
}
|
||||
|
||||
if ($action != 'presend')
|
||||
{
|
||||
if ($action != 'presend') {
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
@ -473,40 +473,35 @@ class Contact extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople");
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ...
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('CONTACT_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
@ -558,13 +553,20 @@ class Contact extends CommonObject
|
||||
$this->town = (empty($this->town) ? '' : trim($this->town));
|
||||
$this->setUpperOrLowerCase();
|
||||
$this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
|
||||
if (empty($this->statut)) $this->statut = 0;
|
||||
if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility
|
||||
if (empty($this->statut)) {
|
||||
$this->statut = 0;
|
||||
}
|
||||
if (empty($this->civility_code) && !is_numeric($this->civility_id)) {
|
||||
$this->civility_code = $this->civility_id; // For backward compatibility
|
||||
}
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET ";
|
||||
if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',";
|
||||
elseif ($this->socid == -1) $sql .= " fk_soc=null,";
|
||||
if ($this->socid > 0) {
|
||||
$sql .= " fk_soc='".$this->db->escape($this->socid)."',";
|
||||
} elseif ($this->socid == -1) {
|
||||
$sql .= " fk_soc=null,";
|
||||
}
|
||||
$sql .= " civility='".$this->db->escape($this->civility_code)."'";
|
||||
$sql .= ", lastname='".$this->db->escape($this->lastname)."'";
|
||||
$sql .= ", firstname='".$this->db->escape($this->firstname)."'";
|
||||
@ -586,8 +588,7 @@ class Contact extends CommonObject
|
||||
$sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "null");
|
||||
$sql .= ", priv = '".$this->db->escape($this->priv)."'";
|
||||
$sql .= ", fk_prospectcontactlevel = '".$this->db->escape($this->fk_prospectlevel)."'";
|
||||
if (isset($this->stcomm_id))
|
||||
{
|
||||
if (isset($this->stcomm_id)) {
|
||||
$sql .= ", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id : "0");
|
||||
}
|
||||
$sql .= ", statut = ".$this->db->escape($this->statut);
|
||||
@ -598,8 +599,7 @@ class Contact extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
unset($this->country_code);
|
||||
unset($this->country);
|
||||
unset($this->state_code);
|
||||
@ -608,25 +608,21 @@ class Contact extends CommonObject
|
||||
$action = 'update';
|
||||
|
||||
// Actions on extra fields
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$result = $this->updateRoles();
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && $this->user_id > 0)
|
||||
{
|
||||
if (!$error && $this->user_id > 0) {
|
||||
// If contact is linked to a user
|
||||
$tmpobj = new User($this->db);
|
||||
$tmpobj->fetch($this->user_id);
|
||||
@ -685,14 +681,18 @@ class Contact extends CommonObject
|
||||
// }
|
||||
if ($usermustbemodified) {
|
||||
$result = $tmpobj->update($user, 0, 1, 1, 1);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('CONTACT_MODIFY', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -759,34 +759,69 @@ class Contact extends CommonObject
|
||||
$this->fullname = $this->getFullName($langs);
|
||||
|
||||
// Fields
|
||||
if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
|
||||
if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
|
||||
if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
|
||||
if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
|
||||
}
|
||||
if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
|
||||
}
|
||||
if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
|
||||
}
|
||||
|
||||
if ($this->poste) $info["title"] = $this->poste;
|
||||
if ($this->poste) {
|
||||
$info["title"] = $this->poste;
|
||||
}
|
||||
if ($this->socid > 0) {
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->socid);
|
||||
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_COMPANY] = $soc->name;
|
||||
if ($soc->client == 1) $info["businessCategory"] = "Customers";
|
||||
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
|
||||
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
|
||||
if ($soc->client == 1) {
|
||||
$info["businessCategory"] = "Customers";
|
||||
}
|
||||
if ($soc->client == 2) {
|
||||
$info["businessCategory"] = "Prospects";
|
||||
}
|
||||
if ($soc->fournisseur == 1) {
|
||||
$info["businessCategory"] = "Suppliers";
|
||||
}
|
||||
}
|
||||
if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
|
||||
}
|
||||
if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
|
||||
}
|
||||
if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
|
||||
}
|
||||
if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
|
||||
}
|
||||
if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
|
||||
}
|
||||
if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
|
||||
}
|
||||
if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
|
||||
}
|
||||
if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
|
||||
}
|
||||
if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
|
||||
}
|
||||
if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
|
||||
}
|
||||
if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) {
|
||||
$info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
|
||||
}
|
||||
if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
|
||||
if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
|
||||
if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
|
||||
if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
|
||||
if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
|
||||
if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
|
||||
if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
|
||||
if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
|
||||
if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
|
||||
if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
|
||||
if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
|
||||
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
|
||||
{
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') {
|
||||
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
|
||||
|
||||
$info['uidnumber'] = $this->id;
|
||||
@ -805,8 +840,12 @@ class Contact extends CommonObject
|
||||
|
||||
$info["phpgwContactOwner"] = $this->egroupware_id;
|
||||
|
||||
if ($this->email) $info["rfc822Mailbox"] = $this->email;
|
||||
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
|
||||
if ($this->email) {
|
||||
$info["rfc822Mailbox"] = $this->email;
|
||||
}
|
||||
if ($this->phone_mobile) {
|
||||
$info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
|
||||
}
|
||||
}
|
||||
|
||||
return $info;
|
||||
@ -834,13 +873,14 @@ class Contact extends CommonObject
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET";
|
||||
$sql .= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null");
|
||||
$sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null");
|
||||
if ($user) $sql .= ", fk_user_modif=".$user->id;
|
||||
if ($user) {
|
||||
$sql .= ", fk_user_modif=".$user->id;
|
||||
}
|
||||
$sql .= " WHERE rowid=".$this->db->escape($id);
|
||||
|
||||
dol_syslog(get_class($this)."::update_perso this->birthday=".$this->birthday." -", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
@ -875,7 +915,9 @@ class Contact extends CommonObject
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('CONTACT_MODIFY', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -906,8 +948,7 @@ class Contact extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::fetch id=".$id." ref_ext=".$ref_ext." email=".$email, LOG_DEBUG);
|
||||
|
||||
if (empty($id) && empty($ref_ext) && empty($email))
|
||||
{
|
||||
if (empty($id) && empty($ref_ext) && empty($email)) {
|
||||
$this->error = 'BadParameter';
|
||||
return -1;
|
||||
}
|
||||
@ -936,8 +977,9 @@ class Contact extends CommonObject
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id';
|
||||
if ($id) $sql .= " WHERE c.rowid = ".((int) $id);
|
||||
else {
|
||||
if ($id) {
|
||||
$sql .= " WHERE c.rowid = ".((int) $id);
|
||||
} else {
|
||||
$sql .= " WHERE c.entity IN (".getEntity($this->element).")";
|
||||
if ($ref_ext) {
|
||||
$sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'";
|
||||
@ -948,17 +990,14 @@ class Contact extends CommonObject
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num > 1)
|
||||
{
|
||||
if ($num > 1) {
|
||||
$this->error = 'Fetch found several records. Rename one of contact to avoid duplicate.';
|
||||
dol_syslog($this->error, LOG_ERR);
|
||||
|
||||
return 2;
|
||||
} elseif ($num) // $num = 1
|
||||
{
|
||||
} elseif ($num) { // $num = 1
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
@ -1030,10 +1069,8 @@ class Contact extends CommonObject
|
||||
$sql .= " WHERE u.fk_socpeople = ".$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$uobj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->user_id = $uobj->rowid;
|
||||
@ -1049,17 +1086,14 @@ class Contact extends CommonObject
|
||||
$this->fetch_optionals();
|
||||
|
||||
// Load also alerts of this user
|
||||
if ($user)
|
||||
{
|
||||
if ($user) {
|
||||
$sql = "SELECT fk_user";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user_alert";
|
||||
$sql .= " WHERE fk_user = ".$user->id." AND fk_contact = ".$this->db->escape($id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->birthday_alert = 1;
|
||||
@ -1102,11 +1136,9 @@ class Contact extends CommonObject
|
||||
{
|
||||
unset($this->gender);
|
||||
|
||||
if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR')))
|
||||
{
|
||||
if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR'))) {
|
||||
$this->gender = 'man';
|
||||
} elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE')))
|
||||
{
|
||||
} elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE'))) {
|
||||
$this->gender = 'woman';
|
||||
}
|
||||
}
|
||||
@ -1135,16 +1167,18 @@ class Contact extends CommonObject
|
||||
dol_syslog(get_class($this)."::load_ref_elements", LOG_DEBUG);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
if ($obj->nb)
|
||||
{
|
||||
if ($obj->element == 'facture') $this->ref_facturation = $obj->nb;
|
||||
elseif ($obj->element == 'contrat') $this->ref_contrat = $obj->nb;
|
||||
elseif ($obj->element == 'commande') $this->ref_commande = $obj->nb;
|
||||
elseif ($obj->element == 'propal') $this->ref_propal = $obj->nb;
|
||||
if ($resql) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
if ($obj->nb) {
|
||||
if ($obj->element == 'facture') {
|
||||
$this->ref_facturation = $obj->nb;
|
||||
} elseif ($obj->element == 'contrat') {
|
||||
$this->ref_contrat = $obj->nb;
|
||||
} elseif ($obj->element == 'commande') {
|
||||
$this->ref_commande = $obj->nb;
|
||||
} elseif ($obj->element == 'propal') {
|
||||
$this->ref_propal = $obj->nb;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->free($resql);
|
||||
@ -1169,8 +1203,7 @@ class Contact extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// Get all rowid of element_contact linked to a type that is link to llx_socpeople
|
||||
$sql = "SELECT ec.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."element_contact ec,";
|
||||
@ -1180,21 +1213,18 @@ class Contact extends CommonObject
|
||||
$sql .= " AND tc.source='external'";
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num && !$error)
|
||||
{
|
||||
while ($i < $num && !$error) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$sqldel = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
|
||||
$sqldel .= " WHERE rowid = ".$obj->rowid;
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$result = $this->db->query($sqldel);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
$error++;
|
||||
$this->error = $this->db->error().' sql='.$sqldel;
|
||||
}
|
||||
@ -1207,56 +1237,48 @@ class Contact extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// Remove Roles
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id;
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error .= $this->db->lasterror();
|
||||
$errorflag = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// Remove Roles
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id;
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error .= $this->db->lasterror();
|
||||
$errorflag = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// Remove category
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople = ".$this->id;
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error .= $this->db->lasterror();
|
||||
$errorflag = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
$error++;
|
||||
$this->error = $this->db->error().' sql='.$sql;
|
||||
}
|
||||
@ -1266,19 +1288,21 @@ class Contact extends CommonObject
|
||||
if (!$error) {
|
||||
// For avoid conflicts if trigger used
|
||||
$result = $this->deleteExtraFields();
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('CONTACT_DELETE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
@ -1303,10 +1327,8 @@ class Contact extends CommonObject
|
||||
$sql .= " WHERE c.rowid = ".$this->db->escape($id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
@ -1346,8 +1368,7 @@ class Contact extends CommonObject
|
||||
$sql .= " AND m.entity IN (".getEntity($this->element).") AND mc.statut NOT IN (-1,0)"; // -1 error, 0 not sent, 1 sent with success
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$nb = $obj->nb;
|
||||
|
||||
@ -1377,8 +1398,7 @@ class Contact extends CommonObject
|
||||
|
||||
$result = ''; $label = '';
|
||||
|
||||
if (!empty($this->photo) && class_exists('Form'))
|
||||
{
|
||||
if (!empty($this->photo) && class_exists('Form')) {
|
||||
$label .= '<div class="photointooltip">';
|
||||
$label .= Form::showphoto('contact', $this, 0, 40, 0, '', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip.
|
||||
$label .= '</div><div style="clear: both;"></div>';
|
||||
@ -1388,67 +1408,83 @@ class Contact extends CommonObject
|
||||
$label .= ' '.$this->getLibStatut(4);
|
||||
$label .= '<br><b>'.$langs->trans("Name").':</b> '.$this->getFullName($langs);
|
||||
//if ($this->civility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code
|
||||
if (!empty($this->poste)) $label .= '<br><b>'.$langs->trans("Poste").':</b> '.$this->poste;
|
||||
if (!empty($this->poste)) {
|
||||
$label .= '<br><b>'.$langs->trans("Poste").':</b> '.$this->poste;
|
||||
}
|
||||
$label .= '<br><b>'.$langs->trans("EMail").':</b> '.$this->email;
|
||||
$phonelist = array();
|
||||
$country_code = empty($this->country_code) ? '': $this->country_code;
|
||||
if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone');
|
||||
if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile');
|
||||
if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone');
|
||||
if ($this->phone_pro) {
|
||||
$phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone');
|
||||
}
|
||||
if ($this->phone_mobile) {
|
||||
$phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile');
|
||||
}
|
||||
if ($this->phone_perso) {
|
||||
$phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone');
|
||||
}
|
||||
$label .= '<br><b>'.$langs->trans("Phone").':</b> '.implode(' ', $phonelist);
|
||||
$label .= '<br><b>'.$langs->trans("Address").':</b> '.dol_format_address($this, 1, ' ', $langs);
|
||||
|
||||
$url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id;
|
||||
|
||||
if ($option !== 'nolink')
|
||||
{
|
||||
if ($option !== 'nolink') {
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
||||
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||
$add_save_lastsearch_values = 1;
|
||||
}
|
||||
if ($add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
}
|
||||
|
||||
$url .= $moreparam;
|
||||
|
||||
$linkclose = "";
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowContact");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip"';
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip"';
|
||||
|
||||
/*
|
||||
$hookmanager->initHooks(array('contactdao'));
|
||||
$parameters=array('id'=>$this->id);
|
||||
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
|
||||
*/
|
||||
/*
|
||||
$hookmanager->initHooks(array('contactdao'));
|
||||
$parameters=array('id'=>$this->id);
|
||||
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
|
||||
*/
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart .= $linkclose.'>';
|
||||
$linkend = '</a>';
|
||||
|
||||
if ($option == 'xxx')
|
||||
{
|
||||
if ($option == 'xxx') {
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend = '</a>';
|
||||
}
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs));
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs));
|
||||
}
|
||||
$result .= $linkend;
|
||||
|
||||
global $action;
|
||||
$hookmanager->initHooks(array('contactdao'));
|
||||
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
|
||||
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook > 0) $result = $hookmanager->resPrint;
|
||||
else $result .= $hookmanager->resPrint;
|
||||
if ($reshook > 0) {
|
||||
$result = $hookmanager->resPrint;
|
||||
} else {
|
||||
$result .= $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -1463,7 +1499,9 @@ class Contact extends CommonObject
|
||||
global $langs;
|
||||
|
||||
$code = ($this->civility_code ? $this->civility_code : (!empty($this->civility_id) ? $this->civility : (!empty($this->civilite) ? $this->civilite : '')));
|
||||
if (empty($code)) return '';
|
||||
if (empty($code)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$langs->load("dict");
|
||||
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code);
|
||||
@ -1507,7 +1545,9 @@ class Contact extends CommonObject
|
||||
);
|
||||
|
||||
$statusType = 'status4';
|
||||
if ($status == 0 || $status == 5) $statusType = 'status5';
|
||||
if ($status == 0 || $status == 5) {
|
||||
$statusType = 'status5';
|
||||
}
|
||||
|
||||
$label = $langs->trans($labelStatus[$status]);
|
||||
$labelshort = $langs->trans($labelStatusShort[$status]);
|
||||
@ -1527,8 +1567,11 @@ class Contact extends CommonObject
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
if ($status == '1') return $langs->trans('ContactPrivate');
|
||||
else return $langs->trans('ContactPublic');
|
||||
if ($status == '1') {
|
||||
return $langs->trans('ContactPrivate');
|
||||
} else {
|
||||
return $langs->trans('ContactPublic');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1547,7 +1590,9 @@ class Contact extends CommonObject
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) $socid = $obj->rowid;
|
||||
if ($obj) {
|
||||
$socid = $obj->rowid;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialise parameters
|
||||
@ -1592,8 +1637,11 @@ class Contact extends CommonObject
|
||||
$error = 0;
|
||||
|
||||
// Check parameters
|
||||
if ($this->statut == $status) return 0;
|
||||
else $this->statut = $status;
|
||||
if ($this->statut == $status) {
|
||||
return 0;
|
||||
} else {
|
||||
$this->statut = $status;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -1604,16 +1652,16 @@ class Contact extends CommonObject
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
dol_syslog(get_class($this)."::setstatus", LOG_DEBUG);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if ($error)
|
||||
{
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -$error;
|
||||
} else {
|
||||
@ -1725,12 +1773,10 @@ class Contact extends CommonObject
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$tab[] = array('fk_socpeople'=>$obj->id, 'type_contact'=>$obj->fk_c_type_contact);
|
||||
|
||||
@ -1758,7 +1804,9 @@ class Contact extends CommonObject
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (!isset($this->roles)) return; // Avoid to loose roles when property not set
|
||||
if (!isset($this->roles)) {
|
||||
return; // Avoid to loose roles when property not set
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -1800,8 +1848,7 @@ class Contact extends CommonObject
|
||||
$sql .= ")";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
$this->errors[] = $this->db->lasterror().' sql='.$sql;
|
||||
$error++;
|
||||
}
|
||||
@ -1830,12 +1877,13 @@ class Contact extends CommonObject
|
||||
global $langs;
|
||||
|
||||
$sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcommcontact";
|
||||
if ($active >= 0) $sql .= " WHERE active = ".$active;
|
||||
if ($active >= 0) {
|
||||
$sql .= " WHERE active = ".$active;
|
||||
}
|
||||
$resql = $this->db->query($sql);
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->cacheprospectstatus[$obj->id] = array('id' => $obj->id, 'code' => $obj->code, 'label' => ($langs->trans("ST_".strtoupper($obj->code)) == "ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_".strtoupper($obj->code)), 'picto' => $obj->picto);
|
||||
$i++;
|
||||
@ -1865,8 +1913,7 @@ class Contact extends CommonObject
|
||||
|
||||
$lib = $langs->trans("ProspectLevel".$fk_prospectlevel);
|
||||
// If lib not found in language file, we get label from cache/databse
|
||||
if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel))
|
||||
{
|
||||
if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) {
|
||||
$lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label');
|
||||
}
|
||||
return $lib;
|
||||
@ -1915,36 +1962,48 @@ class Contact extends CommonObject
|
||||
global $langs;
|
||||
$langs->load('customers');
|
||||
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1");
|
||||
elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0");
|
||||
elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1");
|
||||
elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2");
|
||||
elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3");
|
||||
else {
|
||||
if ($mode == 2) {
|
||||
if ($statut == '-1' || $statut == 'ST_NO') {
|
||||
return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1");
|
||||
} elseif ($statut == '0' || $statut == 'ST_NEVER') {
|
||||
return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0");
|
||||
} elseif ($statut == '1' || $statut == 'ST_TODO') {
|
||||
return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1");
|
||||
} elseif ($statut == '2' || $statut == 'ST_PEND') {
|
||||
return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2");
|
||||
} elseif ($statut == '3' || $statut == 'ST_DONE') {
|
||||
return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3");
|
||||
} else {
|
||||
return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label);
|
||||
}
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto);
|
||||
elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto);
|
||||
elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto);
|
||||
elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto);
|
||||
elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto);
|
||||
else {
|
||||
if ($mode == 3) {
|
||||
if ($statut == '-1' || $statut == 'ST_NO') {
|
||||
return img_action($langs->trans("StatusProspect-1"), -1, $picto);
|
||||
} elseif ($statut == '0' || $statut == 'ST_NEVER') {
|
||||
return img_action($langs->trans("StatusProspect0"), 0, $picto);
|
||||
} elseif ($statut == '1' || $statut == 'ST_TODO') {
|
||||
return img_action($langs->trans("StatusProspect1"), 1, $picto);
|
||||
} elseif ($statut == '2' || $statut == 'ST_PEND') {
|
||||
return img_action($langs->trans("StatusProspect2"), 2, $picto);
|
||||
} elseif ($statut == '3' || $statut == 'ST_DONE') {
|
||||
return img_action($langs->trans("StatusProspect3"), 3, $picto);
|
||||
} else {
|
||||
return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto);
|
||||
}
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1");
|
||||
elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0");
|
||||
elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1");
|
||||
elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2");
|
||||
elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3");
|
||||
else {
|
||||
if ($mode == 4) {
|
||||
if ($statut == '-1' || $statut == 'ST_NO') {
|
||||
return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1");
|
||||
} elseif ($statut == '0' || $statut == 'ST_NEVER') {
|
||||
return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0");
|
||||
} elseif ($statut == '1' || $statut == 'ST_TODO') {
|
||||
return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1");
|
||||
} elseif ($statut == '2' || $statut == 'ST_PEND') {
|
||||
return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2");
|
||||
} elseif ($statut == '3' || $statut == 'ST_DONE') {
|
||||
return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3");
|
||||
} else {
|
||||
return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label);
|
||||
}
|
||||
}
|
||||
@ -1964,24 +2023,19 @@ class Contact extends CommonObject
|
||||
$error = 0;
|
||||
|
||||
// Update mass emailing flag into table mailing_unsubscribe
|
||||
if ($this->email)
|
||||
{
|
||||
if ($this->email) {
|
||||
$this->db->begin();
|
||||
|
||||
if ($no_email)
|
||||
{
|
||||
if ($no_email) {
|
||||
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$this->db->escape($this->email)."'";
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$noemail = $obj->nb;
|
||||
if (empty($noemail))
|
||||
{
|
||||
if (empty($noemail)) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$this->db->escape($this->email)."', ".$this->db->escape(getEntity('mailing', 0)).", '".$this->db->idate(dol_now())."')";
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
@ -1995,8 +2049,7 @@ class Contact extends CommonObject
|
||||
} else {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$this->db->escape($this->email)."' AND entity = ".$this->db->escape(getEntity('mailing', 0));
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
@ -2024,8 +2077,7 @@ class Contact extends CommonObject
|
||||
*/
|
||||
public function getNoEmail()
|
||||
{
|
||||
if ($this->email)
|
||||
{
|
||||
if ($this->email) {
|
||||
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($this->email)."'";
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
|
||||
@ -37,8 +37,12 @@ $id = GETPOST('id', 'int');
|
||||
|
||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||
$object = new Contact($db);
|
||||
if ($id > 0) $object->fetch($id);
|
||||
if (empty($object->thirdparty)) $object->fetch_thirdparty();
|
||||
if ($id > 0) {
|
||||
$object->fetch($id);
|
||||
}
|
||||
if (empty($object->thirdparty)) {
|
||||
$object->fetch_thirdparty();
|
||||
}
|
||||
$socid = $object->thirdparty->id;
|
||||
|
||||
// Sort & Order fields
|
||||
@ -46,12 +50,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) $sortorder = 'DESC';
|
||||
if (!$sortfield) $sortfield = 'dateprint';
|
||||
if (!$sortorder) {
|
||||
$sortorder = 'DESC';
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = 'dateprint';
|
||||
}
|
||||
|
||||
// Search fields
|
||||
$sref = GETPOST("sref");
|
||||
@ -60,8 +70,7 @@ $month = GETPOST('month', 'int');
|
||||
$year = GETPOST('year', 'int');
|
||||
|
||||
// Clean up on purge search criteria ?
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
|
||||
$sref = '';
|
||||
$sprod_fulldescr = '';
|
||||
$year = '';
|
||||
@ -84,7 +93,9 @@ $hookmanager->initHooks(array('consumptioncontact'));
|
||||
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -99,8 +110,7 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if (empty($id))
|
||||
{
|
||||
if (empty($id)) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
@ -111,13 +121,15 @@ print dol_get_fiche_head($head, 'consumption', $langs->trans("ContactsAddresses"
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
$objsoc->fetch($socid);
|
||||
// Thirdparty
|
||||
$morehtmlref .= $langs->trans('ThirdParty').' : ';
|
||||
if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
|
||||
else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
if ($objsoc->id > 0) {
|
||||
$morehtmlref .= $objsoc->getNomUrl(1, 'contact');
|
||||
} else {
|
||||
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
}
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
@ -133,22 +145,34 @@ print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td>';
|
||||
print $object->getCivilityLabel();
|
||||
print '</td></tr>';
|
||||
|
||||
if ($object->thirdparty->client)
|
||||
{
|
||||
if ($object->thirdparty->client) {
|
||||
$thirdTypeArray['customer'] = $langs->trans("customer");
|
||||
if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
|
||||
if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
|
||||
if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
|
||||
if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
|
||||
if ($conf->propal->enabled && $user->rights->propal->lire) {
|
||||
$elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
|
||||
}
|
||||
if ($conf->commande->enabled && $user->rights->commande->lire) {
|
||||
$elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
|
||||
}
|
||||
if ($conf->facture->enabled && $user->rights->facture->lire) {
|
||||
$elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
|
||||
}
|
||||
if ($conf->contrat->enabled && $user->rights->contrat->lire) {
|
||||
$elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
|
||||
if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) {
|
||||
$elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
|
||||
}
|
||||
|
||||
if ($object->thirdparty->fournisseur)
|
||||
{
|
||||
if ($object->thirdparty->fournisseur) {
|
||||
$thirdTypeArray['supplier'] = $langs->trans("supplier");
|
||||
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
|
||||
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
|
||||
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) {
|
||||
$elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
|
||||
}
|
||||
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) {
|
||||
$elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
|
||||
}
|
||||
|
||||
// There no contact type for supplier proposals
|
||||
// if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals');
|
||||
@ -166,8 +190,7 @@ print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?id='.$id.'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
$sql_select = '';
|
||||
if ($type_element == 'fichinter')
|
||||
{ // Customer : show products from invoices
|
||||
if ($type_element == 'fichinter') { // Customer : show products from invoices
|
||||
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
|
||||
$documentstatic = new Fichinter($db);
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle as type_contact_label, ';
|
||||
@ -178,8 +201,7 @@ if ($type_element == 'fichinter')
|
||||
$where = ' WHERE f.entity IN ('.getEntity('ficheinter').')';
|
||||
$dateprint = 'f.datec';
|
||||
$doc_number = 'f.ref';
|
||||
} elseif ($type_element == 'invoice')
|
||||
{ // Customer : show products from invoices
|
||||
} elseif ($type_element == 'invoice') { // Customer : show products from invoices
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$documentstatic = new Facture($db);
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, ';
|
||||
@ -192,8 +214,7 @@ if ($type_element == 'fichinter')
|
||||
$dateprint = 'f.datef';
|
||||
$doc_number = 'f.ref';
|
||||
$thirdTypeSelect = 'customer';
|
||||
} elseif ($type_element == 'propal')
|
||||
{
|
||||
} elseif ($type_element == 'propal') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
$documentstatic = new Propal($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, ';
|
||||
@ -206,8 +227,7 @@ if ($type_element == 'fichinter')
|
||||
$datePrint = 'c.datep';
|
||||
$doc_number = 'c.ref';
|
||||
$thirdTypeSelect = 'customer';
|
||||
} elseif ($type_element == 'order')
|
||||
{
|
||||
} elseif ($type_element == 'order') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
$documentstatic = new Commande($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, ';
|
||||
@ -220,8 +240,7 @@ if ($type_element == 'fichinter')
|
||||
$dateprint = 'c.date_commande';
|
||||
$doc_number = 'c.ref';
|
||||
$thirdTypeSelect = 'customer';
|
||||
} elseif ($type_element == 'supplier_invoice')
|
||||
{ // Supplier : Show products from invoices.
|
||||
} elseif ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices.
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
$documentstatic = new FactureFournisseur($db);
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, ';
|
||||
@ -234,22 +253,19 @@ if ($type_element == 'fichinter')
|
||||
$dateprint = 'f.datef';
|
||||
$doc_number = 'f.ref';
|
||||
$thirdTypeSelect = 'supplier';
|
||||
}
|
||||
//elseif ($type_element == 'supplier_proposal')
|
||||
//{
|
||||
// require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
|
||||
// $documentstatic=new SupplierProposal($db);
|
||||
// $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, ';
|
||||
// $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d";
|
||||
// $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
|
||||
// $where.= " AND d.fk_supplier_proposal = c.rowid";
|
||||
// $where.= " AND c.entity = ".$conf->entity;
|
||||
// $dateprint = 'c.date_valid';
|
||||
// $doc_number='c.ref';
|
||||
// $thirdTypeSelect='supplier';
|
||||
//}
|
||||
elseif ($type_element == 'supplier_order')
|
||||
{ // Supplier : Show products from orders.
|
||||
//} elseif ($type_element == 'supplier_proposal') {
|
||||
// require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
|
||||
// $documentstatic=new SupplierProposal($db);
|
||||
// $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, ';
|
||||
// $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d";
|
||||
// $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
|
||||
// $where.= " AND d.fk_supplier_proposal = c.rowid";
|
||||
// $where.= " AND c.entity = ".$conf->entity;
|
||||
// $dateprint = 'c.date_valid';
|
||||
// $doc_number='c.ref';
|
||||
// $thirdTypeSelect='supplier';
|
||||
//}
|
||||
} elseif ($type_element == 'supplier_order') { // Supplier : Show products from orders.
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||
$documentstatic = new CommandeFournisseur($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, ';
|
||||
@ -262,8 +278,7 @@ elseif ($type_element == 'supplier_order')
|
||||
$dateprint = 'c.date_valid';
|
||||
$doc_number = 'c.ref';
|
||||
$thirdTypeSelect = 'supplier';
|
||||
} elseif ($type_element == 'contract')
|
||||
{ // Order
|
||||
} elseif ($type_element == 'contract') { // Order
|
||||
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
$documentstatic = new Contrat($db);
|
||||
$documentstaticline = new ContratLigne($db);
|
||||
@ -282,26 +297,40 @@ elseif ($type_element == 'supplier_order')
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
||||
|
||||
if (!empty($sql_select))
|
||||
{
|
||||
if (!empty($sql_select)) {
|
||||
$sql = $sql_select;
|
||||
$sql .= ' d.description as description';
|
||||
if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') $sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
if ($type_element == 'supplier_proposal') $sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
if ($type_element == 'contract') $sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
if ($type_element != 'fichinter') $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity';
|
||||
if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') {
|
||||
$sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
}
|
||||
if ($type_element == 'supplier_proposal') {
|
||||
$sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
}
|
||||
if ($type_element == 'contract') {
|
||||
$sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
}
|
||||
if ($type_element != 'fichinter') {
|
||||
$sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity';
|
||||
}
|
||||
$sql .= " ";
|
||||
if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label";
|
||||
if ($type_element != 'fichinter') {
|
||||
$sql .= ", p.ref as prod_ref, p.label as product_label";
|
||||
}
|
||||
$sql .= " FROM "/*.MAIN_DB_PREFIX."societe as s, "*/.$tables_from;
|
||||
// if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
|
||||
$sql .= $where;
|
||||
$sql .= dolSqlDateFilter($dateprint, 0, $month, $year);
|
||||
if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
|
||||
if ($sprod_fulldescr)
|
||||
{
|
||||
if ($sref) {
|
||||
$sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
|
||||
}
|
||||
if ($sprod_fulldescr) {
|
||||
$sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
if (GETPOST('type_element') != 'fichinter') {
|
||||
$sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
}
|
||||
if (GETPOST('type_element') != 'fichinter') {
|
||||
$sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
}
|
||||
$sql .= ")";
|
||||
}
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
@ -332,21 +361,36 @@ $param .= "&type_element=".urlencode($type_element);
|
||||
|
||||
$total_qty = 0;
|
||||
|
||||
if ($sql_select)
|
||||
{
|
||||
if ($sql_select) {
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr);
|
||||
if ($sref) $param .= "&sref=".urlencode($sref);
|
||||
if ($month) $param .= "&month=".urlencode($month);
|
||||
if ($year) $param .= "&year=".urlencode($year);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($sprod_fulldescr) {
|
||||
$param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr);
|
||||
}
|
||||
if ($sref) {
|
||||
$param .= "&sref=".urlencode($sref);
|
||||
}
|
||||
if ($month) {
|
||||
$param .= "&month=".urlencode($month);
|
||||
}
|
||||
if ($year) {
|
||||
$param .= "&year=".urlencode($year);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
|
||||
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit);
|
||||
|
||||
@ -393,8 +437,7 @@ if ($sql_select)
|
||||
|
||||
|
||||
$i = 0;
|
||||
while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit))
|
||||
{
|
||||
while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) {
|
||||
$documentstatic->id = $objp->doc_id;
|
||||
$documentstatic->ref = $objp->doc_number;
|
||||
$documentstatic->type = $objp->doc_type;
|
||||
@ -405,7 +448,9 @@ if ($sql_select)
|
||||
$documentstatic->paye = $objp->paid;
|
||||
$documentstatic->paid = $objp->paid;
|
||||
|
||||
if (is_object($documentstaticline)) $documentstaticline->statut = $objp->status;
|
||||
if (is_object($documentstaticline)) {
|
||||
$documentstaticline->statut = $objp->status;
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nobordernopadding nowrap" width="100">';
|
||||
@ -415,8 +460,7 @@ if ($sql_select)
|
||||
|
||||
// Status
|
||||
print '<td class="center">';
|
||||
if ($type_element == 'contract')
|
||||
{
|
||||
if ($type_element == 'contract') {
|
||||
print $documentstaticline->getLibStatut(2);
|
||||
} else {
|
||||
print $documentstatic->getLibStatut(2);
|
||||
@ -429,8 +473,7 @@ if ($sql_select)
|
||||
$text = ''; $description = ''; $type = 0;
|
||||
|
||||
// Code to show product duplicated from commonobject->printObjectLine
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
if ($objp->fk_product > 0) {
|
||||
$product_static = new Product($db);
|
||||
|
||||
$product_static->type = $objp->fk_product_type;
|
||||
@ -441,20 +484,21 @@ if ($sql_select)
|
||||
}
|
||||
|
||||
// Product
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
if ($objp->fk_product > 0) {
|
||||
// Define output language
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
|
||||
$prod = new Product($db);
|
||||
$prod->fetch($objp->fk_product);
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if (empty($newlang)) $newlang = $object->default_lang;
|
||||
if (!empty($newlang))
|
||||
{
|
||||
if (empty($newlang) && GETPOST('lang_id', 'aZ09')) {
|
||||
$newlang = GETPOST('lang_id', 'aZ09');
|
||||
}
|
||||
if (empty($newlang)) {
|
||||
$newlang = $object->default_lang;
|
||||
}
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
@ -468,42 +512,42 @@ if ($sql_select)
|
||||
$description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description));
|
||||
}
|
||||
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
if (($objp->info_bits & 2) == 2) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'">';
|
||||
$txt = '';
|
||||
print img_object($langs->trans("ShowReduc"), 'reduc').' ';
|
||||
if ($objp->description == '(DEPOSIT)') $txt = $langs->trans("Deposit");
|
||||
elseif ($objp->description == '(EXCESS RECEIVED)') $txt = $langs->trans("ExcessReceived");
|
||||
elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid");
|
||||
if ($objp->description == '(DEPOSIT)') {
|
||||
$txt = $langs->trans("Deposit");
|
||||
} elseif ($objp->description == '(EXCESS RECEIVED)') {
|
||||
$txt = $langs->trans("ExcessReceived");
|
||||
} elseif ($objp->description == '(EXCESS PAID)') {
|
||||
$txt = $langs->trans("ExcessPaid");
|
||||
}
|
||||
//else $txt=$langs->trans("Discount");
|
||||
print $txt;
|
||||
print '</a>';
|
||||
if ($objp->description)
|
||||
{
|
||||
if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0)
|
||||
{
|
||||
if ($objp->description) {
|
||||
if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) {
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fetch($objp->fk_remise_except);
|
||||
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
|
||||
}
|
||||
if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0)
|
||||
{
|
||||
if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) {
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fetch($objp->fk_remise_except);
|
||||
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
|
||||
} elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0)
|
||||
{
|
||||
} elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) {
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fetch($objp->fk_remise_except);
|
||||
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
|
||||
} elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0)
|
||||
{
|
||||
} elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) {
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fetch($objp->fk_remise_except);
|
||||
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
|
||||
// Add date of deposit
|
||||
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')';
|
||||
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
|
||||
echo ' ('.dol_print_date($discount->datec).')';
|
||||
}
|
||||
} else {
|
||||
echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description);
|
||||
}
|
||||
@ -516,15 +560,16 @@ if ($sql_select)
|
||||
echo get_date_range($objp->date_start, $objp->date_end);
|
||||
|
||||
// Add description in form
|
||||
if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
|
||||
{
|
||||
if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
|
||||
print (!empty($objp->description) && $objp->description != $objp->product_label) ? '<br>'.dol_htmlentitiesbr($objp->description) : '';
|
||||
}
|
||||
} else {
|
||||
if (!empty($objp->label) || !empty($objp->description))
|
||||
{
|
||||
if ($type == 1) $text = img_object($langs->trans('Service'), 'service');
|
||||
else $text = img_object($langs->trans('Product'), 'product');
|
||||
if (!empty($objp->label) || !empty($objp->description)) {
|
||||
if ($type == 1) {
|
||||
$text = img_object($langs->trans('Service'), 'service');
|
||||
} else {
|
||||
$text = img_object($langs->trans('Product'), 'product');
|
||||
}
|
||||
|
||||
if (!empty($objp->label)) {
|
||||
$text .= ' <strong>'.$objp->label.'</strong>';
|
||||
|
||||
@ -43,15 +43,16 @@ $object = new Contact($db);
|
||||
$object->getCanvas($id);
|
||||
$objcanvas = null;
|
||||
$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas"));
|
||||
if (!empty($canvas))
|
||||
{
|
||||
if (!empty($canvas)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
|
||||
$objcanvas = new Canvas($db, $action);
|
||||
$objcanvas->getCanvas('contact', 'contactcard', $canvas);
|
||||
}
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
|
||||
|
||||
// Get parameters
|
||||
@ -59,18 +60,30 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; }
|
||||
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; }
|
||||
if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) {
|
||||
$sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) {
|
||||
$sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
|
||||
}
|
||||
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "name";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "name";
|
||||
}
|
||||
|
||||
if ($id > 0) $object->fetch($id);
|
||||
if ($id > 0) {
|
||||
$object->fetch($id);
|
||||
}
|
||||
|
||||
$upload_dir = $conf->societe->multidir_output[$object->entity].'/contact/'.dol_sanitizeFileName($object->ref);
|
||||
$modulepart = 'contact';
|
||||
@ -90,12 +103,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
||||
$form = new Form($db);
|
||||
|
||||
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
|
||||
$title = $object->lastname;
|
||||
}
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $helpurl);
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
if ($object->id) {
|
||||
$head = contact_prepare_head($object);
|
||||
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||
|
||||
@ -105,22 +119,23 @@ if ($object->id)
|
||||
// Build file list
|
||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
||||
$totalsize = 0;
|
||||
foreach ($filearray as $key => $file)
|
||||
{
|
||||
foreach ($filearray as $key => $file) {
|
||||
$totalsize += $file['size'];
|
||||
}
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($object->socid);
|
||||
// Thirdparty
|
||||
$morehtmlref .= $langs->trans('ThirdParty').' : ';
|
||||
if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1);
|
||||
else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
if ($objsoc->id > 0) {
|
||||
$morehtmlref .= $objsoc->getNomUrl(1);
|
||||
} else {
|
||||
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
}
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
@ -133,23 +148,23 @@ if ($object->id)
|
||||
|
||||
// Company
|
||||
/*
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if ($object->socid > 0)
|
||||
{
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($object->socid);
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if ($object->socid > 0)
|
||||
{
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($object->socid);
|
||||
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
|
||||
print $langs->trans("ContactNotLinkedToCompany");
|
||||
print '</td></tr>';
|
||||
}
|
||||
}*/
|
||||
else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
|
||||
print $langs->trans("ContactNotLinkedToCompany");
|
||||
print '</td></tr>';
|
||||
}
|
||||
}*/
|
||||
|
||||
// Civility
|
||||
print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
||||
|
||||
@ -34,7 +34,9 @@ $langs->load("companies");
|
||||
|
||||
// Security check
|
||||
$id = GETPOST("id", 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||
|
||||
$object = new Contact($db);
|
||||
@ -51,8 +53,7 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C
|
||||
|
||||
llxHeader('', $title, 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$result = $object->fetch($id, $user);
|
||||
|
||||
$object->info($id);
|
||||
|
||||
@ -36,12 +36,13 @@ $action = GETPOST('action', 'aZ09');
|
||||
|
||||
// Security check
|
||||
$id = GETPOST('id', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||
|
||||
$object = new Contact($db);
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$object->fetch($id, $user);
|
||||
}
|
||||
|
||||
@ -50,8 +51,7 @@ if ($id > 0)
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'dolibarr2ldap')
|
||||
{
|
||||
if ($action == 'dolibarr2ldap') {
|
||||
$db->begin();
|
||||
|
||||
$ldap = new Ldap();
|
||||
@ -63,8 +63,7 @@ if ($action == 'dolibarr2ldap')
|
||||
|
||||
$result = $ldap->update($dn, $info, $user, $olddn);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
setEventMessages($langs->trans("ContactSynchronized"), null, 'mesgs');
|
||||
$db->commit();
|
||||
} else {
|
||||
@ -98,8 +97,7 @@ print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// Company
|
||||
if ($object->socid > 0)
|
||||
{
|
||||
if ($object->socid > 0) {
|
||||
$thirdparty = new Societe($db);
|
||||
$thirdparty->fetch($object->socid);
|
||||
|
||||
@ -139,14 +137,15 @@ print dol_get_fiche_end();
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr')
|
||||
{
|
||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print "<br>\n";
|
||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') {
|
||||
print "<br>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -163,8 +162,7 @@ print '</tr>';
|
||||
// Lecture LDAP
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$info = $object->_load_ldap_info();
|
||||
$dn = $object->_load_ldap_dn($info, 1);
|
||||
$search = "(".$object->_load_ldap_dn($info, 2).")";
|
||||
@ -174,10 +172,8 @@ if ($result > 0)
|
||||
//var_dump($records);
|
||||
|
||||
// Show tree
|
||||
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0))
|
||||
{
|
||||
if (!is_array($records))
|
||||
{
|
||||
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
|
||||
if (!is_array($records)) {
|
||||
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
|
||||
} else {
|
||||
$result = show_ldap_content($records, 0, $records['count'], true);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -36,11 +36,15 @@ $langs->load("companies");
|
||||
|
||||
// Security check
|
||||
$id = GETPOST('id', 'int');
|
||||
if ($user->socid) $id = $user->socid;
|
||||
if ($user->socid) {
|
||||
$id = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||
|
||||
$object = new Contact($db);
|
||||
if ($id > 0) $object->fetch($id);
|
||||
if ($id > 0) {
|
||||
$object->fetch($id);
|
||||
}
|
||||
|
||||
$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
|
||||
|
||||
@ -65,12 +69,13 @@ $form = new Form($db);
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
if (!empty($conf->notification->enabled)) $langs->load("mails");
|
||||
* Affichage onglets
|
||||
*/
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
|
||||
$head = contact_prepare_head($object);
|
||||
|
||||
@ -79,14 +84,16 @@ if ($id > 0)
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($object->socid);
|
||||
// Thirdparty
|
||||
$morehtmlref .= $langs->trans('ThirdParty').' : ';
|
||||
if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1);
|
||||
else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
if ($objsoc->id > 0) {
|
||||
$morehtmlref .= $objsoc->getNomUrl(1);
|
||||
} else {
|
||||
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
}
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
|
||||
@ -35,7 +35,9 @@ $id = GETPOST('id', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||
$object = new Contact($db);
|
||||
|
||||
@ -43,47 +45,43 @@ $object = new Contact($db);
|
||||
* Action
|
||||
*/
|
||||
|
||||
if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) {
|
||||
$ret = $object->fetch($id);
|
||||
|
||||
// Note: Correct date should be completed with location to have exact GM time of birth.
|
||||
$object->birthday = dol_mktime(0, 0, 0, $_POST["birthdaymonth"], $_POST["birthdayday"], $_POST["birthdayyear"]);
|
||||
$object->birthday_alert = $_POST["birthday_alert"];
|
||||
|
||||
if (GETPOST('deletephoto')) $object->photo = '';
|
||||
elseif (!empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
if (GETPOST('deletephoto')) {
|
||||
$object->photo = '';
|
||||
} elseif (!empty($_FILES['photo']['name'])) {
|
||||
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
}
|
||||
|
||||
$result = $object->update_perso($id, $user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$object->old_name = '';
|
||||
$object->old_firstname = '';
|
||||
// Logo/Photo save
|
||||
$dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos';
|
||||
|
||||
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
||||
if ($file_OK)
|
||||
{
|
||||
if ($file_OK) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
if (GETPOST('deletephoto'))
|
||||
{
|
||||
if (GETPOST('deletephoto')) {
|
||||
$fileimg = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/'.$object->photo;
|
||||
$dirthumbs = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/thumbs';
|
||||
dol_delete_file($fileimg);
|
||||
dol_delete_dir_recursive($dirthumbs);
|
||||
}
|
||||
|
||||
if (image_format_supported($_FILES['photo']['name']) > 0)
|
||||
{
|
||||
if (image_format_supported($_FILES['photo']['name']) > 0) {
|
||||
dol_mkdir($dir);
|
||||
|
||||
if (@is_dir($dir))
|
||||
{
|
||||
if (@is_dir($dir)) {
|
||||
$newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0)
|
||||
{
|
||||
if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) {
|
||||
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
|
||||
} else {
|
||||
// Create thumbs
|
||||
@ -94,8 +92,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact-
|
||||
setEventMessages("ErrorBadImageFormat", null, 'errors');
|
||||
}
|
||||
} else {
|
||||
switch ($_FILES['photo']['error'])
|
||||
{
|
||||
switch ($_FILES['photo']['error']) {
|
||||
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
|
||||
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
|
||||
$errors[] = "ErrorFileSizeTooLarge";
|
||||
@ -118,7 +115,9 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact-
|
||||
$now = dol_now();
|
||||
|
||||
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
|
||||
$title = $object->lastname;
|
||||
}
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $helpurl);
|
||||
|
||||
@ -128,8 +127,7 @@ $object->fetch($id, $user);
|
||||
|
||||
$head = contact_prepare_head($object);
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
/*
|
||||
* Fiche en mode edition
|
||||
*/
|
||||
@ -151,11 +149,15 @@ if ($action == 'edit')
|
||||
// Photo
|
||||
print '<td class="center hideonsmartphone valignmiddle" rowspan="6">';
|
||||
print $form->showphoto('contact', $object)."\n";
|
||||
if ($object->photo) print "<br>\n";
|
||||
if ($object->photo) {
|
||||
print "<br>\n";
|
||||
}
|
||||
|
||||
print '<table class="nobordernopadding">';
|
||||
|
||||
if ($object->photo) print '<tr><td class="center"><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||
if ($object->photo) {
|
||||
print '<tr><td class="center"><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
||||
print '</table>';
|
||||
@ -167,10 +169,8 @@ if ($action == 'edit')
|
||||
print '<tr><td>'.$langs->trans("Firstname").'</td><td colspan="3">'.$object->firstname.'</td>';
|
||||
|
||||
// Company
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if ($object->socid > 0)
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
if ($object->socid > 0) {
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($object->socid);
|
||||
|
||||
@ -194,8 +194,7 @@ if ($action == 'edit')
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="2">'.$langs->trans("Alert").': ';
|
||||
if (!empty($object->birthday_alert))
|
||||
{
|
||||
if (!empty($object->birthday_alert)) {
|
||||
print '<input type="checkbox" name="birthday_alert" checked></td>';
|
||||
} else {
|
||||
print '<input type="checkbox" name="birthday_alert"></td>';
|
||||
@ -221,14 +220,16 @@ if ($action == 'edit')
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($object->socid);
|
||||
// Thirdparty
|
||||
$morehtmlref .= $langs->trans('ThirdParty').' : ';
|
||||
if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1);
|
||||
else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
if ($objsoc->id > 0) {
|
||||
$morehtmlref .= $objsoc->getNomUrl(1);
|
||||
} else {
|
||||
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
|
||||
}
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
@ -243,23 +244,23 @@ if ($action == 'edit')
|
||||
|
||||
// Company
|
||||
/*
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if ($object->socid > 0)
|
||||
{
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($object->socid);
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if ($object->socid > 0)
|
||||
{
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($object->socid);
|
||||
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
|
||||
print $langs->trans("ContactNotLinkedToCompany");
|
||||
print '</td></tr>';
|
||||
}
|
||||
}*/
|
||||
else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
|
||||
print $langs->trans("ContactNotLinkedToCompany");
|
||||
print '</td></tr>';
|
||||
}
|
||||
}*/
|
||||
|
||||
// Civility
|
||||
print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
||||
@ -268,8 +269,7 @@ if ($action == 'edit')
|
||||
|
||||
// Date To Birth
|
||||
print '<tr>';
|
||||
if (!empty($object->birthday))
|
||||
{
|
||||
if (!empty($object->birthday)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
print '<td>'.$langs->trans("DateOfBirth").'</td><td colspan="3">'.dol_print_date($object->birthday, "day");
|
||||
@ -278,14 +278,21 @@ if ($action == 'edit')
|
||||
//var_dump($birthdatearray);
|
||||
$ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970;
|
||||
$agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1;
|
||||
if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')';
|
||||
elseif ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')';
|
||||
else print '('.$agemonth.' '.$langs->trans("DurationMonth").')';
|
||||
if ($ageyear >= 2) {
|
||||
print '('.$ageyear.' '.$langs->trans("DurationYears").')';
|
||||
} elseif ($agemonth >= 2) {
|
||||
print '('.$agemonth.' '.$langs->trans("DurationMonths").')';
|
||||
} else {
|
||||
print '('.$agemonth.' '.$langs->trans("DurationMonth").')';
|
||||
}
|
||||
|
||||
|
||||
print ' - ';
|
||||
if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn");
|
||||
else print $langs->trans("BirthdayAlertOff");
|
||||
if ($object->birthday_alert) {
|
||||
print $langs->trans("BirthdayAlertOn");
|
||||
} else {
|
||||
print $langs->trans("BirthdayAlertOff");
|
||||
}
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td>'.$langs->trans("DateOfBirth").'</td><td colspan="3"></td>';
|
||||
@ -300,15 +307,12 @@ if ($action == 'edit')
|
||||
}
|
||||
|
||||
|
||||
if ($action != 'edit')
|
||||
{
|
||||
if ($action != 'edit') {
|
||||
// Barre d'actions
|
||||
if ($user->socid == 0)
|
||||
{
|
||||
if ($user->socid == 0) {
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($user->rights->societe->contact->creer) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
|
||||
|
||||
@ -39,8 +39,7 @@ $result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||
|
||||
|
||||
$result = $contact->fetch($id);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result <= 0) {
|
||||
dol_print_error($contact->error);
|
||||
exit;
|
||||
}
|
||||
@ -48,8 +47,7 @@ if ($result <= 0)
|
||||
$physicalperson = 1;
|
||||
|
||||
$company = new Societe($db);
|
||||
if ($contact->socid)
|
||||
{
|
||||
if ($contact->socid) {
|
||||
$result = $company->fetch($contact->socid);
|
||||
}
|
||||
|
||||
@ -76,33 +74,32 @@ $v->setNote($contact->note);
|
||||
$v->setTitle($contact->poste);
|
||||
|
||||
// Data from linked company
|
||||
if ($company->id)
|
||||
{
|
||||
if ($company->id) {
|
||||
$v->setURL($company->url, "TYPE=WORK");
|
||||
if (!$contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
|
||||
if (!$contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
|
||||
if (!$contact->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL");
|
||||
if (!$contact->phone_pro) {
|
||||
$v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
|
||||
}
|
||||
if (!$contact->fax) {
|
||||
$v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
|
||||
}
|
||||
if (!$contact->zip) {
|
||||
$v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL");
|
||||
}
|
||||
|
||||
// when company e-mail is empty, use only contact e-mail
|
||||
if (empty(trim($company->email)))
|
||||
{
|
||||
if (empty(trim($company->email))) {
|
||||
// was set before, don't set twice
|
||||
}
|
||||
// when contact e-mail is empty, use only company e-mail
|
||||
elseif (empty(trim($contact->email)))
|
||||
{
|
||||
} elseif (empty(trim($contact->email))) {
|
||||
// when contact e-mail is empty, use only company e-mail
|
||||
$v->setEmail($company->email);
|
||||
}
|
||||
// when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second)
|
||||
elseif (strtolower(end(explode("@", $contact->email))) == strtolower(end(explode("@", $company->email))))
|
||||
{
|
||||
} elseif (strtolower(end(explode("@", $contact->email))) == strtolower(end(explode("@", $company->email)))) {
|
||||
// when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second)
|
||||
$v->setEmail($contact->email);
|
||||
|
||||
// support by Microsoft Outlook (2019 and possible earlier)
|
||||
$v->setEmail($company->email, 'INTERNET');
|
||||
}
|
||||
// when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second)
|
||||
else {
|
||||
} else {
|
||||
// when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second)
|
||||
$v->setEmail($company->email);
|
||||
|
||||
// support by Microsoft Outlook (2019 and possible earlier)
|
||||
@ -110,12 +107,16 @@ if ($company->id)
|
||||
}
|
||||
|
||||
// Si contact lie a un tiers non de type "particulier"
|
||||
if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->name);
|
||||
if ($contact->typent_code != 'TE_PRIVATE') {
|
||||
$v->setOrg($company->name);
|
||||
}
|
||||
}
|
||||
|
||||
// Personal informations
|
||||
$v->setPhoneNumber($contact->phone_perso, "TYPE=HOME;VOICE");
|
||||
if ($contact->birthday) $v->setBirthday($contact->birthday);
|
||||
if ($contact->birthday) {
|
||||
$v->setBirthday($contact->birthday);
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user