NEW Move contacts of a thirdparty on tab Contacts/Addresses
This commit is contained in:
parent
7a0b8c3964
commit
fdc1aa2a03
@ -541,7 +541,7 @@ else
|
||||
{
|
||||
print '<tr><td><label for="socid">'.$langs->trans("ThirdParty").'</label></td>';
|
||||
print '<td colspan="3" class="maxwidthonsmartphone">';
|
||||
print $objsoc->getNomUrl(1);
|
||||
print $objsoc->getNomUrl(1, 'contact');
|
||||
print '</td>';
|
||||
print '<input type="hidden" name="socid" id="socid" value="'.$objsoc->id.'">';
|
||||
print '</td></tr>';
|
||||
@ -1063,7 +1063,7 @@ else
|
||||
$objsoc->fetch($object->socid);
|
||||
// Thirdparty
|
||||
$morehtmlref.=$langs->trans('ThirdParty') . ' : ';
|
||||
if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1);
|
||||
if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1, 'contact');
|
||||
else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany");
|
||||
}
|
||||
$morehtmlref.='</div>';
|
||||
|
||||
@ -301,7 +301,7 @@ class FormMail extends Form
|
||||
{
|
||||
$model_id=$this->param["models_id"];
|
||||
}
|
||||
$arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
|
||||
$arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, ($model_id ? $model_id : -1)); // we set -1 if model_id empty
|
||||
}
|
||||
//var_dump($this->param["models"]);
|
||||
//var_dump($model_id);
|
||||
@ -914,7 +914,7 @@ class FormMail extends Form
|
||||
* @param string $type_template Get message for type=$type_template, type='all' also included.
|
||||
* @param string $user Use template public or limited to this user
|
||||
* @param Translate $outputlangs Output lang object
|
||||
* @param int $id Id template to find
|
||||
* @param int $id Id of template to find, or -1 for first found with position = 0, or 0 for all
|
||||
* @param int $active 1=Only active template, 0=Only disabled, -1=All
|
||||
* @return array array('topic'=>,'content'=>,..)
|
||||
*/
|
||||
@ -929,8 +929,10 @@ class FormMail extends Form
|
||||
$sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned
|
||||
if ($active >= 0) $sql.=" AND active = ".$active;
|
||||
if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
|
||||
if (!empty($id)) $sql.= " AND rowid=".$id;
|
||||
if ($id > 0) $sql.= " AND rowid=".$id;
|
||||
if ($id == -1) $sql.= " AND position=0";
|
||||
$sql.= $db->order("position,lang,label","ASC");
|
||||
if ($id == -1) $sql.= $db->plimit(1);
|
||||
//print $sql;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
@ -48,6 +48,17 @@ function societe_prepare_head(Societe $object)
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
//$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = 0; // TODO
|
||||
$head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($object->client==1 || $object->client==2 || $object->client==3)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id;
|
||||
@ -748,7 +759,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
|
||||
|
||||
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print '<div class="div-table-responsive-nomin">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print "\n".'<table class="noborder" width="100%">'."\n";
|
||||
|
||||
$param="socid=".$object->id;
|
||||
|
||||
@ -48,6 +48,16 @@ function commande_prepare_head(Commande $object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
|
||||
|| ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire))
|
||||
{
|
||||
@ -60,16 +70,6 @@ function commande_prepare_head(Commande $object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
|
||||
@ -34,16 +34,19 @@ if ($action == 'presend')
|
||||
|
||||
$object->fetch_projet();
|
||||
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||
//
|
||||
if ($object->element == 'invoice_supplier')
|
||||
if (! in_array($object->element, array('societe', 'user')))
|
||||
{
|
||||
$fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id,2,0,0,$object,$object->element).$ref, preg_quote($ref,'/').'([^\-])+');
|
||||
}
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||
//
|
||||
if ($object->element == 'invoice_supplier')
|
||||
{
|
||||
$fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id,2,0,0,$object,$object->element).$ref, preg_quote($ref,'/').'([^\-])+');
|
||||
}
|
||||
|
||||
$file = $fileparams['fullname'];
|
||||
$file = $fileparams['fullname'];
|
||||
}
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
@ -72,16 +75,19 @@ if ($action == 'presend')
|
||||
}
|
||||
|
||||
// Build document if it not exists
|
||||
if (! $file || ! is_readable($file)) {
|
||||
if ($object->element != 'member')
|
||||
{
|
||||
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
exit();
|
||||
if (! in_array($object->element, array('societe', 'user')))
|
||||
{
|
||||
if (! $file || ! is_readable($file)) {
|
||||
if ($object->element != 'member')
|
||||
{
|
||||
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
exit();
|
||||
}
|
||||
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||
$file = $fileparams['fullname'];
|
||||
}
|
||||
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||
$file = $fileparams['fullname'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +112,7 @@ if ($action == 'presend')
|
||||
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
|
||||
{
|
||||
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id);
|
||||
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, $trackid);
|
||||
}
|
||||
$formmail->withfrom = 1;
|
||||
|
||||
|
||||
@ -87,8 +87,8 @@ PredefinedMailContentSendSupplierOrder=__CONTACTCIVNAME__\n\nYou will find here
|
||||
PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
|
||||
PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __SHIPPINGREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
|
||||
PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __FICHINTERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
|
||||
PredefinedMailContentThirdparty=__CONTACTCIVNAME__\n\n__PERSONALIZED__\n\n__SIGNATURE__
|
||||
PredefinedMailContentUser=aa__PERSONALIZED__\n\n__SIGNATURE__
|
||||
PredefinedMailContentThirdparty=\n\n__SIGNATURE__
|
||||
PredefinedMailContentUser=\n\n__SIGNATURE__
|
||||
DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available.
|
||||
ChooseYourDemoProfil=Choose the demo profile that best suits your needs...
|
||||
ChooseYourDemoProfilMore=...or build your own profile<br>(manual module selection)
|
||||
|
||||
@ -59,7 +59,7 @@ $action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view');
|
||||
$cancel = GETPOST('cancel','alpha');
|
||||
$backtopage = GETPOST('backtopage','alpha');
|
||||
$confirm = GETPOST('confirm');
|
||||
$socid = GETPOST('socid','int');
|
||||
$socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
if (empty($socid) && $action == 'view') $action='create';
|
||||
|
||||
@ -2372,69 +2372,68 @@ else
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
print '<div class="tabsAction">'."\n";
|
||||
if ($action != 'presend')
|
||||
{
|
||||
print '<div class="tabsAction">'."\n";
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook))
|
||||
{
|
||||
$at_least_one_email_contact = false;
|
||||
$TContact = $object->contact_array_objects();
|
||||
foreach ($TContact as &$contact)
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (!empty($contact->email))
|
||||
$at_least_one_email_contact = false;
|
||||
$TContact = $object->contact_array_objects();
|
||||
foreach ($TContact as &$contact)
|
||||
{
|
||||
$at_least_one_email_contact = true;
|
||||
break;
|
||||
if (!empty($contact->email))
|
||||
{
|
||||
$at_least_one_email_contact = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($object->email) || $at_least_one_email_contact)
|
||||
{
|
||||
$langs->load("mails");
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("mails");
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a></div>';
|
||||
}
|
||||
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
|
||||
}
|
||||
|
||||
if ($user->rights->societe->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=merge&socid='.$object->id.'" title="'.dol_escape_htmltag($langs->trans("MergeThirdparties")).'">'.$langs->trans('Merge').'</a></div>';
|
||||
}
|
||||
|
||||
if ($user->rights->societe->supprimer)
|
||||
{
|
||||
if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile
|
||||
{
|
||||
print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($object->email) || $at_least_one_email_contact)
|
||||
{
|
||||
$langs->load("mails");
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendMail').'</a></div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("mails");
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a></div>';
|
||||
}
|
||||
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
|
||||
}
|
||||
|
||||
if ($user->rights->societe->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=merge&socid='.$object->id.'" title="'.dol_escape_htmltag($langs->trans("MergeThirdparties")).'">'.$langs->trans('Merge').'</a></div>';
|
||||
}
|
||||
|
||||
if ($user->rights->societe->supprimer)
|
||||
{
|
||||
if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile
|
||||
{
|
||||
print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>'."\n";
|
||||
print '</div>'."\n";
|
||||
}
|
||||
|
||||
//Select mail models is same action as presend
|
||||
if (GETPOST('modelselected')) {
|
||||
$action = 'presend';
|
||||
}
|
||||
if ($action == 'presend')
|
||||
/*if ($action == 'presend')
|
||||
{
|
||||
/*
|
||||
* Affiche formulaire mail
|
||||
*/
|
||||
|
||||
// By default if $action=='presend'
|
||||
$titreform='SendMail';
|
||||
$topicmail='';
|
||||
@ -2491,31 +2490,6 @@ else
|
||||
$formmail->substit['__PERSONALIZED__']=''; // deprecated
|
||||
$formmail->substit['__CONTACTCIVNAME__']='';
|
||||
|
||||
//Find the good contact adress
|
||||
/*
|
||||
$custcontact='';
|
||||
$contactarr=array();
|
||||
$contactarr=$object->liste_contact(-1,'external');
|
||||
|
||||
if (is_array($contactarr) && count($contactarr)>0)
|
||||
{
|
||||
foreach($contactarr as $contact)
|
||||
{
|
||||
if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) {
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
|
||||
|
||||
$contactstatic=new Contact($db);
|
||||
$contactstatic->fetch($contact['id']);
|
||||
$custcontact=$contactstatic->getFullName($langs,1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($custcontact)) {
|
||||
$formmail->substit['__CONTACTCIVNAME__']=$custcontact;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// Tableau des parametres complementaires du post
|
||||
$formmail->param['action']=$action;
|
||||
@ -2533,14 +2507,15 @@ else
|
||||
print $formmail->get_form();
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
else
|
||||
}*/
|
||||
|
||||
if ($action != 'presend')
|
||||
{
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
|
||||
if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
|
||||
{
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
/*
|
||||
* Documents generes
|
||||
@ -2553,35 +2528,34 @@ else
|
||||
$var=true;
|
||||
|
||||
print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
|
||||
print '</div></div></div>';
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
print '<div class="fichecenter"><br></div>';
|
||||
|
||||
// Subsidiaries list
|
||||
if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES))
|
||||
{
|
||||
$result=show_subsidiaries($conf,$langs,$db,$object);
|
||||
$result=show_subsidiaries($conf,$langs,$db,$object);
|
||||
}
|
||||
|
||||
// Contacts list
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
$result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||
}
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
// Addresses list
|
||||
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
|
||||
{
|
||||
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||
}
|
||||
$MAX = 5;
|
||||
|
||||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAX); // Show all action for thirdparty
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
|
||||
// Presend form
|
||||
$modelmail='thirdparty';
|
||||
$defaulttopic='Information';
|
||||
$diroutput = $conf->societe->dir_output;
|
||||
$trackid = 'thi'.$object->id;
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1898,6 +1898,11 @@ class Societe extends CommonObject
|
||||
$label.= '<u>' . $langs->trans("ShowMargin") . '</u>';
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/margin/tabs/thirdpartyMargins.php?socid='.$this->id.'&type=1';
|
||||
}
|
||||
else if ($option == 'contact')
|
||||
{
|
||||
$label.= '<u>' . $langs->trans("ShowContacts") . '</u>';
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/contact.php?socid='.$this->id;
|
||||
}
|
||||
|
||||
// By default
|
||||
if (empty($linkstart))
|
||||
|
||||
218
htdocs/societe/contact.php
Normal file
218
htdocs/societe/contact.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
|
||||
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2013 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/societe/card.php
|
||||
* \ingroup societe
|
||||
* \brief Third party card page
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("commercial");
|
||||
$langs->load("bills");
|
||||
$langs->load("banks");
|
||||
$langs->load("users");
|
||||
if (! empty($conf->categorie->enabled)) $langs->load("categories");
|
||||
if (! empty($conf->incoterm->enabled)) $langs->load("incoterm");
|
||||
if (! empty($conf->notification->enabled)) $langs->load("mails");
|
||||
|
||||
$mesg=''; $error=0; $errors=array();
|
||||
|
||||
$action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view');
|
||||
$cancel = GETPOST('cancel','alpha');
|
||||
$backtopage = GETPOST('backtopage','alpha');
|
||||
$confirm = GETPOST('confirm');
|
||||
$socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
if (empty($socid) && $action == 'view') $action='create';
|
||||
|
||||
$object = new Societe($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('thirdpartycard','globalcard'));
|
||||
|
||||
if ($action == 'view' && $object->fetch($socid)<=0)
|
||||
{
|
||||
$langs->load("errors");
|
||||
print($langs->trans('ErrorRecordNotFound'));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
||||
$object->getCanvas($socid);
|
||||
$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
|
||||
$objcanvas=null;
|
||||
if (! empty($canvas))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
|
||||
$objcanvas = new Canvas($db, $action);
|
||||
$objcanvas->getCanvas('thirdparty', 'card', $canvas);
|
||||
}
|
||||
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters=array('id'=>$socid, '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 (empty($reshook))
|
||||
{
|
||||
if ($cancel)
|
||||
{
|
||||
$action='';
|
||||
if (! empty($backtopage))
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formadmin = new FormAdmin($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
if ($socid > 0 && empty($object->id))
|
||||
{
|
||||
$result=$object->fetch($socid);
|
||||
if ($result <= 0) dol_print_error('',$object->error);
|
||||
}
|
||||
|
||||
$title=$langs->trans("ThirdParty");
|
||||
if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card');
|
||||
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('',$title,$help_url);
|
||||
|
||||
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||
|
||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
{
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
|
||||
$objcanvas->display_canvas($action); // Show template
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels);
|
||||
//if ($res < 0) { dol_print_error($db); exit; }
|
||||
|
||||
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company');
|
||||
|
||||
// Confirm delete third party
|
||||
if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)))
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete");
|
||||
}
|
||||
|
||||
if ($action == 'merge')
|
||||
{
|
||||
$formquestion = array(
|
||||
array(
|
||||
'name' => 'soc_origin',
|
||||
'label' => $langs->trans('MergeOriginThirdparty'),
|
||||
'type' => 'other',
|
||||
'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200')
|
||||
)
|
||||
);
|
||||
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 200);
|
||||
}
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
|
||||
|
||||
|
||||
print '<div style="clear:both"></div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
if ($action != 'presend')
|
||||
{
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
// Contacts list
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
$result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||
}
|
||||
|
||||
// Addresses list
|
||||
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
|
||||
{
|
||||
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||
}
|
||||
|
||||
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
Loading…
Reference in New Issue
Block a user