Merge remote-tracking branch 'refs/remotes/Dolibarr/develop' into develop

This commit is contained in:
fappels 2017-09-26 16:13:17 +02:00
commit 35835a8b09
145 changed files with 5913 additions and 3143 deletions

View File

@ -17,8 +17,48 @@ Following changes may create regressions for some external modules, but were nec
__PROPALREF__, ...) __PROPALREF__, ...)
***** ChangeLog for 6.0.0 compared to 5.0.* ***** ***** ChangeLog for 6.0.1 compared to 6.0.* *****
FIX: #7000 Dashboard link for late pending payment supplier invoices do not work
FIX: #7325 Default VAT rate when editing template invoices is 0%
FIX: #7330
FIX: #7359
FIX: #7367
FIX: #7368
FIX: #7391
FIX: #7420
FIX: Add some missing attributes in Adherent:makeSubstitution (type, phone…
FIX: Bad const name
FIX: Bad link to unpayed suppliers invoices
FIX: Better protection to no send email when we change limit
FIX: Calculation in the activity box
FIX: Clean bad parameters when inserting line of template invoice
FIX: dateSelector was not taken into account
FIX: hidden option MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN
FIX: journalization for bank journal should not rely on a label.
FIX: menu enty when url is external link
FIX: missing supplier qty and supplier discount in available fields for product export.
FIX: multicompany better accuracy in rounding and with revenue stamp.
FIX: Must use pdf format page as default for merging PDF.
FIX: PDF output was sharing 2 different currencies in same total
FIX: Position of signature on strato template
FIX: Protection to avoid to apply credit note discount > remain to pay
FIX: Remove warning when using log into syslog
FIX: Responsive
FIX: Security fixes (filter onload js, less verbose error message in
FIX: SEPA recording payment must save one payment in bank per customer
FIX: Several problem with the last event box on project/tasks
FIX: Sign of amount in origin currency on credit note created from lines
FIX: Some page of admin were not responsive
FIX: SQL injection
FIX: time.php crashed without project id in param
FIX: transfer of line extrafields from order to invoice
FIX: Upgrade missing on field
FIX: View of timespent for another user
FIX: ODT generation
FIX: CVE-2017-9840, CVE-2017-14238, CVE-2017-14239, CVE-2017-14240, CVE-2017-14241,
CVE-2017-14242
***** ChangeLog for 6.0.0 compared to 5.0.* *****
NEW: Add experimental BlockeLog module (to log business events in a non reversible log file). NEW: Add experimental BlockeLog module (to log business events in a non reversible log file).
NEW: Add a payment module for Stripe. NEW: Add a payment module for Stripe.
NEW: Add module "Product variant" (like red, blue for the product shoes) NEW: Add module "Product variant" (like red, blue for the product shoes)

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2016 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2012-2016 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
@ -121,14 +121,22 @@ $hookmanager->initHooks(array('membercard','globalcard'));
* Actions * Actions
*/ */
if ($cancel) $action='';
$parameters=array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas); $parameters=array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $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))
{ {
if ($cancel)
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
$action='';
}
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
{ {
$error=0; $error=0;
@ -230,6 +238,7 @@ if (empty($reshook))
} }
} }
/*
if ($action == 'confirm_sendinfo' && $confirm == 'yes') if ($action == 'confirm_sendinfo' && $confirm == 'yes')
{ {
if ($object->email) if ($object->email)
@ -242,7 +251,7 @@ if (empty($reshook))
$langs->load("mails"); $langs->load("mails");
setEventMessages($langs->trans("MailSuccessfulySent", $from, $object->email), null, 'mesgs'); setEventMessages($langs->trans("MailSuccessfulySent", $from, $object->email), null, 'mesgs');
} }
} }*/
if ($action == 'update' && ! $cancel && $user->rights->adherent->creer) if ($action == 'update' && ! $cancel && $user->rights->adherent->creer)
{ {
@ -715,10 +724,21 @@ if (empty($reshook))
} }
} }
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to build doc // Actions to build doc
$upload_dir = $conf->adherent->dir_output; $upload_dir = $conf->adherent->dir_output;
$permissioncreate=$user->rights->adherent->creer; $permissioncreate=$user->rights->adherent->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
$trigger_name='MEMBER_SENTBYMAIL';
$paramname='id';
$mode='emailfrommember';
$trackid='mem'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
} }
@ -813,6 +833,7 @@ else
print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">'; print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
dol_fiche_head(''); dol_fiche_head('');
@ -956,8 +977,15 @@ else
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">'; print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />'; if (! empty($backtopage))
{
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
}
else
{
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
}
print '</div>'; print '</div>';
print "</form>\n"; print "</form>\n";
@ -1225,7 +1253,7 @@ else
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
@ -1344,10 +1372,10 @@ else
} }
// Confirm send card by mail // Confirm send card by mail
if ($action == 'sendinfo') /*if ($action == 'sendinfo')
{ {
print $form->formconfirm("card.php?rowid=".$id,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1); print $form->formconfirm("card.php?rowid=".$id,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1);
} }*/
// Confirm terminate // Confirm terminate
if ($action == 'resign') if ($action == 'resign')
@ -1590,6 +1618,31 @@ else
if (empty($reshook)) { if (empty($reshook)) {
if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty') if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty')
{ {
// Send
if ($object->statut == 1) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>';
}
// Send card by email
// TODO Remove this to replace with a template
/*
if ($user->rights->adherent->creer)
{
if ($object->statut >= 1)
{
if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a></div>\n";
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a></div>\n";
}
else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("SendCardByMail")."</font></div>";
}
}
else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</font></div>";
}*/
// Modify // Modify
if ($user->rights->adherent->creer) if ($user->rights->adherent->creer)
{ {
@ -1626,24 +1679,6 @@ else
} }
} }
// Send card by email
if ($user->rights->adherent->creer)
{
if ($object->statut >= 1)
{
if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a></div>\n";
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a></div>\n";
}
else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("SendCardByMail")."</font></div>";
}
}
else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</font></div>";
}
// Terminate // Terminate
if ($object->statut >= 1) if ($object->statut >= 1)
{ {
@ -1720,7 +1755,13 @@ else
} }
// Select mail models is same action as presend
if (GETPOST('modelselected')) {
$action = 'presend';
}
if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
@ -1759,13 +1800,20 @@ else
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element // List of actions on element
/* Already in tab Agenda/Events
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'member', $socid, 1); $somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', 10);
*/
print '</div></div></div>';
print '</div></div></div>';
}
// Presend form
$modelmail='member';
$defaulttopic='SendMemberRef';
$diroutput = $conf->adherent->dir_output;
$trackid = 'mem'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
} }
} }

View File

@ -213,8 +213,6 @@ class Adherent extends CommonObject
// Substitutions // Substitutions
$substitutionarray=array( $substitutionarray=array(
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
'__ID__'=>$msgishtml?dol_htmlentitiesbr($this->id):$this->id,
'__CIVILITY__'=>$this->getCivilityLabel(), '__CIVILITY__'=>$this->getCivilityLabel(),
'__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname, '__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
'__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname, '__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
@ -222,42 +220,16 @@ class Adherent extends CommonObject
'__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe, '__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):$this->address, '__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):$this->address,
'__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip, '__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'__TOWN_'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town, '__TOWN__'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'__COUNTRY__'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country, '__COUNTRY__'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
'__EMAIL__'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email, '__EMAIL__'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email,
'__BIRTH__'=>$msgishtml?dol_htmlentitiesbr($birthday):$birthday, '__BIRTH__'=>$msgishtml?dol_htmlentitiesbr($birthday):$birthday,
'__PHOTO__'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo, '__PHOTO__'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo,
'__LOGIN__'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login, '__LOGIN__'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login,
'__PASSWORD__'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass, '__PASSWORD__'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass,
// For backward compatibility '__PHONE__'=>$msgishtml?dol_htmlentitiesbr($this->phone):$this->phone,
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, '__PHONEPRO__'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):$this->phone_perso,
'%ID%'=>$msgishtml?dol_htmlentitiesbr($this->id):$this->id, '__PHONEMOBILE__'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):$this->phone_mobile,
'%CIVILITY%'=>$this->getCivilityLabel(),
'%FIRSTNAME%'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
'%LASTNAME%'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
'%FULLNAME%'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs),
'%COMPANY%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'%ADDRESS%'=>$msgishtml?dol_htmlentitiesbr($this->address):$this->address,
'%ZIP%'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'%TOWN%'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'%COUNTRY%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
'%EMAIL%'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email,
'%BIRTH%'=>$msgishtml?dol_htmlentitiesbr($birthday):$birthday,
'%PHOTO%'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo,
'%LOGIN%'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login,
'%PASSWORD%'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass,
'%TYPE%'=>$msgishtml?dol_htmlentitiesbr($this->type):$this->type,
'%PHONE_PRO%'=>$msgishtml?dol_htmlentitiesbr($this->phone):$this->phone,
'%PHONE_PERSO%'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):$this->phone_perso,
'%PHONE_MOBILE%'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):$this->phone_mobile,
// For backward compatibility
'%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos,
'%SOCIETE%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'%PRENOM%'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
'%NOM%'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
'%CP%'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'%VILLE%'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'%PAYS%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
); );
complete_substitutions_array($substitutionarray, $langs, $this); complete_substitutions_array($substitutionarray, $langs, $this);
@ -447,33 +419,33 @@ class Adherent extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql.= " civility = ".(!is_null($this->civility_id)?$this->db->escape($this->civility_id):"null"); $sql.= " civility = ".($this->civility_id>0?$this->db->escape($this->civility_id):"null");
$sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null"); $sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null");
$sql.= ", lastname=" .($this->lastname?"'".$this->db->escape($this->lastname)."'":"null"); $sql.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null");
$sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null"); $sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null");
$sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null"); $sql.= ", societe = ".($this->societe?"'".$this->db->escape($this->societe)."'":"null");
$sql.= ", fk_soc=" .($this->fk_soc > 0?$this->db->escape($this->fk_soc):"null"); $sql.= ", fk_soc = ".($this->fk_soc > 0?$this->db->escape($this->fk_soc):"null");
$sql.= ", address=" .($this->address?"'".$this->db->escape($this->address)."'":"null"); $sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", zip=" .($this->zip?"'".$this->db->escape($this->zip)."'":"null"); $sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null");
$sql.= ", town=" .($this->town?"'".$this->db->escape($this->town)."'":"null"); $sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null");
$sql.= ", country=".($this->country_id>0?$this->db->escape($this->country_id):"null"); $sql.= ", country = ".($this->country_id>0?$this->db->escape($this->country_id):"null");
$sql.= ", state_id=".($this->state_id>0?$this->db->escape($this->state_id):"null"); $sql.= ", state_id = ".($this->state_id>0?$this->db->escape($this->state_id):"null");
$sql.= ", email='".$this->db->escape($this->email)."'"; $sql.= ", email = '".$this->db->escape($this->email)."'";
$sql.= ", skype='".$this->db->escape($this->skype)."'"; $sql.= ", skype = '".$this->db->escape($this->skype)."'";
$sql.= ", phone=" .($this->phone?"'".$this->db->escape($this->phone)."'":"null"); $sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null");
$sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql.= ", phone_perso = ".($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
$sql.= ", phone_mobile=" .($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null"); $sql.= ", phone_mobile = ".($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null");
$sql.= ", note_private=" .($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", note_private = ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", note_public=" .($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", photo=" .($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null");
$sql.= ", public='".$this->db->escape($this->public)."'"; $sql.= ", public = '".$this->db->escape($this->public)."'";
$sql.= ", statut=" .$this->statut; $sql.= ", statut = ".$this->statut;
$sql.= ", fk_adherent_type=".$this->typeid; $sql.= ", fk_adherent_type = ".$this->typeid;
$sql.= ", morphy='".$this->db->escape($this->morphy)."'"; $sql.= ", morphy = '".$this->db->escape($this->morphy)."'";
$sql.= ", birth=" .($this->birth?"'".$this->db->idate($this->birth)."'":"null"); $sql.= ", birth = ".($this->birth?"'".$this->db->idate($this->birth)."'":"null");
if ($this->datefin) $sql.= ", datefin='".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription if ($this->datefin) $sql.= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
if ($this->datevalid) $sql.= ", datevalid='".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member if ($this->datevalid) $sql.= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member
$sql.= ", fk_user_mod=".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest $sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update update member", LOG_DEBUG); dol_syslog(get_class($this)."::update update member", LOG_DEBUG);
@ -748,7 +720,6 @@ class Adherent extends CommonObject
$error++; $error++;
$this->error .= $this->db->lasterror(); $this->error .= $this->db->lasterror();
$errorflag=-1; $errorflag=-1;
} }
// Remove subscription // Remove subscription
@ -1192,7 +1163,7 @@ class Adherent extends CommonObject
// Load other properties // Load other properties
$result=$this->fetch_subscriptions(); $result=$this->fetch_subscriptions();
return $result; return $this->id;
} }
else else
{ {

View File

@ -22,7 +22,6 @@
* \file htdocs/adherents/class/adherent_type.class.php * \file htdocs/adherents/class/adherent_type.class.php
* \ingroup member * \ingroup member
* \brief File of class to manage members types * \brief File of class to manage members types
* \author Rodolphe Quiedeville
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
@ -62,6 +61,8 @@ class AdherentType extends CommonObject
public $vote; public $vote;
/** @var bool Email sent during validation */ /** @var bool Email sent during validation */
public $mail_valid; public $mail_valid;
/** @var array Array of members */
public $members=array();
/** /**
@ -80,14 +81,19 @@ class AdherentType extends CommonObject
* Fonction qui permet de creer le status de l'adherent * Fonction qui permet de creer le status de l'adherent
* *
* @param User $user User making creation * @param User $user User making creation
* @param int $notrigger 1=do not execute triggers, 0 otherwise
* @return int >0 if OK, < 0 if KO * @return int >0 if OK, < 0 if KO
*/ */
function create($user) function create($user,$notrigger=0)
{ {
global $conf; global $conf;
$error=0;
$this->statut=(int) $this->statut; $this->statut=(int) $this->statut;
$this->label=(!empty($this->libelle)?trim($this->libelle):trim($this->label)); $this->label=trim($this->label);
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
$sql.= "libelle"; $sql.= "libelle";
@ -102,29 +108,58 @@ class AdherentType extends CommonObject
if ($result) if ($result)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type");
return $this->update($user);
$result = $this->update($user,1);
if ($result < 0)
{
$this->db->rollback();
return -3;
}
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
{
$this->db->commit();
return $this->id;
} }
else else
{ {
$this->error=$this->db->error().' sql='.$sql; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1; return -1;
} }
} }
/** /**
* Met a jour en base donnees du type * Met a jour en base donnees du type
* *
* @param User $user Object user making change * @param User $user Object user making change
* @param int $notrigger 1=do not execute triggers, 0 otherwise
* @return int >0 if OK, < 0 if KO * @return int >0 if OK, < 0 if KO
*/ */
function update($user) function update($user,$notrigger=0)
{ {
global $hookmanager,$conf; global $conf, $hookmanager;
$error=0; $error=0;
$this->label=(!empty($this->libelle)?trim($this->libelle):trim($this->label)); $this->label=trim($this->label);
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type "; $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
$sql.= "SET "; $sql.= "SET ";
@ -158,12 +193,30 @@ class AdherentType extends CommonObject
} }
else if ($reshook < 0) $error++; else if ($reshook < 0) $error++;
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error().' sql='.$sql; $this->db->rollback();
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -$error;
}
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1; return -1;
} }
} }
@ -171,31 +224,31 @@ class AdherentType extends CommonObject
/** /**
* Fonction qui permet de supprimer le status de l'adherent * Fonction qui permet de supprimer le status de l'adherent
* *
* @param int $rowid Id of member type to delete
* @return int >0 if OK, 0 if not found, < 0 if KO * @return int >0 if OK, 0 if not found, < 0 if KO
*/ */
function delete($rowid='') function delete()
{ {
if (empty($rowid)) $rowid=$this->id; global $user;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type WHERE rowid = ".$rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE rowid = ".$this->id;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
if ($this->db->affected_rows($resql)) // Call trigger
{ $result=$this->call_trigger('MEMBER_TYPE_DELETE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -2; }
// End call triggers
$this->db->commit();
return 1; return 1;
} }
else else
{ {
return 0; $this->db->rollback();
} $this->error=$this->db->lasterror();
} return -1;
else
{
print "Err : ".$this->db->error();
return 0;
} }
} }
@ -223,13 +276,13 @@ class AdherentType extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->label = $obj->label; $this->label = $obj->label;
$this->libelle = $obj->label; // For backward compatibility
$this->statut = $obj->statut; $this->statut = $obj->statut;
$this->subscription = $obj->subscription; $this->subscription = $obj->subscription;
$this->mail_valid = $obj->mail_valid; $this->mail_valid = $obj->mail_valid;
$this->note = $obj->note; $this->note = $obj->note;
$this->vote = $obj->vote; $this->vote = $obj->vote;
} }
return 1; return 1;
} }
else else
@ -250,7 +303,7 @@ class AdherentType extends CommonObject
$adherenttypes = array(); $adherenttypes = array();
$sql = "SELECT rowid, libelle"; $sql = "SELECT rowid, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE entity IN (".getEntity('adherent').")"; $sql.= " WHERE entity IN (".getEntity('adherent').")";
@ -266,7 +319,7 @@ class AdherentType extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$adherenttypes[$obj->rowid] = $langs->trans($obj->libelle); $adherenttypes[$obj->rowid] = $langs->trans($obj->label);
$i++; $i++;
} }
} }
@ -278,12 +331,61 @@ class AdherentType extends CommonObject
return $adherenttypes; return $adherenttypes;
} }
/**
* Return array of Member objects for member type this->id (or all if this->id not defined)
*
* @param string $excludefilter Filter to exclude
* @param int $mode 0=Return array of member instance, 1=Return array of members id only
* @return mixed Array of members or -1 on error
*/
function listMembersForMemberType($excludefilter='', $mode=0)
{
global $conf, $user;
$ret=array();
$sql = "SELECT a.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.entity IN (".getEntity('member').")";
$sql.= " AND a.fk_adherent_type = ".$this->id;
if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')';
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
if (! array_key_exists($obj->rowid, $ret))
{
if ($mode != 1)
{
$memberstatic=new Adherent($this->db);
$memberstatic->fetch($obj->rowid);
$ret[$obj->rowid]=$memberstatic;
}
else $ret[$obj->rowid]=$obj->rowid;
}
}
$this->db->free($resql);
$this->members=$ret;
return $ret;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
/** /**
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $maxlen length max libelle * @param int $maxlen length max label
* @return string String with URL * @return string String with URL
*/ */
function getNomUrl($withpicto=0,$maxlen=0) function getNomUrl($withpicto=0,$maxlen=0)
@ -291,7 +393,7 @@ class AdherentType extends CommonObject
global $langs; global $langs;
$result=''; $result='';
$label=$langs->trans("ShowTypeCard",$this->libelle); $label=$langs->trans("ShowTypeCard",$this->label);
$link = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $link = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>'; $linkend='</a>';
@ -300,11 +402,10 @@ class AdherentType extends CommonObject
if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto && $withpicto != 2) $result.=' ';
$result.=$link.($maxlen?dol_trunc($this->libelle,$maxlen):$this->libelle).$linkend; $result.=$link.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend;
return $result; return $result;
} }
/** /**
* getLibStatut * getLibStatut
* *
@ -315,6 +416,88 @@ class AdherentType extends CommonObject
return ''; return '';
} }
/**
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
*
* @param array $info Info array loaded by _load_ldap_info
* @param int $mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
* 1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
* 2=Return key only (uid=qqq)
* @return string DN
*/
function _load_ldap_dn($info,$mode=0)
{
global $conf;
$dn='';
if ($mode==0) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode==1) $dn=$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode==2) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
return $dn;
}
/**
* Initialize the info array (array of LDAP values) that will be used to call LDAP functions
*
* @return array Tableau info des attributs
*/
function _load_ldap_info()
{
global $conf,$langs;
$info=array();
// Object classes
$info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
// Champs
if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = $this->note;
if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS))
{
$valueofldapfield=array();
foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database.
{
$member=new Adherent($this->db);
$member->fetch($val->id);
$info2 = $member->_load_ldap_info();
$valueofldapfield[] = $member->_load_ldap_dn($info2);
}
$info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:'');
}
return $info;
}
/**
* Initialise an instance with random values.
* Used to build previews or test instances.
* id must be 0 if object instance is a specimen.
*
* @return void
*/
function initAsSpecimen()
{
global $conf, $user, $langs;
// Initialise parametres
$this->id = 0;
$this->ref = 0;
$this->specimen=1;
$this->label='MEMBERS TYPE SPECIMEN';
$this->note='This is a note';
$this->mail_valid='This is welcome email';
$this->subscription=1;
$this->vote=0;
$this->statut=1;
// Members of this member type is just me
$this->members=array(
$user->id => $user
);
}
/** /**
* getMailOnValid * getMailOnValid
* *
@ -342,6 +525,7 @@ class AdherentType extends CommonObject
function getMailOnSubscription() function getMailOnSubscription()
{ {
global $conf; global $conf;
// mail_subscription not defined so never used // mail_subscription not defined so never used
if (! empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined if (! empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined
{ {
@ -361,6 +545,7 @@ class AdherentType extends CommonObject
function getMailOnResiliate() function getMailOnResiliate()
{ {
global $conf; global $conf;
// NOTE mail_resiliate not defined so never used // NOTE mail_resiliate not defined so never used
if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined
{ {
@ -371,4 +556,5 @@ class AdherentType extends CommonObject
return $conf->global->ADHERENT_MAIL_RESIL; return $conf->global->ADHERENT_MAIL_RESIL;
} }
} }
} }

View File

@ -272,7 +272,6 @@ class MembersTypes extends DolibarrApi
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
unset($object->cotisation); unset($object->cotisation);
unset($object->libelle);
unset($object->array_options); unset($object->array_options);
unset($object->linkedObjectsIds); unset($object->linkedObjectsIds);

View File

@ -59,7 +59,7 @@ $AdherentsResilies=array();
$AdherentType=array(); $AdherentType=array();
// Liste les adherents // Liste les adherents
$sql = "SELECT t.rowid, t.libelle, t.subscription,"; $sql = "SELECT t.rowid, t.libelle as label, t.subscription,";
$sql.= " d.statut, count(d.rowid) as somme"; $sql.= " d.statut, count(d.rowid) as somme";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d";
@ -81,7 +81,7 @@ if ($result)
$adhtype=new AdherentType($db); $adhtype=new AdherentType($db);
$adhtype->id=$objp->rowid; $adhtype->id=$objp->rowid;
$adhtype->subscription=$objp->subscription; $adhtype->subscription=$objp->subscription;
$adhtype->libelle=$objp->libelle; $adhtype->label=$objp->label;
$AdherentType[$objp->rowid]=$adhtype; $AdherentType[$objp->rowid]=$adhtype;
if ($objp->statut == -1) { $MemberToValidate[$objp->rowid]=$objp->somme; } if ($objp->statut == -1) { $MemberToValidate[$objp->rowid]=$objp->somme; }
@ -273,7 +273,7 @@ $max=5;
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
$sql.= " a.tms as datem, datefin as date_end_subscription,"; $sql.= " a.tms as datem, datefin as date_end_subscription,";
$sql.= " ta.rowid as typeid, ta.libelle, ta.subscription"; $sql.= " ta.rowid as typeid, ta.libelle as label, ta.subscription";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
$sql.= " WHERE a.entity IN (".getEntity('adherent').")"; $sql.= " WHERE a.entity IN (".getEntity('adherent').")";
$sql.= " AND a.fk_adherent_type = ta.rowid"; $sql.= " AND a.fk_adherent_type = ta.rowid";
@ -310,7 +310,7 @@ if ($resql)
} }
$staticmember->ref=$staticmember->getFullName($langs); $staticmember->ref=$staticmember->getFullName($langs);
$statictype->id=$obj->typeid; $statictype->id=$obj->typeid;
$statictype->libelle=$obj->libelle; $statictype->label=$obj->label;
print '<td>'.$staticmember->getNomUrl(1,32).'</td>'; print '<td>'.$staticmember->getNomUrl(1,32).'</td>';
print '<td>'.$statictype->getNomUrl(1,32).'</td>'; print '<td>'.$statictype->getNomUrl(1,32).'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datem),'dayhour').'</td>'; print '<td>'.dol_print_date($db->jdate($obj->datem),'dayhour').'</td>';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2006-2017 Regis Houssin <regis.houssin@capnetworks.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -218,13 +218,11 @@ if ($result > 0)
} }
else else
{ {
dol_print_error('',$ldap->error); setEventMessages($ldap->error, $ldap->errors, 'errors');
} }
print '</table>'; print '</table>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -315,7 +315,7 @@ if ($search_type > 0)
{ {
$membertype=new AdherentType($db); $membertype=new AdherentType($db);
$result=$membertype->fetch(GETPOST("type",'int')); $result=$membertype->fetch(GETPOST("type",'int'));
$titre.=" (".$membertype->libelle.")"; $titre.=" (".$membertype->label.")";
} }
$param=''; $param='';
@ -698,7 +698,7 @@ while ($i < min($num, $limit))
if (! empty($arrayfields['t.libelle']['checked'])) if (! empty($arrayfields['t.libelle']['checked']))
{ {
$membertypestatic->id=$obj->type_id; $membertypestatic->id=$obj->type_id;
$membertypestatic->libelle=$obj->type; $membertypestatic->label=$obj->type;
print '<td class="nowrap">'; print '<td class="nowrap">';
print $membertypestatic->getNomUrl(1,32); print $membertypestatic->getNomUrl(1,32);
print '</td>'; print '</td>';

View File

@ -37,6 +37,7 @@ $langs->load("members");
$rowid = GETPOST('rowid','int'); $rowid = GETPOST('rowid','int');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$cancel = GETPOST('cancel','alpha'); $cancel = GETPOST('cancel','alpha');
$backtopage = GETPOST('backtopage','alpha');
$search_lastname = GETPOST('search_lastname','alpha'); $search_lastname = GETPOST('search_lastname','alpha');
$search_login = GETPOST('search_login','alpha'); $search_login = GETPOST('search_login','alpha');
@ -64,6 +65,8 @@ $mail_valid=GETPOST("mail_valid");
// Security check // Security check
$result=restrictedArea($user,'adherent',$rowid,'adherent_type'); $result=restrictedArea($user,'adherent',$rowid,'adherent_type');
$object = new AdherentType($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels // fetch optionals attributes and labels
@ -87,23 +90,47 @@ $hookmanager->initHooks(array('membertypecard','globalcard'));
* Actions * Actions
*/ */
if ($cancel) {
$action='';
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
}
if ($action == 'add' && $user->rights->adherent->configurer) if ($action == 'add' && $user->rights->adherent->configurer)
{ {
if (! $cancel)
{
$object = new AdherentType($db);
$object->label = trim($label); $object->label = trim($label);
$object->subscription = (int) trim($subscription); $object->subscription = (int) trim($subscription);
$object->note = trim($comment); $object->note = trim($comment);
$object->mail_valid = (boolean) trim($mail_valid); $object->mail_valid = trim($mail_valid);
$object->vote = (boolean) trim($vote); $object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
if ($object->label) if (empty($object->label)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors');
}
else {
$sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
}
if ($num) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorLabelAlreadyExists",$login), null, 'errors');
}
}
if (! $error)
{ {
$id=$object->create($user); $id=$object->create($user);
if ($id > 0) if ($id > 0)
@ -113,47 +140,63 @@ if ($action == 'add' && $user->rights->adherent->configurer)
} }
else else
{ {
$mesg=$object->error; setEventMessages($object->error, $object->errors, 'errors');
$action = 'create'; $action = 'create';
} }
} }
else else
{ {
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
$action = 'create'; $action = 'create';
} }
}
} }
if ($action == 'update' && $user->rights->adherent->configurer) if ($action == 'update' && $user->rights->adherent->configurer)
{ {
if (! $cancel) $object->fetch($rowid);
{
$object = new AdherentType($db); $object->oldcopy = clone $object;
$object->id = $rowid;
$object->label = trim($label); $object->label = trim($label);
$object->subscription = (int) trim($subscription); $object->subscription = (int) trim($subscription);
$object->note = trim($comment); $object->note = trim($comment);
$object->mail_valid = (boolean) trim($mail_valid); $object->mail_valid = trim($mail_valid);
$object->vote = (boolean) trim($vote); $object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
$object->update($user); $ret=$object->update($user);
header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$_POST["rowid"]); if ($ret >= 0 && ! count($object->errors))
exit; {
setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs');
} }
else
{
setEventMessages($object->error, $object->errors, 'errors');
}
header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
exit;
} }
if ($action == 'delete' && $user->rights->adherent->configurer) if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
{ {
$object = new AdherentType($db); $object->fetch($rowid);
$object->delete($rowid); $res=$object->delete();
if ($res > 0)
{
setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
}
else
{
setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
$action='';
}
} }
@ -308,7 +351,15 @@ if ($rowid > 0)
{ {
$object = new AdherentType($db); $object = new AdherentType($db);
$object->fetch($rowid); $object->fetch($rowid);
$object->fetch_optionals($rowid,$extralabels); $object->fetch_optionals($object->id,$extralabels);
/*
* Confirmation suppression
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAMemberType"),$langs->trans("ConfirmDeleteMemberType",$object->label),"confirm_delete", '',0,1);
}
$head = member_type_prepare_head($object); $head = member_type_prepare_head($object);
@ -345,7 +396,6 @@ if ($rowid > 0)
dol_fiche_end(); dol_fiche_end();
/* /*
* Buttons * Buttons
*/ */
@ -359,7 +409,7 @@ if ($rowid > 0)
} }
// Add // Add
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'">'.$langs->trans("AddMember").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
// Delete // Delete
if ($user->rights->adherent->configurer) if ($user->rights->adherent->configurer)
@ -459,7 +509,7 @@ if ($rowid > 0)
$titre.=" (".$membertype->label.")"; $titre.=" (".$membertype->label.")";
} }
$param="&rowid=".$rowid; $param="&rowid=".$object->id;
if (! empty($status)) $param.="&status=".$status; if (! empty($status)) $param.="&status=".$status;
if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname; if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname;
if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname; if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname;
@ -473,7 +523,7 @@ if ($rowid > 0)
} }
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input class="flat" type="hidden" name="rowid" value="'.$rowid.'" size="12"></td>'; print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
print '<br>'; print '<br>';
print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
@ -593,12 +643,12 @@ if ($rowid > 0)
print '<td align="center">'; print '<td align="center">';
if ($user->rights->adherent->creer) if ($user->rights->adherent->creer)
{ {
print '<a href="card.php?rowid='.$objp->rowid.'&action=edit&return=list.php">'.img_edit().'</a>'; print '<a href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
} }
print '&nbsp;'; print '&nbsp;';
if ($user->rights->adherent->supprimer) if ($user->rights->adherent->supprimer)
{ {
print '<a href="card.php?rowid='.$objp->rowid.'&action=resign&return=list.php">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>'; print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
} }
print "</td>"; print "</td>";
@ -631,15 +681,14 @@ if ($rowid > 0)
if ($action == 'edit') if ($action == 'edit')
{ {
$object = new AdherentType($db); $object = new AdherentType($db);
$object->id = $rowid;
$object->fetch($rowid); $object->fetch($rowid);
$object->fetch_optionals($rowid,$extralabels); $object->fetch_optionals($object->id,$extralabels);
$head = member_type_prepare_head($object); $head = member_type_prepare_head($object);
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">'; print '<input type="hidden" name="rowid" value="'.$object->id.'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
@ -706,7 +755,7 @@ if ($rowid > 0)
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print "</form>"; print "</form>";

View File

@ -0,0 +1,191 @@
<?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2017 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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/adherents/type_ldap.php
* \ingroup ldap
* \brief Page fiche LDAP members types
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
$langs->load("members");
$langs->load("admin");
$langs->load("ldap");
$id = GETPOST('rowid', 'int');
$action = GETPOST('action','alpha');
// Security check
$result=restrictedArea($user,'adherent',$id,'adherent_type');
$object = new AdherentType($db);
$object->fetch($id);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('membertypeldapcard','globalcard'));
/*
* Actions
*/
$parameters=array();
$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 ($action == 'dolibarr2ldap')
{
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result > 0)
{
$object->listMembersForMemberType();
$info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info);
$olddn = $dn; // We can say that old dn = dn as we force synchro
$result = $ldap->update($dn, $info, $user, $olddn);
}
if ($result >= 0) {
setEventMessages($langs->trans("MemberTypeSynchronized"), null, 'mesgs');
}
else {
setEventMessages($ldap->error, $ldap->errors, 'errors');
}
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
$head = member_type_prepare_head($object);
dol_fiche_head($head, 'ldap', $langs->trans("MemberType"), -1, 'group');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// LDAP DN
print '<tr><td>LDAP '.$langs->trans("LDAPMemberTypeDn").'</td><td class="valeur">'.$conf->global->LDAP_MEMBER_TYPE_DN."</td></tr>\n";
// LDAP Cle
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_MEMBERS_TYPES."</td></tr>\n";
// LDAP Server
print '<tr><td>LDAP '.$langs->trans("Type").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_TYPE."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("Version").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PROTOCOLVERSION."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
print '</table>';
print '</div>';
dol_fiche_end();
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
}
print "</div>\n";
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) print "<br>\n";
// Affichage attributs LDAP
print load_fiche_titre($langs->trans("LDAPInformationsForThisMemberType"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("LDAPAttributes").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print '</tr>';
// Lecture LDAP
$ldap=new Ldap();
$result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info,1);
$search = "(".$object->_load_ldap_dn($info,2).")";
$records = $ldap->getAttribute($dn,$search);
//print_r($records);
// Affichage arbre
if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{
if (! is_array($records))
{
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
}
else
{
$result=show_ldap_content($records,0,$records['count'],true);
}
}
else
{
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
}
$ldap->unbind();
$ldap->close();
}
else
{
setEventMessages($ldap->error, $ldap->errors, 'errors');
}
print '</table>';
llxFooter();
$db->close();

View File

@ -620,6 +620,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
if ($value == 'color' && empty($_POST['color'])) continue; if ($value == 'color' && empty($_POST['color'])) continue;
if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'formula' && empty($_POST['formula'])) continue;
if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position'
if ((! isset($_POST[$value]) || $_POST[$value]=='') if ((! isset($_POST[$value]) || $_POST[$value]=='')
&& (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy')) // Fields that are not mandatory && (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy')) // Fields that are not mandatory
&& (! ($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10 && (! ($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10
@ -735,7 +736,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql.=","; if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position'
{
$sql.="'".(int) $db->escape($_POST['position'])."'";
}
elseif ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
@ -784,7 +789,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
} }
if ($i) $sql.=","; if ($i) $sql.=",";
$sql.= $field."="; $sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position'
{
$sql.="'".(int) $db->escape($_POST['position'])."'";
}
elseif ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
@ -1903,6 +1912,8 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
} }
else else
{ {
if ($fieldlist[$field]=='sortorder') $fieldlist[$field]='position';
$classtd=''; $class=''; $classtd=''; $class='';
if ($fieldlist[$field]=='code') $classtd='width100'; if ($fieldlist[$field]=='code') $classtd='width100';
if ($fieldlist[$field]=='affect') $class='maxwidth50'; if ($fieldlist[$field]=='affect') $class='maxwidth50';

View File

@ -65,3 +65,4 @@ try {
else if ($trace[0]['args'][0] == 401) die('Bad auth key'); else if ($trace[0]['args'][0] == 401) die('Bad auth key');
else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
} }

View File

@ -82,8 +82,8 @@ if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACK
if ($action == 'update') if ($action == 'update')
{ {
dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["main_lang_default"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["main_multilangs"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"],'chaine',0,'',$conf->entity);
@ -230,15 +230,15 @@ if ($action == 'edit') // Edit
print '</tr>'; print '</tr>';
// Default language // Default language
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'main_lang_default', 1, 0, 0, 0, 0, 'minwidth300'); print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300');
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Multilingual GUI // Multilingual GUI
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1); print $form->selectyesno('MAIN_MULTILANGS',$conf->global->MAIN_MULTILANGS,1);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
@ -349,9 +349,8 @@ if ($action == 'edit') // Edit
print '</tr>'; print '</tr>';
// Message of the day on home page // Message of the day on home page
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'));
complete_substitutions_array($substitutionarray, $langs); complete_substitutions_array($substitutionarray, $langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey');
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
@ -359,7 +358,7 @@ if ($action == 'edit') // Edit
{ {
$texthelp.=$key.'<br>'; $texthelp.=$key.'<br>';
} }
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, ''); print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday');
print '</td><td colspan="2">'; print '</td><td colspan="2">';
@ -379,16 +378,15 @@ if ($action == 'edit') // Edit
print '</tr>'; print '</tr>';
// Message on login page // Message on login page
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','user')); $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount','user'));
complete_substitutions_array($substitutionarray, $langs); complete_substitutions_array($substitutionarray, $langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey');
print '<tr><td>'; print '<tr><td>';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val) foreach($substitutionarray as $key => $val)
{ {
$texthelp.=$key.'<br>'; $texthelp.=$key.'<br>';
} }
print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, ''); print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin');
print '</td><td colspan="2">'; print '</td><td colspan="2">';
$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); $doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
$doleditor->Create(); $doleditor->Create();

View File

@ -68,6 +68,7 @@ if (empty($reshook))
if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE',GETPOST("activesynchro"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE',GETPOST("activesynchro"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE',GETPOST("activecontact"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE',GETPOST("activecontact"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE',GETPOST("activemembers"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE',GETPOST("activemembers"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE',GETPOST("activememberstypes"),'chaine',0,'',$conf->entity)) $error++;
if (! $error) if (! $error)
{ {
@ -135,7 +136,6 @@ print '</td></tr>';
// Synchro contact active // Synchro contact active
if (! empty($conf->societe->enabled)) if (! empty($conf->societe->enabled))
{ {
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnContactActive").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnContactActive").'</td><td>';
$arraylist=array(); $arraylist=array();
$arraylist['0']=$langs->trans("No"); $arraylist['0']=$langs->trans("No");
@ -147,7 +147,6 @@ if (! empty($conf->societe->enabled))
// Synchro member active // Synchro member active
if (! empty($conf->adherent->enabled)) if (! empty($conf->adherent->enabled))
{ {
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberActive").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberActive").'</td><td>';
$arraylist=array(); $arraylist=array();
$arraylist['0']=$langs->trans("No"); $arraylist['0']=$langs->trans("No");
@ -157,6 +156,18 @@ if (! empty($conf->adherent->enabled))
print '</td><td>'.$langs->trans("LDAPDnMemberActiveExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPDnMemberActiveExample").'</td></tr>';
} }
// Synchro member type active
if (! empty($conf->adherent->enabled))
{
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberTypeActive").'</td><td>';
$arraylist=array();
$arraylist['0']=$langs->trans("No");
$arraylist['1']=$langs->trans("DolibarrToLDAP");
$arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
print $form->selectarray('activememberstypes',$arraylist,$conf->global->LDAP_MEMBER_TYPE_ACTIVE);
print '</td><td>'.$langs->trans("LDAPDnMemberTypeActiveExample").'</td></tr>';
}
// Fields from hook // Fields from hook
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('addAdminLdapOptions',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('addAdminLdapOptions',$parameters); // Note that $action and $object may have been modified by hook

View File

@ -220,8 +220,9 @@ if (function_exists("ldap_connect"))
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
// Get a gid number for objectclass PosixGroup // Get a gid number for objectclass PosixGroup
if(in_array('posixGroup',$info['objectclass'])) if (in_array('posixGroup',$info['objectclass'])) {
$info['gidNumber'] = $ldap->getNextGroupGid(); $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
}
$result1=$ldap->delete($dn); // To be sure to delete existing records $result1=$ldap->delete($dn); // To be sure to delete existing records
$result2=$ldap->add($dn,$info,$user); // Now the test $result2=$ldap->add($dn,$info,$user); // Now the test

View File

@ -0,0 +1,252 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
*
* 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/admin/ldap_members_types.php
* \ingroup ldap
* \brief Page to setup LDAP synchronization for members types
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
$langs->load("admin");
$langs->load("errors");
if (!$user->admin)
accessforbidden();
$action = GETPOST('action','aZ09');
/*
* Actions
*/
if ($action == 'setvalue' && $user->admin)
{
$error=0;
$db->begin();
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN',GETPOST("membertype"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME',GETPOST("fieldfullname"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS',GETPOST("fieldmembertypemembers"),'chaine',0,'',$conf->entity)) $error++;
// This one must be after the others
$valkey='';
$key=GETPOST("key");
if ($key) $valkey=$conf->global->$key;
if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES',$valkey,'chaine',0,'',$conf->entity)) $error++;
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
dol_print_error($db);
}
}
/*
* View
*/
llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("LDAPSetup"),$linkback,'title_setup');
$head = ldap_prepare_head();
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
}
dol_fiche_head($head, 'memberstypes', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescMembersTypes").'<br>';
print '<br>';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$form=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("LDAPSynchronizeMembersTypes").'</td>';
print "</tr>\n";
// DN pour les types de membres
print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberTypeDn").'</span></td><td>';
print '<input size="48" type="text" name="membertype" value="'.$conf->global->LDAP_MEMBER_TYPE_DN.'">';
print '</td><td>'.$langs->trans("LDAPMemberTypepDnExample").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
// List of object class used to define attributes in structure
print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberTypeObjectClassList").'</span></td><td>';
print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS.'">';
print '</td><td>'.$langs->trans("LDAPMemberTypeObjectClassListExample").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
print '</table>';
print '<br>';
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
// Filtre
// Common name
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldCommonNameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)?' checked':'')."></td>";
print '</tr>';
// Description
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION.'">';
print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBER_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)?' checked':'')."></td>";
print '</tr>';
// User group
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldGroupMembers").'</td><td>';
print '<input size="25" type="text" name="fieldmembertypemembers" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS.'">';
print '</td><td>'.$langs->trans("LDAPFieldGroupMembersExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)?' checked':'')."></td>";
print '</tr>';
print '</table>';
print info_admin($langs->trans("LDAPDescValues"));
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
print '</form>';
/*
* Test de la connexion
*/
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
{
$butlabel=$langs->trans("LDAPTestSynchroMemberType");
$testlabel='testmembertype';
$key=$conf->global->LDAP_KEY_MEMBERS_TYPES;
$dn=$conf->global->LDAP_MEMBER_TYPE_DN;
$objectclass=$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS;
show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass);
}
if (function_exists("ldap_connect"))
{
if ($_GET["action"] == 'testmembertype')
{
// Creation objet
$object=new AdherentType($db);
$object->initAsSpecimen();
// Test synchro
$ldap=new Ldap();
$result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
// Get a gid number for objectclass PosixGroup
if (in_array('posixGroup',$info['objectclass'])) {
$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPES');
}
$result1=$ldap->delete($dn); // To be sure to delete existing records
$result2=$ldap->add($dn,$info,$user); // Now the test
$result3=$ldap->delete($dn); // Clean what we did
if ($result2 > 0)
{
print img_picto('','info').' ';
print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
}
else
{
print img_picto('','error').' ';
print '<font class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
print ': '.$ldap->error;
print '</font><br>';
print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
}
print "<br>\n";
print "LDAP input file used for test:<br><br>\n";
print nl2br($ldap->dump_content($dn,$info));
print "\n<br>";
}
else
{
print img_picto('','error').' ';
print '<font class="error">'.$langs->trans("LDAPSynchroKO");
print ': '.$ldap->error;
print '</font><br>';
print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
}
}
}
llxFooter();
$db->close();

View File

@ -78,6 +78,9 @@ $offset = $listlimit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (empty($sortfield)) $sortfield='label, lang, position';
if (empty($sortorder)) $sortorder='ASC';
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('emailtemplates')); $hookmanager->initHooks(array('emailtemplates'));
@ -87,7 +90,7 @@ $tabname[25]= MAIN_DB_PREFIX."c_email_templates";
// Criteria to sort dictionaries // Criteria to sort dictionaries
$tabsqlsort=array(); $tabsqlsort=array();
$tabsqlsort[25]="label ASC"; $tabsqlsort[25]="label ASC, lang ASC, position ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire // Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array(); $tabfield=array();
@ -122,17 +125,30 @@ $formmail=new FormMail($db);
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{ {
$tmp=FormMail::getAvailableSubstitKey('formemail'); $tmp=FormMail::getAvailableSubstitKey('formemail');
$tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__'; $tmp['__(AnyTranslationKey)__']='Translation';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp); $helpsubstit = $langs->trans("AvailableVariables").':<br>';
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp); $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
foreach($tmp as $key => $val)
{
$helpsubstit.=$key.' -> '.$val.'<br>';
$helpsubstitforlines.=$key.' -> '.$val.'<br>';
}
} }
else else
{ {
$tmp=FormMail::getAvailableSubstitKey('formemailwithlines'); $tmp=FormMail::getAvailableSubstitKey('formemailwithlines');
$tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__'; $tmp['__(AnyTranslationKey)__']='Translation';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp); $helpsubstit = $langs->trans("AvailableVariables").':<br>';
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
foreach($tmp as $key => $val)
{
$helpsubstit.=$key.' -> '.$val.'<br>';
}
$tmp=FormMail::getAvailableSubstitKey('formemailforlines'); $tmp=FormMail::getAvailableSubstitKey('formemailforlines');
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp); foreach($tmp as $key => $val)
{
$helpsubstitforlines.=$key.' -> '.$val.'<br>';
}
} }
@ -159,6 +175,7 @@ if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$l
if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder'); if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder');
if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice'); if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice');
if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty');
if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember');
if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract');
$elementList['all']=$langs->trans('VisibleEverywhere'); $elementList['all']=$langs->trans('VisibleEverywhere');
$elementList['none']=$langs->trans('VisibleNowhere'); $elementList['none']=$langs->trans('VisibleNowhere');
@ -217,7 +234,7 @@ if (empty($reshook))
if ($value == 'content') $value='content-'.$rowid; if ($value == 'content') $value='content-'.$rowid;
if ($value == 'content_lines') $value='content_lines-'.$rowid; if ($value == 'content_lines') $value='content_lines-'.$rowid;
if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user') if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
{ {
$ok=0; $ok=0;
$fieldnamekey=$listfield[$f]; $fieldnamekey=$listfield[$f];
@ -270,10 +287,9 @@ if (empty($reshook))
$i=0; $i=0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value)
{ {
//var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
$keycode=$listfieldvalue[$i]; $keycode=$listfieldvalue[$i];
if ($value == 'lang') $keycode='langcode'; if ($value == 'lang') $keycode='langcode';
//var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
if ($value == 'entity') $_POST[$keycode] = $conf->entity; if ($value == 'entity') $_POST[$keycode] = $conf->entity;
if ($i) $sql.=","; if ($i) $sql.=",";
if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]=''; if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]='';
@ -520,7 +536,7 @@ foreach ($fieldlist as $field => $value)
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow=$langs->trans($valuetoshow); // try to translate
$align="left"; $align="left";
if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner");} if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner");}
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='lang') { $valuetoshow=(empty($conf->global->MAIN_MULTILANGS) ? '&nbsp;' : $langs->trans("Language")); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
@ -573,7 +589,7 @@ $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook))
{ {
if ($tabname[$id] == MAIN_DB_PREFIX . 'c_email_templates' && $action == 'edit') { if ($action == 'edit') {
fieldList($fieldlist, $obj, $tabname[$id], 'hide'); fieldList($fieldlist, $obj, $tabname[$id], 'hide');
} else { } else {
fieldList($fieldlist, $obj, $tabname[$id], 'add'); fieldList($fieldlist, $obj, $tabname[$id], 'add');
@ -681,6 +697,10 @@ if ($resql)
print '</td>'; print '</td>';
} }
elseif ($value == 'topic') print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>'; elseif ($value == 'topic') print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
elseif ($value == 'type_template')
{
print '<td class="liste_titre">'.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100onsmartphone').'</td>';
}
elseif (! in_array($value, array('content', 'content_lines'))) print '<td class="liste_titre"></td>'; elseif (! in_array($value, array('content', 'content_lines'))) print '<td class="liste_titre"></td>';
} }
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>'; if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>';
@ -829,6 +849,8 @@ if ($resql)
if ($value == 'private') if ($value == 'private')
{ {
$align="center"; $align="center";
if ($valuetoshow) $valuetoshow=yn($valuetoshow);
else $valuetoshow='';
} }
if ($value == 'position') if ($value == 'position')
{ {
@ -1032,9 +1054,17 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" '; if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
print '<td'.($classtd?' class="'.$classtd.'"':'').'>'; print '<td'.($classtd?' class="'.$classtd.'"':'').'>';
if ($fieldlist[$field]=='private' && empty($user->admin)) if ($fieldlist[$field]=='private')
{ {
print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="1" name="'.$fieldlist[$field].'">'; if (empty($user->admin))
{
print $form->selectyesno($fieldlist[$field], '1', 1);
}
else
{
//print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="1" name="'.$fieldlist[$field].'">';
print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
}
} }
else else
{ {

View File

@ -78,23 +78,35 @@ if (preg_match('/del_(.*)/',$action,$reg))
if ($action == 'add_currency') if ($action == 'add_currency')
{ {
$error=0;
$langs->loadCacheCurrencies(''); $langs->loadCacheCurrencies('');
$code = GETPOST('code', 'alpha'); $code = GETPOST('code', 'alpha');
$rate = GETPOST('rate', 'alpha'); $rate = price2num(GETPOST('rate', 'alpha'));
$currency = new MultiCurrency($db); $currency = new MultiCurrency($db);
$currency->code = $code; $currency->code = $code;
$currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code; $currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code;
if (empty($rate))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
$error++;
}
if (! $error)
{
if ($currency->create($user) > 0) if ($currency->create($user) > 0)
{ {
if ($currency->addRate($rate)) setEventMessages($langs->trans('RecordSaved'), array()); if ($currency->addRate($rate)) setEventMessages($langs->trans('RecordSaved'), array());
else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors'); else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors');
} }
else setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors'); else setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors');
}
} }
elseif ($action == 'update_currency') elseif ($action == 'update_currency')
{ {
$error = 0;
$submit = GETPOST('submit', 'alpha'); $submit = GETPOST('submit', 'alpha');
if ($submit == $langs->trans('Modify')) if ($submit == $langs->trans('Modify'))
@ -103,11 +115,19 @@ elseif ($action == 'update_currency')
$rate = price2num(GETPOST('rate', 'alpha')); $rate = price2num(GETPOST('rate', 'alpha'));
$currency = new MultiCurrency($db); $currency = new MultiCurrency($db);
if (empty($rate))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
$error++;
}
if (! $error)
{
if ($currency->fetch($fk_multicurrency) > 0) if ($currency->fetch($fk_multicurrency) > 0)
{ {
$currency->updateRate($rate); $currency->updateRate($rate);
} }
} }
}
elseif ($submit == $langs->trans('Delete')) elseif ($submit == $langs->trans('Delete'))
{ {
$fk_multicurrency = GETPOST('fk_multicurrency', 'int'); $fk_multicurrency = GETPOST('fk_multicurrency', 'int');
@ -279,7 +299,6 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print '</form>'; print '</form>';
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").'</td>'; print '<td>'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").'</td>';
print '<td align="center" width="20">&nbsp;</td>'; print '<td align="center" width="20">&nbsp;</td>';
@ -325,8 +344,7 @@ print '</td></form></tr>';
foreach ($TCurrency as &$currency) foreach ($TCurrency as &$currency)
{ {
if($currency->code == $conf->currency) continue; if ($currency->code == $conf->currency) continue;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$currency->code.' - '.$currency->name.'</td>'; print '<td>'.$currency->code.' - '.$currency->name.'</td>';

View File

@ -77,6 +77,8 @@ if ($action == 'setproductionmode')
} }
} }
dol_mkdir(DOL_DATA_ROOT.'/api/temp'); // May have been deleted by a purge
/* /*
* View * View

View File

@ -48,7 +48,7 @@ class DolibarrApi
*/ */
function __construct($db, $cachedir='', $refreshCache=false) function __construct($db, $cachedir='', $refreshCache=false)
{ {
global $conf; global $conf, $dolibarr_main_url_root;
if (empty($cachedir)) $cachedir = $conf->api->dir_temp; if (empty($cachedir)) $cachedir = $conf->api->dir_temp;
Defaults::$cacheDirectory = $cachedir; Defaults::$cacheDirectory = $cachedir;
@ -56,7 +56,9 @@ class DolibarrApi
$this->db = $db; $this->db = $db;
$production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true );
$this->r = new Restler($production_mode, $refreshCache); $this->r = new Restler($production_mode, $refreshCache);
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$this->r->setBaseUrls(DOL_MAIN_URL_ROOT, $urlwithroot);
$this->r->setAPIVersion(1); $this->r->setAPIVersion(1);
} }

View File

@ -824,7 +824,7 @@ if ($action == 'create')
// Description // Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('note',(GETPOST('note')?GETPOST('note'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,'90%'); $doleditor=new DolEditor('note',(GETPOST('note','none')?GETPOST('note','none'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,'90%');
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';

View File

@ -57,24 +57,17 @@ $hookmanager->initHooks(array('mailingcard','globalcard'));
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$object->substitutionarray=FormMail::getAvailableSubstitKey('emailing'); $object->substitutionarray=FormMail::getAvailableSubstitKey('emailing');
$object->substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$object->substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord', // Set $object->substitutionarrayfortest
//'__EMAIL__' => 'TESTEMail', // Done into "send" action $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
'__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname', $targetobject = null; // Not defined with mass emailing
'__MAILTOEMAIL__' => 'TESTMailtoEmail',
'__OTHER1__' => 'TESTOther1', $parameters=array('mode'=>'emailing');
'__OTHER2__' => 'TESTOther2', $substitutionarray=FormMail::getAvailableSubstitKey('emailing', $targetobject);
'__OTHER3__' => 'TESTOther3',
'__OTHER4__' => 'TESTOther4', $object->substitutionarrayfortest = $substitutionarray;
'__OTHER5__' => 'TESTOther5',
'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''),
'__CHECK_READ__' => 'TagCheckMail',
'__UNSUBSCRIBE__' => 'TagUnsubscribe'
//,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet
);
// List of sending methods // List of sending methods
$listofmethods=array(); $listofmethods=array();
@ -205,24 +198,28 @@ if (empty($reshook))
$tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
// Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) $targetobject = null; // Not defined with mass emailing
$substitutionarray=array( $parameters=array('mode'=>'emailing');
'__ID__' => $obj->source_id, $substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object
'__EMAIL__' => $obj->email,
'__LASTNAME__' => $obj->lastname, // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
'__FIRSTNAME__' => $obj->firstname, $substitutionarray['__ID__'] = $obj->source_id;
'__MAILTOEMAIL__' => '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>', $substitutionarray['__EMAIL__'] = $obj->email;
'__OTHER1__' => $other1, $substitutionarray['__LASTNAME__'] = $obj->lastname;
'__OTHER2__' => $other2, $substitutionarray['__FIRSTNAME__'] = $obj->firstname;
'__OTHER3__' => $other3, $substitutionarray['__MAILTOEMAIL__'] = '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>';
'__OTHER4__' => $other4, $substitutionarray['__OTHER1__'] = $other1;
'__OTHER5__' => $other5, $substitutionarray['__OTHER2__'] = $other2;
'__SIGNATURE__' => $signature, // Signature is empty when ran from command line or taken from user in parameter) $substitutionarray['__OTHER3__'] = $other3;
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>', $substitutionarray['__OTHER4__'] = $other4;
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>' $substitutionarray['__OTHER5__'] = $other5;
); $substitutionarray['__SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
$onlinepaymentenabled = 0; $onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++; if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++;
@ -230,18 +227,20 @@ if (empty($reshook))
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{ {
$substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); {
else $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
}
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); else
else $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2); {
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
else $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
} }
/* For backward compatibility */ /* For backward compatibility */
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
@ -261,6 +260,7 @@ if (empty($reshook))
else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
} }
//$substitutionisok=true; //$substitutionisok=true;
complete_substitutions_array($substitutionarray, $langs); complete_substitutions_array($substitutionarray, $langs);
$newsubject=make_substitutions($subject,$substitutionarray); $newsubject=make_substitutions($subject,$substitutionarray);
$newmessage=make_substitutions($message,$substitutionarray); $newmessage=make_substitutions($message,$substitutionarray);
@ -431,9 +431,12 @@ if (empty($reshook))
$msgishtml=-1; // Inconnu par defaut $msgishtml=-1; // Inconnu par defaut
if (preg_match('/[\s\t]*<html>/i',$object->body)) $msgishtml=1; if (preg_match('/[\s\t]*<html>/i',$object->body)) $msgishtml=1;
$object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; // other are set at begin of page // other are set at begin of page
$object->substitutionarrayfortest['__EMAIL__'] = $object->sendto;
$object->substitutionarrayfortest['__MAILTOEMAIL__'] = '<a href="mailto:'.$object->sendto.'">'.$object->sendto.'</a>';
// Pratique les substitutions sur le sujet et message // Pratique les substitutions sur le sujet et message
complete_substitutions_array($object->substitutionarrayfortest, $langs);
$tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest); $tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest);
$tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest); $tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest);
@ -1073,7 +1076,7 @@ else
$formmail->substit=$object->substitutionarrayfortest; $formmail->substit=$object->substitutionarrayfortest;
// Tableau des parametres complementaires du post // Tableau des parametres complementaires du post
$formmail->param["action"]="send"; $formmail->param["action"]="send";
$formmail->param["models"]="body"; $formmail->param["models"]='none';
$formmail->param["mailid"]=$object->id; $formmail->param["mailid"]=$object->id;
$formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id; $formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id;

View File

@ -358,8 +358,8 @@ if (empty($reshook))
$object->fk_project = GETPOST('projectid'); $object->fk_project = GETPOST('projectid');
$object->modelpdf = GETPOST('model'); $object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated $object->author = $user->id; // deprecated
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->statut = Propal::STATUS_DRAFT; $object->statut = Propal::STATUS_DRAFT;
$object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@ -386,8 +386,8 @@ if (empty($reshook))
$object->fk_project = GETPOST('projectid'); $object->fk_project = GETPOST('projectid');
$object->modelpdf = GETPOST('model'); $object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated $object->author = $user->id; // deprecated
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@ -979,7 +979,7 @@ if (empty($reshook))
$info_bits |= 0x01; $info_bits |= 0x01;
// Clean parameters // Clean parameters
$description = dol_htmlcleanlastbr(GETPOST('product_desc')); $description = dol_htmlcleanlastbr(GETPOST('product_desc','none'));
// Define vat_rate // Define vat_rate
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);

View File

@ -1404,7 +1404,7 @@ class Propal extends CommonObject
{ {
$this->lines=array(); $this->lines=array();
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,'; $sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
$sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,'; $sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,';
$sql.= ' d.fk_unit,'; $sql.= ' d.fk_unit,';
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
@ -1443,6 +1443,8 @@ class Propal extends CommonObject
$line->tva_tx = $objp->tva_tx; $line->tva_tx = $objp->tva_tx;
$line->localtax1_tx = $objp->localtax1_tx; $line->localtax1_tx = $objp->localtax1_tx;
$line->localtax2_tx = $objp->localtax2_tx; $line->localtax2_tx = $objp->localtax2_tx;
$line->localtax1_type = $objp->localtax1_type;
$line->localtax2_type = $objp->localtax2_type;
$line->subprice = $objp->subprice; $line->subprice = $objp->subprice;
$line->fk_remise_except = $objp->fk_remise_except; $line->fk_remise_except = $objp->fk_remise_except;
$line->remise_percent = $objp->remise_percent; $line->remise_percent = $objp->remise_percent;
@ -3366,8 +3368,8 @@ class Propal extends CommonObject
$this->lines = array(); $this->lines = array();
$sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,';
$sql.= ' pt.qty, pt.vat_src_code, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.qty, pt.vat_src_code, pt.tva_tx, pt.localtax1_tx, pt.localtax2_tx, pt.localtax1_type, pt.localtax2_type, pt.remise_percent, pt.subprice, pt.info_bits,';
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.total_localtax1, pt.total_localtax2, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code,';
$sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang, pt.fk_parent_line,'; $sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang, pt.fk_parent_line,';
$sql.= ' pt.fk_unit,'; $sql.= ' pt.fk_unit,';
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.description as product_desc, p.tobatch as product_tobatch,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.description as product_desc, p.tobatch as product_tobatch,';
@ -3411,10 +3413,16 @@ class Propal extends CommonObject
$this->lines[$i]->vat_src_code = $obj->vat_src_code; $this->lines[$i]->vat_src_code = $obj->vat_src_code;
$this->lines[$i]->tva_tx = $obj->tva_tx; $this->lines[$i]->tva_tx = $obj->tva_tx;
$this->lines[$i]->localtax1_tx = $obj->localtax1_tx;
$this->lines[$i]->localtax2_tx = $obj->localtax2_tx;
$this->lines[$i]->localtax1_type = $obj->localtax1_type;
$this->lines[$i]->localtax2_type = $obj->localtax2_type;
$this->lines[$i]->info_bits = $obj->info_bits; $this->lines[$i]->info_bits = $obj->info_bits;
$this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_ht = $obj->total_ht;
$this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_tva = $obj->total_tva;
$this->lines[$i]->total_ttc = $obj->total_ttc; $this->lines[$i]->total_ttc = $obj->total_ttc;
$this->lines[$i]->total_localtax1 = $obj->total_localtax1;
$this->lines[$i]->total_localtax2 = $obj->total_localtax2;
$this->lines[$i]->fk_fournprice = $obj->fk_fournprice; $this->lines[$i]->fk_fournprice = $obj->fk_fournprice;
$marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht);
$this->lines[$i]->pa_ht = $marginInfos[0]; $this->lines[$i]->pa_ht = $marginInfos[0];

View File

@ -292,7 +292,7 @@ if ($socid > 0)
print $form->load_tva('tva_tx',GETPOST('tva_tx'),$mysoc,$object); print $form->load_tva('tva_tx',GETPOST('tva_tx'),$mysoc,$object);
print '</td></tr>'; print '</td></tr>';
print '<tr><td class="fieldrequired" >'.$langs->trans("NoteReason").'</td>'; print '<tr><td class="fieldrequired" >'.$langs->trans("NoteReason").'</td>';
print '<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST('desc').'"></td></tr>'; print '<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST('desc','none').'"></td></tr>';
print "</table>"; print "</table>";
} }

View File

@ -256,8 +256,8 @@ if (empty($reshook))
$db->begin(); $db->begin();
$object->date_commande = $datecommande; $object->date_commande = $datecommande;
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->source = GETPOST('source_id'); $object->source = GETPOST('source_id');
$object->fk_project = GETPOST('projectid'); $object->fk_project = GETPOST('projectid');
$object->ref_client = GETPOST('ref_client'); $object->ref_client = GETPOST('ref_client');
@ -927,7 +927,7 @@ if (empty($reshook))
$date_end=''; $date_end='';
$date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description=dol_htmlcleanlastbr(GETPOST('product_desc')); $description=dol_htmlcleanlastbr(GETPOST('product_desc','none'));
$pu_ht=GETPOST('price_ht'); $pu_ht=GETPOST('price_ht');
$vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0);
$pu_ht_devise = GETPOST('multicurrency_subprice'); $pu_ht_devise = GETPOST('multicurrency_subprice');
@ -1210,11 +1210,6 @@ if (empty($reshook))
} }
} }
// Actions to build doc
$upload_dir = $conf->commande->dir_output;
$permissioncreate = $user->rights->commande->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
if ($action == 'update_extras') if ($action == 'update_extras')
{ {
// Fill array 'array_options' with data from update form // Fill array 'array_options' with data from update form
@ -1254,6 +1249,11 @@ if (empty($reshook))
// Actions when printing a doc from card // Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to build doc
$upload_dir = $conf->commande->dir_output;
$permissioncreate = $user->rights->commande->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails // Actions to send emails
$trigger_name='ORDER_SENTBYMAIL'; $trigger_name='ORDER_SENTBYMAIL';
$paramname='id'; $paramname='id';
@ -2492,7 +2492,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if (! empty($conf->expedition->enabled)) { if (! empty($conf->expedition->enabled)) {
$numshipping = $object->nb_expedition(); $numshipping = $object->nb_expedition();
if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfProductsLines() > 0) { if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) {
if ($user->rights->expedition->creer) { if ($user->rights->expedition->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/expedition/shipment.php?id=' . $object->id . '">' . $langs->trans('CreateShipment') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/expedition/shipment.php?id=' . $object->id . '">' . $langs->trans('CreateShipment') . '</a></div>';

View File

@ -104,9 +104,9 @@ if (! $sortfield) $sortfield='b.datev, b.dateo, b.rowid';
$mode_balance_ok=false; $mode_balance_ok=false;
//if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected //if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected
if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid'))
{ {
$sortfield = 'b.datev, b.dateo, b.rowid'; $sortfield = 'b.datev,b.dateo,b.rowid';
if ($id > 0 || ! empty($ref) || $account > 0) $mode_balance_ok = true; if ($id > 0 || ! empty($ref) || $account > 0) $mode_balance_ok = true;
} }
if (strtolower($sortorder) == 'desc') $mode_balance_ok = false; if (strtolower($sortorder) == 'desc') $mode_balance_ok = false;
@ -743,7 +743,7 @@ if ($resql)
// Title // Title
$bankcateg=new BankCateg($db); $bankcateg=new BankCateg($db);
$morehtml='<div data-role="fieldcontain">'; $morehtml='<div>';
$morehtml.= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page '; $morehtml.= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page ';
$morehtml.='<input type="text" name="pageplusone" id="pageplusone" size="1" class="flat" value="'.($page+1).'">'; $morehtml.='<input type="text" name="pageplusone" id="pageplusone" size="1" class="flat" value="'.($page+1).'">';
$morehtml.='/'.$nbtotalofpages.' '; $morehtml.='/'.$nbtotalofpages.' ';
@ -887,7 +887,7 @@ if ($resql)
if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['description']['checked'])) print_liste_field_titre($arrayfields['description']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['description']['checked'])) print_liste_field_titre($arrayfields['description']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'],$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'],$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev, b.dateo, b.rowid','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev,b.dateo,b.rowid','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'],$_SERVER['PHP_SELF'],'b.num_chq','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'],$_SERVER['PHP_SELF'],'b.num_chq','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'],$_SERVER['PHP_SELF'],'bu.label','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'],$_SERVER['PHP_SELF'],'bu.label','',$param,'',$sortfield,$sortorder);
@ -1065,7 +1065,7 @@ if ($resql)
$bankstatic->id=$banklinestatic->fk_account; $bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref; $bankstatic->label=$banklinestatic->bank_account_ref;
print ' ('.$langs->trans("TransferFrom").' '; print ' ('.$langs->trans("TransferFrom").' ';
print $bankstatic->getNomUrl(1,'transactions'); print $bankstatic->getNomUrl(1);
print ' '.$langs->trans("toward").' '; print ' '.$langs->trans("toward").' ';
$bankstatic->id=$objp->bankid; $bankstatic->id=$objp->bankid;
$bankstatic->label=$objp->bankref; $bankstatic->label=$objp->bankref;
@ -1082,7 +1082,7 @@ if ($resql)
$banklinestatic->fetch($links[$key]['url_id']); $banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id=$banklinestatic->fk_account; $bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref; $bankstatic->label=$banklinestatic->bank_account_ref;
print $bankstatic->getNomUrl(1,'transactions'); print $bankstatic->getNomUrl(1);
print ')'; print ')';
} }
//var_dump($links); //var_dump($links);

View File

@ -925,7 +925,8 @@ class Account extends CommonObject
} }
else else
{ {
dol_print_error($this->db); $this->error=$this->db->lasterror;
$this->errors[]=$this->error;
return -1; return -1;
} }
} }

View File

@ -92,6 +92,7 @@ $arrayfields=array(
'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>$conf->accountancy->enabled), 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>$conf->accountancy->enabled),
'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled), 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled),
'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1),
'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0),
'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), 'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
@ -121,7 +122,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // 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 tests are required to be compatible with all browsers
{ {
$search_ref=''; $search_ref='';
$search_label=''; $search_label='';
@ -142,7 +143,7 @@ $title=$langs->trans('BankAccounts');
// Load array of financial accounts (opened by default) // Load array of financial accounts (opened by default)
$accounts = array(); $accounts = array();
$sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, datec as date_creation, tms as date_update"; $sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, currency_code, datec as date_creation, tms as date_update";
// Add fields from extrafields // Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks // Add fields from hooks
@ -337,6 +338,12 @@ if (! empty($arrayfields['toreconcile']['checked']))
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '</td>'; print '</td>';
} }
// Currency
if (! empty($arrayfields['b.currency_code']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
@ -407,6 +414,7 @@ if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titr
if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'],$_SERVER["PHP_SELF"],'b.number','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'],$_SERVER["PHP_SELF"],'b.number','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'],$_SERVER["PHP_SELF"],'b.account_number','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'],$_SERVER["PHP_SELF"],'b.account_number','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'],$_SERVER["PHP_SELF"],'b.fk_accountancy_journal','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'],$_SERVER["PHP_SELF"],'b.fk_accountancy_journal','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
@ -442,19 +450,19 @@ foreach ($accounts as $key=>$type)
$found++; $found++;
$acc = new Account($db); $obj = new Account($db);
$acc->fetch($key); $obj->fetch($key);
$var = !$var; $var = !$var;
$solde = $acc->solde(1); $solde = $obj->solde(1);
if (! empty($lastcurrencycode) && $lastcurrencycode != $acc->currency_code) if (! empty($lastcurrencycode) && $lastcurrencycode != $obj->currency_code)
{ {
$lastcurrencycode='various'; // We found several different currencies $lastcurrencycode='various'; // We found several different currencies
} }
if ($lastcurrencycode != 'various') if ($lastcurrencycode != 'various')
{ {
$lastcurrencycode=$acc->currency_code; $lastcurrencycode=$obj->currency_code;
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -462,14 +470,14 @@ foreach ($accounts as $key=>$type)
// Ref // Ref
if (! empty($arrayfields['b.ref']['checked'])) if (! empty($arrayfields['b.ref']['checked']))
{ {
print '<td>'.$acc->getNomUrl(1).'</td>'; print '<td>'.$obj->getNomUrl(1).'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Label // Label
if (! empty($arrayfields['b.label']['checked'])) if (! empty($arrayfields['b.label']['checked']))
{ {
print '<td>'.$acc->label.'</td>'; print '<td>'.$obj->label.'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
@ -477,7 +485,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['accountype']['checked'])) if (! empty($arrayfields['accountype']['checked']))
{ {
print '<td>'; print '<td>';
print $acc->type_lib[$acc->type]; print $obj->type_lib[$obj->type];
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
@ -485,7 +493,7 @@ foreach ($accounts as $key=>$type)
// Number // Number
if (! empty($arrayfields['b.number']['checked'])) if (! empty($arrayfields['b.number']['checked']))
{ {
print '<td>'.$acc->number.'</td>'; print '<td>'.$obj->number.'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
@ -496,12 +504,12 @@ foreach ($accounts as $key=>$type)
if (! empty($conf->accounting->enabled)) if (! empty($conf->accounting->enabled))
{ {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('',$acc->account_number); $accountingaccount->fetch('',$obj->account_number);
print $accountingaccount->getNomUrl(0,1,1,'',1); print $accountingaccount->getNomUrl(0,1,1,'',1);
} }
else else
{ {
print $acc->account_number; print $obj->account_number;
} }
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
@ -514,7 +522,7 @@ foreach ($accounts as $key=>$type)
if (! empty($conf->accounting->enabled)) if (! empty($conf->accounting->enabled))
{ {
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($acc->fk_accountancy_journal); $accountingjournal->fetch($obj->fk_accountancy_journal);
print $accountingjournal->getNomUrl(0,1,1,'',1); print $accountingjournal->getNomUrl(0,1,1,'',1);
} }
else else
@ -525,15 +533,24 @@ foreach ($accounts as $key=>$type)
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Currency
if (! empty($arrayfields['b.currency_code']['checked']))
{
print '<td align="center">';
print $obj->currency_code;
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Transactions to reconcile // Transactions to reconcile
if (! empty($arrayfields['toreconcile']['checked'])) if (! empty($arrayfields['toreconcile']['checked']))
{ {
print '<td align="center">'; print '<td align="center">';
if ($acc->rappro) if ($obj->rappro)
{ {
$result=$acc->load_board($user,$acc->id); $result=$obj->load_board($user,$obj->id);
if ($result<0) { if ($result<0) {
setEventMessages($acc->error, $acc->errors, 'errors'); setEventMessages($obj->error, $obj->errors, 'errors');
} else { } else {
print $result->nbtodo; print $result->nbtodo;
if ($result->nbtodolate) print ' &nbsp; ('.$result->nbtodolate.img_warning($langs->trans("Late")).')'; if ($result->nbtodolate) print ' &nbsp; ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
@ -570,7 +587,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['b.datec']['checked'])) if (! empty($arrayfields['b.datec']['checked']))
{ {
print '<td align="center">'; print '<td align="center">';
print dol_print_date($acc->date_creation, 'dayhour'); print dol_print_date($obj->date_creation, 'dayhour');
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
@ -578,7 +595,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['b.tms']['checked'])) if (! empty($arrayfields['b.tms']['checked']))
{ {
print '<td align="center">'; print '<td align="center">';
print dol_print_date($acc->date_update, 'dayhour'); print dol_print_date($obj->date_update, 'dayhour');
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
@ -586,7 +603,7 @@ foreach ($accounts as $key=>$type)
// Status // Status
if (! empty($arrayfields['b.clos']['checked'])) if (! empty($arrayfields['b.clos']['checked']))
{ {
print '<td align="center">'.$acc->getLibStatut(5).'</td>'; print '<td align="center">'.$obj->getLibStatut(5).'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
@ -594,7 +611,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['balance']['checked'])) if (! empty($arrayfields['balance']['checked']))
{ {
print '<td align="right">'; print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$acc->id.'">'.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'</a>'; print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$obj->id.'">'.price($solde, 0, $langs, 0, 0, -1, $obj->currency_code).'</a>';
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield']; if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield'];
@ -614,7 +631,7 @@ foreach ($accounts as $key=>$type)
print '</tr>'; print '</tr>';
$total[$acc->currency_code] += $solde; $total[$obj->currency_code] += $solde;
$i++; $i++;
} }

View File

@ -30,8 +30,7 @@ require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks"); $langs->loadLangs(array("banks", "categories", "multicurrency"));
$langs->load("categories");
if (! $user->rights->banque->transfer) if (! $user->rights->banque->transfer)
accessforbidden(); accessforbidden();
@ -44,14 +43,14 @@ $error = 0;
* Actions * Actions
*/ */
if ($action == 'add_confirm') if ($action == 'add')
{ {
$langs->load("errors"); $langs->load("errors");
$dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); $dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$amount= GETPOST('amount'); $amount= GETPOST('amount');
$amount_to= GETPOST('amount_to'); $amountto= GETPOST('amountto');
if (! $label) if (! $label)
{ {
@ -83,7 +82,17 @@ if ($action == 'add_confirm')
$accountto=new Account($db); $accountto=new Account($db);
$accountto->fetch(GETPOST('account_to','int')); $accountto->fetch(GETPOST('account_to','int'));
if ($accountto->id != $accountfrom->id) if ($accountto->currency_code == $accountfrom->currency_code) {
$amountto=$amount;
} else {
if (! $amountto)
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")), null, 'errors');
}
}
if (($accountto->id != $accountfrom->id) && empty($error))
{ {
$db->begin(); $db->begin();
@ -103,8 +112,7 @@ if ($action == 'add_confirm')
if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user); if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user);
if (! ($bank_line_id_from > 0)) $error++; if (! ($bank_line_id_from > 0)) $error++;
if ((! $error) && ($accountto->currency_code == $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user); if (! $error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amountto), '', '', $user);
if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user);
if (! ($bank_line_id_to > 0)) $error++; if (! ($bank_line_id_to > 0)) $error++;
if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'); if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
@ -114,7 +122,7 @@ if ($action == 'add_confirm')
if (! $error) if (! $error)
{ {
$mesgs = $langs->trans("TransferFromToDone","<a href=\"card.php?id=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"card.php?id=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency)); $mesgs = $langs->trans("TransferFromToDone",'<a href="bankentries.php?id='.$accountfrom->id.'&sortfield=b.datev,b.dateo,b.rowid&sortorder=desc">'.$accountfrom->label."</a>",'<a href="bankentries.php?id='.$accountto->id.'">'.$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
setEventMessages($mesgs, null, 'mesgs'); setEventMessages($mesgs, null, 'mesgs');
$db->commit(); $db->commit();
} }
@ -139,6 +147,58 @@ if ($action == 'add_confirm')
*/ */
llxHeader(); llxHeader();
print ' <script type="text/javascript">
$(document).ready(function () {
$(".selectbankaccount").change(function() {
var account1 = $("#selectaccount_from").val();
var account2 = $("#selectaccount_to").val();
var currencycode1="";
var currencycode2="";
$.get("'.DOL_URL_ROOT.'/core/ajax/getaccountcurrency.php", {id: account1})
.done(function( data ) {
if (data != null)
{
var item= $.parseJSON(data);
if (item.num==-1) {
console.error("Error: "+item.error);
} else if (item.num!==0) {
currencycode1 = item.value;
}
$.get("'.DOL_URL_ROOT.'/core/ajax/getaccountcurrency.php", {id: account2})
.done(function( data ) {
if (data != null)
{
var item=$.parseJSON(data);
if (item.num==-1) {
console.error("Error: "+item.error);
} else if (item.num!==0) {
currencycode2 = item.value;
}
if (currencycode2!==currencycode1 && currencycode2!=="" && currencycode1!=="") {
$(".multicurrency").show();
} else {
$(".multicurrency").hide();
}
}
else {
console.error("Error: Ajax url has returned an empty page. Should be an empty json array.");
}
}).fail(function( data ) {
console.error("Error: has returned an empty page. Should be an empty json array.");
});
}
else {
console.error("Error: has returned an empty page. Should be an empty json array.");
}
}).fail(function( data ) {
console.error("Error: has returned an empty page. Should be an empty json array.");
});
});
});
</script>';
$form=new Form($db); $form=new Form($db);
@ -146,9 +206,8 @@ $account_from='';
$account_to=''; $account_to='';
$label=''; $label='';
$amount=''; $amount='';
$amount_to='';
if ($error) if($error)
{ {
$account_from = GETPOST('account_from','int'); $account_from = GETPOST('account_from','int');
$account_to = GETPOST('account_to','int'); $account_to = GETPOST('account_to','int');
@ -164,21 +223,21 @@ print "<br><br>";
print '<form name="add" method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form name="add" method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add_confirm">'; print '<input type="hidden" name="action" value="add">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("TransferFrom").'</td><td>'.$langs->trans("TransferTo").'</td><td>'.$langs->trans("Date").'</td>'; print '<td>'.$langs->trans("TransferFrom").'</td><td>'.$langs->trans("TransferTo").'</td><td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Description").'</td><td>'.$langs->trans("Amount").'</td>';
print '<td>'.$langs->trans("Description").'</td><td>'.$langs->trans("Amount").'</td>'; print '<td style="display:none" class="multicurrency">'.$langs->trans("AmountToOthercurrency").'</td>';
print '</tr>'; print '</tr>';
$var=false; $var=false;
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
$form->select_comptes($account_from,'account_from',0,'',1); $form->select_comptes($account_from, 'account_from', 0, '', 1, '', empty($conf->multicurrency->enabled)?0:1);
print "</td>"; print "</td>";
print "<td>\n"; print "<td>\n";
$form->select_comptes($account_to,'account_to',0,'',1); $form->select_comptes($account_to, 'account_to', 0, '', 1, '', empty($conf->multicurrency->enabled)?0:1);
print "</td>\n"; print "</td>\n";
print "<td>"; print "<td>";
@ -186,6 +245,8 @@ $form->select_date((! empty($dateo)?$dateo:''),'','','','','add');
print "</td>\n"; print "</td>\n";
print '<td><input name="label" class="flat quatrevingtpercent" type="text" value="'.$label.'"></td>'; print '<td><input name="label" class="flat quatrevingtpercent" type="text" value="'.$label.'"></td>';
print '<td><input name="amount" class="flat" type="text" size="6" value="'.$amount.'"></td>'; print '<td><input name="amount" class="flat" type="text" size="6" value="'.$amount.'"></td>';
print '<td style="display:none" class="multicurrency"><input name="amountto" class="flat" type="text" size="6" value="'.$amountto.'"></td>';
print "</table>"; print "</table>";
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></div>'; print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></div>';

View File

@ -1414,6 +1414,7 @@ if (empty($reshook))
{ {
$line->origin = $object->origin; $line->origin = $object->origin;
$line->origin_id = $line->id; $line->origin_id = $line->id;
$line->fetch_optionals($line->id);
} }
} }
@ -1435,7 +1436,21 @@ if (empty($reshook))
$object->situation_counter = $object->situation_counter + 1; $object->situation_counter = $object->situation_counter + 1;
$id = $object->createFromCurrent($user); $id = $object->createFromCurrent($user);
if ($id <= 0) $mesg = $object->error; if ($id <= 0)
{
$mesg = $object->error;
}
else
{
$nextSituationInvoice = new Facture($db);
$nextSituationInvoice->fetch($id);
// create extrafields with data from create form
$extralabels = $extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $nextSituationInvoice);
if ($ret > 0) {
$nextSituationInvoice->insertExtraFields();
}
}
} }
} }
@ -1801,7 +1816,7 @@ if (empty($reshook))
$date_end = ''; $date_end = '';
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc')); $description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none'));
$pu_ht = GETPOST('price_ht'); $pu_ht = GETPOST('price_ht');
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty'); $qty = GETPOST('qty');
@ -2550,8 +2565,8 @@ if ($action == 'create')
print $desc; print $desc;
print '<div id="credit_note_options" class="clearboth">'; print '<div id="credit_note_options" class="clearboth">';
print '&nbsp;&nbsp;&nbsp; <input data-role="none" type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>"; print '&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '<br>&nbsp;&nbsp;&nbsp; <input data-role="none" type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>"; print '<br>&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
print '</div>'; print '</div>';
print '</div></div>'; print '</div></div>';

View File

@ -192,7 +192,7 @@ class Invoices extends DolibarrApi
foreach($request_data as $field => $value) { foreach($request_data as $field => $value) {
$this->invoice->$field = $value; $this->invoice->$field = $value;
} }
if(! array_keys($request_data,'date')) { if(! array_key_exists('date', $request_data)) {
$this->invoice->date = dol_now(); $this->invoice->date = dol_now();
} }
/* We keep lines as an array /* We keep lines as an array
@ -276,6 +276,107 @@ class Invoices extends DolibarrApi
); );
} }
/**
* Get lines of a given invoice
*
* @param int $id Id of invoice
*
* @url GET {id}/lines
*
* @return array
*/
function getLines($id) {
if(! DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->invoice->getLinesArray();
$result = array();
foreach ($this->invoice->lines as $line) {
array_push($result,$this->_cleanObjectDatas($line));
}
return $result;
}
/**
* Add a line to a given invoice
*
* Exemple of POST query : { "desc": "Desc", "subprice": "1.00000000", "qty": "1", "tva_tx": "20.000", "localtax1_tx": "0.000", "localtax2_tx": "0.000", "fk_product": "1", "remise_percent": "0", "date_start": "", "date_end": "", "fk_code_ventilation": 0, "info_bits": "0", "fk_remise_except": null, "product_type": "1", "rang": "-1", "special_code": "0", "fk_parent_line": null, "fk_fournprice": null, "pa_ht": "0.00000000", "label": "", "array_options": [], "situation_percent": "100", "fk_prev_id": null, "fk_unit": null }
*
* @param int $id Id of invoice
* @param array $request_data Invoiceline data
*
* @url POST {id}/lines
*
* @return int
*/
function postLine($id, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
// Reset fk_parent_line for no child products and special product
if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) {
$request_data->fk_parent_line = 0;
}
$updateRes = $this->invoice->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
$request_data->date_start,
$request_data->date_end,
$request_data->fk_code_ventilation,
$request_data->info_bits,
$request_data->fk_remise_except,
'HT',
0,
$request_data->product_type,
$request_data->rang,
$request_data->special_code,
'facture',
$id,
$request_data->fk_parent_line,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->label,
$request_data->array_options,
$request_data->situation_percent,
$request_data->fk_prev_id,
$request_data->fk_unit
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
}
throw new RestException(400, 'Unable to insert the new line. Check your inputs.');
}
/** /**
* Validate an order * Validate an order
* *

View File

@ -152,8 +152,8 @@ class FactureRec extends CommonInvoice
$sql.= ", '".$this->db->escape($user->id)."'"; $sql.= ", '".$this->db->escape($user->id)."'";
$sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null"); $sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null");
$sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null"); $sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null");
$sql.= ", '".$this->db->escape($facsrc->cond_reglement_id)."'"; $sql.= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null");
$sql.= ", '".$this->db->escape($facsrc->mode_reglement_id)."'"; $sql.= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null");
$sql.= ", ".$this->usenewprice; $sql.= ", ".$this->usenewprice;
$sql.= ", ".$this->frequency; $sql.= ", ".$this->frequency;
$sql.= ", '".$this->db->escape($this->unit_frequency)."'"; $sql.= ", '".$this->db->escape($this->unit_frequency)."'";
@ -329,7 +329,6 @@ class FactureRec extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retreive all extrafield for thirdparty // Retreive all extrafield for thirdparty
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
@ -447,7 +446,6 @@ class FactureRec extends CommonInvoice
$line->price = $objp->price; $line->price = $objp->price;
$line->remise = $objp->remise; $line->remise = $objp->remise;
// Retreive all extrafield for thirdparty // Retreive all extrafield for thirdparty
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');

View File

@ -293,8 +293,8 @@ class Facture extends CommonInvoice
// Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI
$this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project;
$this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public; $this->note_public = GETPOST('note_public','none') ? GETPOST('note_public','none') : $_facrec->note_public;
$this->note_private = GETPOST('note_private') ? GETPOST('note_private') : $_facrec->note_private; $this->note_private = GETPOST('note_private','none') ? GETPOST('note_private','none') : $_facrec->note_private;
$this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf; $this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf;
$this->cond_reglement_id = GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id; $this->cond_reglement_id = GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id;
$this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id; $this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id;

View File

@ -70,13 +70,17 @@ $search_societe=GETPOST('search_societe');
$search_montant_ht=GETPOST('search_montant_ht'); $search_montant_ht=GETPOST('search_montant_ht');
$search_montant_vat=GETPOST('search_montant_vat'); $search_montant_vat=GETPOST('search_montant_vat');
$search_montant_ttc=GETPOST('search_montant_ttc'); $search_montant_ttc=GETPOST('search_montant_ttc');
$search_payment_mode=GETPOST('search_payment_mode');
$search_payment_term=GETPOST('search_payment_term');
$day=GETPOST('day'); $day=GETPOST('day');
$year=GETPOST('year'); $year=GETPOST('year');
$month=GETPOST('month'); $month=GETPOST('month');
$day_date_when=GETPOST('day_date_when'); $day_date_when=GETPOST('day_date_when');
$year_date_when=GETPOST('year_date_when'); $year_date_when=GETPOST('year_date_when');
$month_date_when=GETPOST('month_date_when'); $month_date_when=GETPOST('month_date_when');
$search_frequency=GETPOST('search_frequency'); $search_recurring=GETPOST('search_recurring','int');
$search_frequency=GETPOST('search_frequency','alpha');
$search_unit_frequency=GETPOST('search_unit_frequency','alpha');
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
@ -111,29 +115,6 @@ $permissionnote = $user->rights->facture->creer; // Used by the include of actio
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
$arrayfields=array(
'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
'f.frequency'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1),
'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1),
'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1),
'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1),
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
/* /*
* Actions * Actions
@ -168,13 +149,17 @@ if (empty($reshook))
$search_montant_ht=''; $search_montant_ht='';
$search_montant_vat=''; $search_montant_vat='';
$search_montant_ttc=''; $search_montant_ttc='';
$search_montant_mode='';
$search_montant_term='';
$day=''; $day='';
$year=''; $year='';
$month=''; $month='';
$day_date_when=''; $day_date_when='';
$year_date_when=''; $year_date_when='';
$month_date_when=''; $month_date_when='';
$search_recurring='';
$search_frequency=''; $search_frequency='';
$search_unit_frequency='';
$search_array_options=array(); $search_array_options=array();
} }
@ -224,8 +209,8 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
$object->titre = GETPOST('titre', 'alpha'); $object->titre = GETPOST('titre', 'alpha');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->usenewprice = GETPOST('usenewprice'); $object->usenewprice = GETPOST('usenewprice');
$object->frequency = $frequency; $object->frequency = $frequency;
@ -375,7 +360,7 @@ if (empty($reshook))
// For triggers // For triggers
$line->id = $lineid; $line->id = $lineid;
if ($line->delete() > 0) if ($line->delete($user) > 0)
{ {
$result=$object->update_price(1); $result=$object->update_price(1);
@ -738,7 +723,7 @@ if (empty($reshook))
$date_end = ''; $date_end = '';
//$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
//$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc')); $description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none'));
$pu_ht = GETPOST('price_ht'); $pu_ht = GETPOST('price_ht');
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty'); $qty = GETPOST('qty');
@ -980,13 +965,16 @@ if ($action == 'create')
print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>';
print '</tr>'; print '</tr>';
$note_public=GETPOST('note_public')?GETPOST('note_public'):$object->note_public; $note_public=GETPOST('note_public','none')?GETPOST('note_public','none'):$object->note_public;
$note_private=GETPOST('note_private')?GETPOST('note_private'):$object->note_private; $note_private=GETPOST('note_private','none')?GETPOST('note_private','none'):$object->note_private;
// Help of substitution key // Help of substitution key
$substitutionarray=array( $substitutionarray=array(
'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')', //'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')', //'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__AMOUNT_EXCL_TAX__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__AMOUNT_VAT__' => $langs->trans("AmountVAT").' ('.$langs->trans("Example").': '.price($object->total_tva).')',
'__AMOUNT__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')', '__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')',
'__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')', '__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')',
'__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')', '__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')',
@ -1042,7 +1030,7 @@ if ($action == 'create')
// Payment mode // Payment mode
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>"; print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', '', 1);
print "</td></tr>"; print "</td></tr>";
// Project // Project
@ -1077,7 +1065,7 @@ if ($action == 'create')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Frequency // Frequency + unit
print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>"; print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m'));
print "</td></tr>"; print "</td></tr>";
@ -1181,7 +1169,7 @@ else
// Recurring invoice content // Recurring invoice content
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/fiche-rec.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/invoicetemplate_list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref=''; $morehtmlref='';
if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2);
@ -1307,8 +1295,11 @@ else
$dateexample=dol_now(); $dateexample=dol_now();
if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when;
$substitutionarray=array( $substitutionarray=array(
'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')', //'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')', //'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__AMOUNT_EXCL_TAX__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__AMOUNT_VAT__' => $langs->trans("AmountVAT").' ('.$langs->trans("Example").': '.price($object->total_tva).')',
'__AMOUNT__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')', '__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')',
'__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')', '__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')',
'__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')', '__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')',
@ -1549,8 +1540,6 @@ else
{ {
if ($action != 'editline') if ($action != 'editline')
{ {
$var = true;
// Add free products/services // Add free products/services
$object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice
@ -1620,382 +1609,6 @@ else
print '</div></div>'; print '</div></div>';
} }
else
{
/*
* List mode
*/
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,";
$sql.= " f.datec, f.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1);
if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1);
if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
if ($search_frequency > 0) $sql.= natural_search('f.frequency', $search_frequency);
if ($search_frequency == '1') $sql.= ' AND f.frequency > 0';
if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)';
if ($month > 0)
{
if ($year > 0 && empty($day))
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else if ($year > 0 && ! empty($day))
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
else
$sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'";
}
else if ($year > 0)
{
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($month_date_when > 0)
{
if ($year_date_when > 0 && empty($day_date_when))
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'";
else if ($year_date_when > 0 && ! empty($day_date_when))
$sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'";
else
$sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'";
}
else if ($year_date_when > 0)
{
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'";
}
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->order($sortfield, $sortorder);
$sql.= $db->plimit($limit+1,$offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($socid) $param.='&socid='.$socid;
if ($day) $param.='&day='.$day;
if ($month) $param.='&month='.$month;
if ($year) $param.='&year=' .$year;
if ($day_date_when) $param.='&day_date_when='.$day_date_when;
if ($month_date_when) $param.='&month_date_when='.$month_date_when;
if ($year_date_when) $param.='&year_date_when=' .$year_date_when;
if ($search_ref) $param.='&search_ref=' .$search_ref;
if ($search_societe) $param.='&search_societe=' .$search_societe;
if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht;
if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat;
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc;
if ($search_frequency > 0) $param.='&search_frequency=' .$search_frequency;
if ($option) $param.="&option=".$option;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
//$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
print '<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit);
print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>';
$i = 0;
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// Filters lines
print '<tr class="liste_titre_filter">';
// Ref
if (! empty($arrayfields['f.titre']['checked']))
{
print '<td class="liste_titre" align="left">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
// Thirpdarty
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
}
if (! empty($arrayfields['f.total']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
print '</td>';
}
if (! empty($arrayfields['f.tva']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
print '</td>';
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
print '</td>';
}
if (! empty($arrayfields['f.frequency']['checked']))
{
// Recurring or not
print '<td class="liste_titre" align="center">';
print $form->selectyesno('search_frequency', $search_frequency, 1, false, 1);
print '</td>';
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
{
// Nb generation
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Date invoice
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>';
}
// Date due
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_date_when" value="'.$day_date_when.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_date_when" value="'.$month_date_when.'">';
$formother->select_year($year_date_when?$year_date_when:-1,'year_date_when',1, 20, 5);
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
print '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['f.datec']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (! empty($arrayfields['f.tms']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Status
if (! empty($arrayfields['status']['checked']))
{
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Action column
print '<td class="liste_titre" align="middle">';
$searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
print "</tr>\n";
if ($num > 0)
{
$var=true;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
$companystatic->id=$objp->socid;
$companystatic->name=$objp->name;
$invoicerectmp->id=$objp->id;
$invoicerectmp->frequency=$objp->frequency;
$invoicerectmp->suspend=$objp->suspend;
$invoicerectmp->unit_frequency=$objp->unit_frequency;
print '<tr class="oddeven">';
if (! empty($arrayfields['f.titre']['checked']))
{
print '<td><a href="'.$_SERVER['PHP_SELF'].'?id='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
print "</a></td>\n";
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>';
}
if (! empty($arrayfields['f.total']['checked']))
{
print '<td align="right">'.price($objp->total).'</td>'."\n";
}
if (! empty($arrayfields['f.tva']['checked']))
{
print '<td align="right">'.price($objp->total_vat).'</td>'."\n";
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
print '<td align="right">'.price($objp->total_ttc).'</td>'."\n";
}
if (! empty($arrayfields['f.frequency']['checked']))
{
print '<td align="center">'.yn($objp->frequency?1:0).'</td>';
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
}
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
}
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
}
if (! empty($arrayfields['f.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->datec),'dayhour');
print '</td>';
}
if (! empty($arrayfields['f.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->tms),'dayhour');
print '</td>';
}
if (! empty($arrayfields['status']['checked']))
{
print '<td align="center">';
print $invoicerectmp->getLibStatut(3,0);
print '</td>';
}
// Action column
print '<td align="center">';
if ($user->rights->facture->creer)
{
if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
{
print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
print $langs->trans("CreateBill").'</a>';
}
else
{
print $langs->trans("DateIsNotEnough");
}
}
else
{
print "&nbsp;";
}
print "</td>";
print "</tr>\n";
$i++;
}
}
else
{
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
print "</table>";
print "</div>";
print "</form>";
$db->free($resql);
}
else
{
dol_print_error($db);
}
}
} }
llxFooter(); llxFooter();

View File

@ -0,0 +1,700 @@
<?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.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/compta/facture/invoicetemplate_list.php
* \ingroup facture
* \brief Page to show list of template/recurring invoices
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
//require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
}
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
$langs->load('bills');
$langs->load('compta');
$langs->load('admin');
$langs->load('other');
$action = GETPOST('action','alpha');
$massaction = GETPOST('massaction','alpha');
$show_files = GETPOST('show_files','int');
$confirm = GETPOST('confirm','alpha');
$cancel = GETPOST('cancel', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicetemplatelist'; // To manage different context of search
// Security check
$id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int'));
$lineid=GETPOST('lineid','int');
$ref=GETPOST('ref','alpha');
if ($user->societe_id) $socid=$user->societe_id;
$objecttype = 'facture_rec';
if ($action == "create" || $action == "add") $objecttype = '';
$result = restrictedArea($user, 'facture', $id, $objecttype);
$projectid = GETPOST('projectid','int');
$search_ref=GETPOST('search_ref');
$search_societe=GETPOST('search_societe');
$search_montant_ht=GETPOST('search_montant_ht');
$search_montant_vat=GETPOST('search_montant_vat');
$search_montant_ttc=GETPOST('search_montant_ttc');
$search_payment_mode=GETPOST('search_payment_mode');
$search_payment_term=GETPOST('search_payment_term');
$day=GETPOST('day');
$year=GETPOST('year');
$month=GETPOST('month');
$day_date_when=GETPOST('day_date_when');
$year_date_when=GETPOST('year_date_when');
$month_date_when=GETPOST('month_date_when');
$search_recurring=GETPOST('search_recurring','int');
$search_frequency=GETPOST('search_frequency','alpha');
$search_unit_frequency=GETPOST('search_unit_frequency','alpha');
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
if (! $sortorder) $sortorder='DESC';
if (! $sortfield) $sortfield='f.titre';
$pageprev = $page - 1;
$pagenext = $page + 1;
$object = new FactureRec($db);
if (($id > 0 || $ref) && $action != 'create' && $action != 'add')
{
$ret = $object->fetch($id, $ref);
if (!$ret)
{
setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
}
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('invoicereccard','globalcard'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('facture_rec');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
$arrayfields=array(
'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0),
'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0),
'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1),
'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1),
'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1),
'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1),
'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1),
'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1),
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
/*
* Actions
*/
if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
$parameters = array('socid' => $socid);
$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 (GETPOST('cancel','alpha')) $action='';
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Do we click on 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
{
$search_ref='';
$search_societe='';
$search_montant_ht='';
$search_montant_vat='';
$search_montant_ttc='';
$search_payment_mode='';
$search_payment_term='';
$day='';
$year='';
$month='';
$day_date_when='';
$year_date_when='';
$month_date_when='';
$search_recurring='';
$search_frequency='';
$search_unit_frequency='';
$search_array_options=array();
}
// Mass actions
/*$objectclass='MyObject';
$objectlabel='MyObject';
$permtoread = $user->rights->mymodule->read;
$permtodelete = $user->rights->mymodule->delete;
$uploaddir = $conf->mymodule->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
}
/*
* View
*/
llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec');
$form = new Form($db);
$formother = new FormOther($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
$companystatic = new Societe($db);
$invoicerectmp = new FactureRec($db);
$now = dol_now();
$tmparray=dol_getdate($now);
$today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day
/*
* List mode
*/
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,";
$sql.= " f.datec, f.tms,";
$sql.= " f.fk_cond_reglement, f.fk_mode_reglement";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1);
if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1);
if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
if (! empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1);
if (! empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1);
if ($search_recurring == '1') $sql .= ' AND f.frequency > 0';
if ($search_recurring == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
if ($search_frequency != '') $sql .= natural_search('f.frequency', $search_frequency, 1);
if ($search_unit_frequency != '') $sql .= natural_search('f.unit_frequency', $search_unit_frequency);
if ($month > 0)
{
if ($year > 0 && empty($day))
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else if ($year > 0 && ! empty($day))
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
else
$sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'";
}
else if ($year > 0)
{
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($month_date_when > 0)
{
if ($year_date_when > 0 && empty($day_date_when))
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'";
else if ($year_date_when > 0 && ! empty($day_date_when))
$sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'";
else
$sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'";
}
else if ($year_date_when > 0)
{
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'";
}
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->order($sortfield, $sortorder);
$sql.= $db->plimit($limit+1,$offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($socid) $param.='&socid='.urlencode($socid);
if ($day) $param.='&day='.urlencode($day);
if ($month) $param.='&month='.urlencode($month);
if ($year) $param.='&year=' .urlencode($year);
if ($day_date_when) $param.='&day_date_when='.urlencode($day_date_when);
if ($month_date_when) $param.='&month_date_when='.urlencode($month_date_when);
if ($year_date_when) $param.='&year_date_when=' .urlencode($year_date_when);
if ($search_ref) $param.='&search_ref=' .urlencode($search_ref);
if ($search_societe) $param.='&search_societe=' .urlencode($search_societe);
if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht);
if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat);
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode);
if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type);
if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring);
if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency);
if ($search_unit_frequency > 0) $param.='&search_unit_frequency='.urlencode($search_unit_frequency);
if ($option) $param.="&option=".urlencode($option);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
//$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit);
print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>';
$i = 0;
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// Filters lines
print '<tr class="liste_titre_filter">';
// Ref
if (! empty($arrayfields['f.titre']['checked']))
{
print '<td class="liste_titre" align="left">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
// Thirpdarty
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
}
if (! empty($arrayfields['f.total']['checked']))
{
// Amount net
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
print '</td>';
}
if (! empty($arrayfields['f.tva']['checked']))
{
// Amount Vat
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
print '</td>';
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
print '</td>';
}
if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
{
// Payment term
print '<td class="liste_titre" align="right">';
print $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
print "</td>";
}
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
{
// Payment mode
print '<td class="liste_titre" align="right">';
print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100');
print '</td>';
}
if (! empty($arrayfields['recurring']['checked']))
{
// Recurring or not
print '<td class="liste_titre" align="center">';
print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
print '</td>';
}
if (! empty($arrayfields['f.frequency']['checked']))
{
// Recurring or not
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
print '</td>';
}
if (! empty($arrayfields['f.unit_frequency']['checked']))
{
// Frequency unit
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
print '</td>';
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
{
// Nb generation
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Date invoice
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>';
}
// Date due
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_date_when" value="'.$day_date_when.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_date_when" value="'.$month_date_when.'">';
$formother->select_year($year_date_when?$year_date_when:-1,'year_date_when',1, 20, 5);
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
print '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['f.datec']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (! empty($arrayfields['f.tms']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Status
if (! empty($arrayfields['status']['checked']))
{
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Action column
print '<td class="liste_titre" align="middle">';
$searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n";
print "</tr>\n";
if ($num > 0)
{
$i=0;
$totalarray=array();
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
if (empty($objp)) break;
$companystatic->id=$objp->socid;
$companystatic->name=$objp->name;
$invoicerectmp->id=$objp->id;
$invoicerectmp->frequency=$objp->frequency;
$invoicerectmp->suspend=$objp->suspend;
$invoicerectmp->unit_frequency=$objp->unit_frequency;
print '<tr class="oddeven">';
if (! empty($arrayfields['f.titre']['checked']))
{
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/fiche-rec.php?id='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
print "</a></td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.total']['checked']))
{
print '<td align="right">'.price($objp->total).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total';
$totalarray['val']['f.total'] += $objp->total;
}
if (! empty($arrayfields['f.tva']['checked']))
{
print '<td align="right">'.price($objp->total_vat).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva';
$totalarray['val']['f.tva'] += $objp->total_vat;
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
print '<td align="right">'.price($objp->total_ttc).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc';
$totalarray['val']['f.total_ttc'] += $objp->total_ttc;
}
// Payment term
if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
{
print '<td align="right">';
print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
print '</td>'."\n";
if (! $i) $totalarray['nbfield']++;
}
// Payment mode
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
{
print '<td align="right">';
print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
print '</td>'."\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['recurring']['checked']))
{
print '<td align="center">'.yn($objp->frequency?1:0).'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.frequency']['checked']))
{
print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.unit_frequency']['checked']))
{
print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->datec),'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->tms),'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['status']['checked']))
{
print '<td align="center">';
print $invoicerectmp->getLibStatut(3,0);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Action column
print '<td align="center">';
if ($user->rights->facture->creer)
{
if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
{
print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
print $langs->trans("CreateBill").'</a>';
}
else
{
print $langs->trans("DateIsNotEnough");
}
}
else
{
print "&nbsp;";
}
if (! $i) $totalarray['nbfield']++;
print "</td>";
print "</tr>\n";
$i++;
}
}
else
{
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
//var_dump($totalarray);
// Show total line
if (isset($totalarray['pos']))
{
print '<tr class="liste_total">';
$i=0;
while ($i < $totalarray['nbfield'])
{
$i++;
if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
else
{
if ($i == 1)
{
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
}
else print '<td></td>';
}
}
print '</tr>';
}
print "</table>";
print "</div>";
print "</form>";
$db->free($resql);
}
else
{
dol_print_error($db);
}
llxFooter();
$db->close();

View File

@ -60,7 +60,7 @@ if ($action == 'setnote' && $user->rights->facture->paiement)
$db->begin(); $db->begin();
$object->fetch($id); $object->fetch($id);
$result = $object->update_note(GETPOST('note')); $result = $object->update_note(GETPOST('note','none'));
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2006-2017 Regis Houssin <regis.houssin@capnetworks.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -196,15 +196,11 @@ if ($result > 0)
} }
else else
{ {
dol_print_error('',$ldap->error); setEventMessages($ldap->error, $ldap->errors, 'errors');
} }
print '</table>'; print '</table>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -676,7 +676,7 @@ if (empty($reshook))
$fk_unit = GETPOST('unit', 'alpha'); $fk_unit = GETPOST('unit', 'alpha');
$objectline->description=GETPOST('product_desc'); $objectline->description=GETPOST('product_desc','none');
$objectline->price_ht=GETPOST('elprice'); $objectline->price_ht=GETPOST('elprice');
$objectline->subprice=GETPOST('elprice'); $objectline->subprice=GETPOST('elprice');
$objectline->qty=GETPOST('elqty'); $objectline->qty=GETPOST('elqty');
@ -918,51 +918,17 @@ if (empty($reshook))
} }
} }
// Generation doc (depuis lien ou depuis cartouche doc)
else if ($action == 'builddoc' && $user->rights->contrat->creer) {
if (GETPOST('model')) {
$object->setDocModel($user, GETPOST('model'));
}
// Define output language // Actions to build doc
$outputlangs = $langs;
if (! empty($conf->global->MAIN_MULTILANGS)) {
$outputlangs = new Translate("", $conf);
$newlang = (GETPOST('lang_id','aZ09') ? GETPOST('lang_id','aZ09') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$action='';
}
}
// Remove file in doc form
else if ($action == 'remove_file' && $user->rights->contrat->creer) {
if ($object->id > 0) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$langs->load("other");
$upload_dir = $conf->contrat->dir_output; $upload_dir = $conf->contrat->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $permissioncreate = $user->rights->contrat->creer;
$ret = dol_delete_file($file, 0, 0, 0, $object); include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
}
}
/*
* Send mail
*/
// Actions to send emails // Actions to send emails
$trigger_name='CONTRACT_SENTBYMAIL'; $trigger_name='CONTRACT_SENTBYMAIL';
$paramname='id'; $paramname='id';
$mode='emailfromcontract'; $mode='emailfromcontract';
$trackid='cont'.$object->id; $trackid='con'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
@ -2164,135 +2130,13 @@ else
print '</div></div></div>'; print '</div></div></div>';
} }
/* // Presend form
* Action presend $modelmail='contract';
*/ $defaulttopic='SendContractRef';
if ($action == 'presend') $diroutput = $conf->contrat->dir_output;
{ $trackid = 'con'.$object->id;
$object->fetch_projet();
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->contrat->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $object->thirdparty->default_lang;
if (!empty($newlang))
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('commercial');
}
// Build document if it not exists
if (! $file || ! is_readable($file)) {
$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($conf->contrat->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>';
print '<br>';
print load_fiche_titre($langs->trans('SendByMail'));
dol_fiche_head('');
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
$formmail->trackid='cont'.$object->id;
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->withfrom = 1;
$liste = array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)
$liste [$key] = $value;
$formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste;
$formmail->withtocc = $liste;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
if (empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->trans('SendContractRef', '__CONTRACTREF__');
} else if (! empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->trans('SendContractRef', '__CONTRACTREF__ (__REFCLIENT__)');
}
$formmail->withfile = 2;
$formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1;
// Array of substitutions
$formmail->setSubstitFromObject($object);
$datenextexpiration='';
foreach($object->lines as $line)
{
if ($line->statut != 4) continue;
if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue;
}
$formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
$formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']='';
$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_contract_external_CUSTOMER')) { // TODO Use code and not label
$contactstatic = new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact = $contactstatic->getFullName($langs, 1);
}
}
if (! empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
}
}
// Tableau des parametres complementaires
$formmail->param['action'] = 'send';
$formmail->param['models'] = 'contract_send';
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['contractid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
// Init list of files
if (GETPOST("mode") == 'init') {
$formmail->clear_attached_files();
$formmail->add_attached_files($file, basename($file), dol_mimetype($file));
}
// Show form
print $formmail->get_form();
dol_fiche_end();
}
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
} }
} }

View File

@ -790,7 +790,7 @@ class Contrat extends CommonObject
} }
// Selectionne les lignes contrat liees a aucun produit // Selectionne les lignes contrat liees a aucun produit
$sql = "SELECT d.rowid, d.fk_contrat, d.statut, d.qty, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.rowid, d.remise_percent, d.subprice,"; $sql = "SELECT d.rowid, d.fk_contrat, d.statut, d.qty, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.rowid, d.remise_percent, d.subprice,";
$sql.= " d.total_ht,"; $sql.= " d.total_ht,";
$sql.= " d.total_tva,"; $sql.= " d.total_tva,";
$sql.= " d.total_localtax1,"; $sql.= " d.total_localtax1,";
@ -828,6 +828,8 @@ class Contrat extends CommonObject
$line->tva_tx = $objp->tva_tx; $line->tva_tx = $objp->tva_tx;
$line->localtax1_tx = $objp->localtax1_tx; $line->localtax1_tx = $objp->localtax1_tx;
$line->localtax2_tx = $objp->localtax2_tx; $line->localtax2_tx = $objp->localtax2_tx;
$line->localtax1_type = $objp->localtax1_type;
$line->localtax2_type = $objp->localtax2_type;
$line->subprice = $objp->subprice; $line->subprice = $objp->subprice;
$line->remise_percent = $objp->remise_percent; $line->remise_percent = $objp->remise_percent;
$line->price_ht = $objp->price_ht; $line->price_ht = $objp->price_ht;
@ -934,7 +936,7 @@ class Contrat extends CommonObject
$sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; $sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,";
$sql.= " ref, entity, note_private, note_public, ref_customer, ref_supplier, ref_ext)"; $sql.= " ref, entity, note_private, note_public, ref_customer, ref_supplier, ref_ext)";
$sql.= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id; $sql.= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id;
$sql.= ", '".$this->db->idate($this->date_contrat)."'"; $sql.= ", ".(dol_strlen($this->date_contrat)!=0 ? "'".$this->db->idate($this->date_contrat)."'" : "NULL");
$sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL");
$sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL"); $sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL");
$sql.= ",".($this->fk_project>0?$this->fk_project:"NULL"); $sql.= ",".($this->fk_project>0?$this->fk_project:"NULL");
@ -2711,6 +2713,8 @@ class ContratLigne extends CommonObjectLine
$sql.= " t.vat_src_code,"; $sql.= " t.vat_src_code,";
$sql.= " t.localtax1_tx,"; $sql.= " t.localtax1_tx,";
$sql.= " t.localtax2_tx,"; $sql.= " t.localtax2_tx,";
$sql.= " t.localtax1_type,";
$sql.= " t.localtax2_type,";
$sql.= " t.qty,"; $sql.= " t.qty,";
$sql.= " t.remise_percent,"; $sql.= " t.remise_percent,";
$sql.= " t.remise,"; $sql.= " t.remise,";
@ -2764,6 +2768,8 @@ class ContratLigne extends CommonObjectLine
$this->vat_src_code = $obj->vat_src_code; $this->vat_src_code = $obj->vat_src_code;
$this->localtax1_tx = $obj->localtax1_tx; $this->localtax1_tx = $obj->localtax1_tx;
$this->localtax2_tx = $obj->localtax2_tx; $this->localtax2_tx = $obj->localtax2_tx;
$this->localtax1_type = $obj->localtax1_type;
$this->localtax2_type = $obj->localtax2_type;
$this->qty = $obj->qty; $this->qty = $obj->qty;
$this->remise_percent = $obj->remise_percent; $this->remise_percent = $obj->remise_percent;
$this->remise = $obj->remise; $this->remise = $obj->remise;

View File

@ -47,6 +47,7 @@ $confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$search_name=GETPOST('search_name'); $search_name=GETPOST('search_name');
$search_email=GETPOST('search_email');
$search_town=GETPOST('search_town','alpha'); $search_town=GETPOST('search_town','alpha');
$search_zip=GETPOST('search_zip','alpha'); $search_zip=GETPOST('search_zip','alpha');
$search_state=trim(GETPOST("search_state")); $search_state=trim(GETPOST("search_state"));
@ -116,6 +117,7 @@ $arrayfields=array(
'c.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), 'c.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
'c.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), 'c.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
's.email'=>array('label'=>$langs->trans("ThirdPartyEmail"), 'checked'=>0),
's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0), 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0), 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
@ -156,6 +158,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$month=''; $month='';
$year=''; $year='';
$search_name=""; $search_name="";
$search_email="";
$search_town=''; $search_town='';
$search_zip=""; $search_zip="";
$search_state=""; $search_state="";
@ -199,7 +202,7 @@ llxHeader('', $langs->trans("Contracts"));
$sql = 'SELECT'; $sql = 'SELECT';
$sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; $sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql.= " typent.code as typent_code,"; $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' SUM('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,'; $sql.= ' SUM('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,';
@ -246,6 +249,7 @@ else if ($year > 0)
$sql.= " AND c.date_contrat BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; $sql.= " AND c.date_contrat BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
} }
if ($search_name) $sql .= natural_search('s.nom', $search_name); if ($search_name) $sql .= natural_search('s.nom', $search_name);
if ($search_email) $sql .= natural_search('s.email', $search_name);
if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract);
if (!empty($search_ref_customer)) $sql .= natural_search(array('c.ref_customer'), $search_ref_customer); if (!empty($search_ref_customer)) $sql .= natural_search(array('c.ref_customer'), $search_ref_customer);
if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier);
@ -275,7 +279,7 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // No
$sql.=$hookmanager->resPrint; $sql.=$hookmanager->resPrint;
$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; $sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
$sql.= ' s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql.= " typent.code,"; $sql.= " typent.code,";
$sql.= " state.code_departement, state.nom"; $sql.= " state.code_departement, state.nom";
// Add fields from extrafields // Add fields from extrafields
@ -324,6 +328,7 @@ if ($resql)
if ($sall != '') $param.='&sall='.$sall; if ($sall != '') $param.='&sall='.$sall;
if ($search_contract != '') $param.='&search_contract='.$search_contract; if ($search_contract != '') $param.='&search_contract='.$search_contract;
if ($search_name != '') $param.='&search_name='.$search_name; if ($search_name != '') $param.='&search_name='.$search_name;
if ($search_email != '') $param.='&search_email='.$search_email;
if ($search_ref_supplier != '') $param.='&search_ref_supplier='.$search_ref_supplier; if ($search_ref_supplier != '') $param.='&search_ref_supplier='.$search_ref_supplier;
if ($search_sale != '') $param.='&search_sale=' .$search_sale; if ($search_sale != '') $param.='&search_sale=' .$search_sale;
if ($show_files) $param.='&show_files=' .$show_files; if ($show_files) $param.='&show_files=' .$show_files;
@ -446,6 +451,12 @@ if ($resql)
print '<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).'">'; print '<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
print '</td>'; print '</td>';
} }
if (! empty($arrayfields['s.email']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
print '</td>';
}
// Town // Town
if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
// Zip // Zip
@ -542,6 +553,7 @@ if ($resql)
if (! empty($arrayfields['c.ref_customer']['checked'])) print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer","","$param",'',$sortfield,$sortorder); if (! empty($arrayfields['c.ref_customer']['checked'])) print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer","","$param",'',$sortfield,$sortorder);
if (! empty($arrayfields['c.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier","","$param",'',$sortfield,$sortorder); if (! empty($arrayfields['c.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier","","$param",'',$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom","","$param",'',$sortfield,$sortorder); if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom","","$param",'',$sortfield,$sortorder);
if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email","","$param",'',$sortfield,$sortorder);
if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
@ -621,6 +633,10 @@ if ($resql)
{ {
print '<td><a href="../comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>'; print '<td><a href="../comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
} }
if (! empty($arrayfields['s.email']['checked']))
{
print '<td>'.$obj->email.'</td>';
}
// Town // Town
if (! empty($arrayfields['s.town']['checked'])) if (! empty($arrayfields['s.town']['checked']))
{ {

View File

@ -104,7 +104,7 @@ if (! $error && $massaction == 'confirm_presend')
if (empty($receiver) || $receiver == '-1') $receiver=array(); if (empty($receiver) || $receiver == '-1') $receiver=array();
else $receiver=array($receiver); else $receiver=array($receiver);
} }
if (count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory if (! trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory
{ {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings');
@ -322,15 +322,29 @@ if (! $error && $massaction == 'confirm_presend')
if ($objectclass == 'CommandeFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO); if ($objectclass == 'CommandeFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO);
if ($objectclass == 'FactureFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO); if ($objectclass == 'FactureFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO);
$objecttmp=new $objectclass($db); // $listofqualifiedid is array with key = object id of qualified objects for the current thirdparty
$objecttmp->thirdparty = $thirdparty; $oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
$looparray=array();
if (! $oneemailperrecipient)
{
$looparray = $listofqualifiedid;
}
else
{
$objectforloop=new $objectclass($db);
$objectforloop->thirdparty = $thirdparty;
$looparray[0]=$objectforloop;
}
//var_dump($looparray);exit;
foreach ($looparray as $objecttmp) // $objecttmp is a real object or an empty if we choose to send one email per thirdparty instead of per record
{
// Make substitution in email content // Make substitution in email content
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp); $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp);
$substitutionarray['__ID__'] = join(', ',array_keys($listofqualifiedid)); $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ',array_keys($listofqualifiedid)) : $objecttmp->id);
$substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ',$listofqualifiedref) : $objecttmp->ref);
$substitutionarray['__EMAIL__'] = $thirdparty->email; $substitutionarray['__EMAIL__'] = $thirdparty->email;
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>'; $substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$substitutionarray['__REF__'] = join(', ',$listofqualifiedref);
$parameters=array('mode'=>'formemail'); $parameters=array('mode'=>'formemail');
complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters);
@ -432,6 +446,7 @@ if (! $error && $massaction == 'confirm_presend')
} }
} }
} }
}
$resaction.=($resaction?'<br>':$resaction); $resaction.=($resaction?'<br>':$resaction);
$resaction.='<strong>'.$langs->trans("ResultOfMailSending").':</strong><br>'."\n"; $resaction.='<strong>'.$langs->trans("ResultOfMailSending").':</strong><br>'."\n";

View File

@ -18,8 +18,8 @@
/** /**
* \file htdocs/core/actions_sendmails.inc.php * \file htdocs/core/actions_sendmails.inc.php
* \brief Code for actions on sending mails from object page * \brief Code for actions on sending mails from object page
*/ */
// $mysoc must be defined // $mysoc must be defined
// $id must be defined // $id must be defined
@ -113,13 +113,18 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$result=$object->fetch($id); $result=$object->fetch($id);
$sendtosocid=0; // Thirdparty on object $sendtosocid=0; // Thirdparty on object
if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe') if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member')))
{ {
$result=$object->fetch_thirdparty(); $result=$object->fetch_thirdparty();
if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok
$thirdparty=$object->thirdparty; $thirdparty=$object->thirdparty;
$sendtosocid=$thirdparty->id; $sendtosocid=$thirdparty->id;
} }
else if ($object->element == 'member')
{
$thirdparty=$object;
if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
}
else if ($object->element == 'societe') else if ($object->element == 'societe')
{ {
$thirdparty=$object; $thirdparty=$object;
@ -348,18 +353,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto; $substitutionarray['__EMAIL__'] = $sendto;
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':''; $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':'';
// Add specific substitution for contracts
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
{
$datenextexpiration='';
foreach($object->lines as $line)
{
if ($line->statut != 4) continue;
if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue;
}
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
$parameters=array('mode'=>'formemail'); $parameters=array('mode'=>'formemail');
complete_substitutions_array($substitutionarray, $langs, $object, $parameters); complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
@ -367,6 +360,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$subject=make_substitutions($subject, $substitutionarray); $subject=make_substitutions($subject, $substitutionarray);
$message=make_substitutions($message, $substitutionarray); $message=make_substitutions($message, $substitutionarray);
if (method_exists($object, 'makeSubstitution'))
{
$subject = $object->makeSubstitution($subject);
$message = $object->makeSubstitution($message);
}
// Send mail (substitutionarray must be done just before this) // Send mail (substitutionarray must be done just before this)
if (empty($sendcontext)) $sendcontext = 'standard'; if (empty($sendcontext)) $sendcontext = 'standard';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext); $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext);
@ -482,7 +481,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
else else
{ {
$langs->load("other"); $langs->load("other");
setEventMessages($langs->trans('ErrorFailedToReadEntity',$object->element), null, 'errors'); setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors');
dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element); dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
$action = 'presend'; $action = 'presend';
} }

View File

@ -32,7 +32,7 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel
{ {
if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before');
if (empty($object->id)) $object->fetch($id); // Fetch may not be already done if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
// Set public note // Set public note
@ -40,6 +40,6 @@ else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('
{ {
if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before');
if (empty($object->id)) $object->fetch($id); // Fetch may not be already done if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }

View File

@ -0,0 +1,60 @@
<?php
/* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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/core/ajax/vatrates.php
* \brief File to load vat rates combobox
*/
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
require '../../main.inc.php';
$id = GETPOST('id','int');
/*
* View
*/
top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value
if (! empty($id))
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$account=new Account($db);
$result = $account->fetch($id);
if ($result<0) {
$return['value'] = '';
$return['num'] = $result;
$return['error'] = $account->errors[0];
} else {
$return['value'] = $account->currency_code;
$return['num'] = $result;
$return['error'] = '';
}
echo json_encode($return);
}

View File

@ -435,7 +435,7 @@ class box_activity extends ModeleBoxes
} }
// Add the sum in the bottom of the boxes // Add the sum in the bottom of the boxes
$this->info_box_contents[$line][0] = array('tr' => 'class="liste_total"'); $this->info_box_contents[$line][0] = array('tr' => 'class="liste_total_wrap"');
$this->info_box_contents[$line][1] = array('td' => 'align="left" class="liste_total" ', 'text' => $langs->trans("Total")."&nbsp;".$textHead); $this->info_box_contents[$line][1] = array('td' => 'align="left" class="liste_total" ', 'text' => $langs->trans("Total")."&nbsp;".$textHead);
$this->info_box_contents[$line][2] = array('td' => 'align="right" class="liste_total" ', 'text' => $totalnb); $this->info_box_contents[$line][2] = array('td' => 'align="right" class="liste_total" ', 'text' => $totalnb);
$this->info_box_contents[$line][3] = array('td' => 'align="right" class="liste_total" ', 'text' => ''); $this->info_box_contents[$line][3] = array('td' => 'align="right" class="liste_total" ', 'text' => '');

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2017 Nicolas Zabouri <info@inovea-conseil.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -91,7 +92,7 @@ class box_services_contracts extends ModeleBoxes
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= "INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= ")"; $sql.= ")";
$sql.= " WHERE c.entity = ".$conf->entity; $sql.= " WHERE c.entity = ".$conf->entity;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;

View File

@ -286,7 +286,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
if (isset($contents[$i])) if (isset($contents[$i]))
{ {
// TR // TR
if (isset($contents[$i][0]['tr'])) $out.= '<tr class="tdtop" '.$contents[$i][0]['tr'].'>'; if (isset($contents[$i][0]['tr'])) $out.= '<tr '.$contents[$i][0]['tr'].'>';
else $out.= '<tr class="oddeven">'; else $out.= '<tr class="oddeven">';
// Loop on each TD // Loop on each TD

View File

@ -1563,22 +1563,22 @@ abstract class CommonObject
switch ($this->element) { switch ($this->element) {
case 'propal': case 'propal':
$this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, ($line->description?$line->description:$line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
break; break;
case 'commande': case 'commande':
$this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); $this->updateline($line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
break; break;
case 'facture': case 'facture':
$this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice); $this->updateline($line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice);
break; break;
case 'supplier_proposal': case 'supplier_proposal':
$this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->multicurrency_subprice); $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, ($line->description?$line->description:$line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->multicurrency_subprice);
break; break;
case 'order_supplier': case 'order_supplier':
$this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); $this->updateline($line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
break; break;
case 'invoice_supplier': case 'invoice_supplier':
$this->updateline($line->id, $line->desc, $line->subprice, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->qty, 0, 'HT', $line->info_bits, $line->product_type, $line->remise_percent, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); $this->updateline($line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->qty, 0, 'HT', $line->info_bits, $line->product_type, $line->remise_percent, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
break; break;
default: default:
dol_syslog(get_class($this).'::setMulticurrencyRate no updateline defined', LOG_DEBUG); dol_syslog(get_class($this).'::setMulticurrencyRate no updateline defined', LOG_DEBUG);

View File

@ -254,6 +254,7 @@ class Conf
if (! isset($this->global->LDAP_KEY_GROUPS)) $this->global->LDAP_KEY_GROUPS=$this->global->LDAP_FIELD_FULLNAME; if (! isset($this->global->LDAP_KEY_GROUPS)) $this->global->LDAP_KEY_GROUPS=$this->global->LDAP_FIELD_FULLNAME;
if (! isset($this->global->LDAP_KEY_CONTACTS)) $this->global->LDAP_KEY_CONTACTS=$this->global->LDAP_FIELD_FULLNAME; if (! isset($this->global->LDAP_KEY_CONTACTS)) $this->global->LDAP_KEY_CONTACTS=$this->global->LDAP_FIELD_FULLNAME;
if (! isset($this->global->LDAP_KEY_MEMBERS)) $this->global->LDAP_KEY_MEMBERS=$this->global->LDAP_FIELD_FULLNAME; if (! isset($this->global->LDAP_KEY_MEMBERS)) $this->global->LDAP_KEY_MEMBERS=$this->global->LDAP_FIELD_FULLNAME;
if (! isset($this->global->LDAP_KEY_MEMBERS_TYPES)) $this->global->LDAP_KEY_MEMBERS_TYPES=$this->global->LDAP_FIELD_FULLNAME;
// Load translation object with current language // Load translation object with current language
if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US"; if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US";
@ -286,6 +287,8 @@ class Conf
if (! empty($this->modules_parts['dir'])) if (! empty($this->modules_parts['dir']))
{ {
foreach($this->modules_parts['dir'] as $module => $dirs) foreach($this->modules_parts['dir'] as $module => $dirs)
{
if (! empty($this->$module->enabled))
{ {
foreach($dirs as $type => $name) foreach($dirs as $type => $name)
{ {
@ -299,6 +302,7 @@ class Conf
} }
} }
} }
}
// For mycompany storage // For mycompany storage
$this->mycompany->dir_output=$rootfordata."/mycompany"; $this->mycompany->dir_output=$rootfordata."/mycompany";

View File

@ -8,6 +8,7 @@
* Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro>
* Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr> * Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -898,7 +899,7 @@ class ExtraFields
{ {
$tmp=explode(',',$size); $tmp=explode(',',$size);
$newsize=$tmp[0]; $newsize=$tmp[0];
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" " maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>'; $out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
} }
elseif ($type == 'varchar') elseif ($type == 'varchar')
{ {

View File

@ -544,7 +544,7 @@ class Form
$disabled=0; $disabled=0;
$ret='<div class="centpercent center">'; $ret='<div class="centpercent center">';
$ret.='<select data-role="none" class="flat'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionselect" name="massaction"'.($disabled?' disabled="disabled"':'').'>'; $ret.='<select class="flat'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionselect" name="massaction"'.($disabled?' disabled="disabled"':'').'>';
// Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks. // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks.
$parameters=array(); $parameters=array();
@ -561,7 +561,7 @@ class Form
$ret.='</select>'; $ret.='</select>';
// Warning: if you set submit button to disabled, post using 'Enter' will no more work. // Warning: if you set submit button to disabled, post using 'Enter' will no more work.
$ret.='<input type="submit" data-role="none" name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; $ret.='<input type="submit" name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
$ret.='</div>'; $ret.='</div>';
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
@ -1256,6 +1256,7 @@ class Form
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param bool $options_only Return options only (for ajax treatment) * @param bool $options_only Return options only (for ajax treatment)
* @return int <0 if KO, Nb of contact in list if OK * @return int <0 if KO, Nb of contact in list if OK
* @deprected You can use selectcontacts directly (warning order of param was changed)
*/ */
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $showsoc=0, $forcecombo=0, $events=array(), $options_only=false) function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $showsoc=0, $forcecombo=0, $events=array(), $options_only=false)
{ {
@ -1264,7 +1265,8 @@ class Form
} }
/** /**
* Return list of all contacts (for a third party or all) * Return HTML code of the SELECT of list of all contacts (for a third party or all).
* This also set the number of contacts found into $this->num
* *
* @param int $socid Id ot third party or 0 for all * @param int $socid Id ot third party or 0 for all
* @param string $selected Id contact pre-selectionne * @param string $selected Id contact pre-selectionne
@ -2991,9 +2993,11 @@ class Form
* @param string $htmlname Nom de la zone select * @param string $htmlname Nom de la zone select
* @param int $filtertype Not used * @param int $filtertype Not used
* @param int $addempty Add an empty entry * @param int $addempty Add an empty entry
* @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
* @param string $morecss Add more CSS on select tag
* @return void * @return void
*/ */
function select_conditions_paiements($selected=0, $htmlname='condid', $filtertype=-1, $addempty=0) function select_conditions_paiements($selected=0, $htmlname='condid', $filtertype=-1, $addempty=0, $noinfoadmin=0, $morecss='')
{ {
global $langs, $user, $conf; global $langs, $user, $conf;
@ -3004,7 +3008,7 @@ class Form
// Set default value if not already set by caller // Set default value if not already set by caller
if (empty($selected) && ! empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID; if (empty($selected) && ! empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
print '<select class="flat" name="'.$htmlname.'">'; print '<select id="'.$htmlname.'" class="flat selectpaymentterms'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">';
if ($addempty) print '<option value="0">&nbsp;</option>'; if ($addempty) print '<option value="0">&nbsp;</option>';
foreach($this->cache_conditions_paiements as $id => $arrayconditions) foreach($this->cache_conditions_paiements as $id => $arrayconditions)
{ {
@ -3020,7 +3024,7 @@ class Form
print '</option>'; print '</option>';
} }
print '</select>'; print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); if ($user->admin && empty($noinfoadmin)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
} }
@ -3035,7 +3039,7 @@ class Form
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $maxlength Max length of label * @param int $maxlength Max length of label
* @param int $active Active or not, -1 = all * @param int $active Active or not, -1 = all
* @param string $morecss Add more css * @param string $morecss Add more CSS on select tag
* @return void * @return void
*/ */
function select_types_paiements($selected='', $htmlname='paiementtype', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $active=1, $morecss='') function select_types_paiements($selected='', $htmlname='paiementtype', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $active=1, $morecss='')
@ -3275,7 +3279,7 @@ class Form
$return= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">'; $return= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
$sql = 'SELECT rowid, label from '.MAIN_DB_PREFIX.'c_units'; $sql = 'SELECT rowid, label, code from '.MAIN_DB_PREFIX.'c_units';
$sql.= ' WHERE active > 0'; $sql.= ' WHERE active > 0';
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -3308,15 +3312,16 @@ class Form
* @param string $filtre To filter list * @param string $filtre To filter list
* @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
* @param string $moreattrib To add more attribute on select * @param string $moreattrib To add more attribute on select
* @param int $showcurrency Show currency in label
* @return void * @return void
*/ */
function select_comptes($selected='',$htmlname='accountid',$statut=0,$filtre='',$useempty=0,$moreattrib='') function select_comptes($selected='',$htmlname='accountid',$statut=0,$filtre='',$useempty=0,$moreattrib='',$showcurrency=0)
{ {
global $langs, $conf; global $langs, $conf;
$langs->load("admin"); $langs->load("admin");
$sql = "SELECT rowid, label, bank, clos as status"; $sql = "SELECT rowid, label, bank, clos as status, currency_code";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE entity IN (".getEntity('bank_account').")"; $sql.= " WHERE entity IN (".getEntity('bank_account').")";
if ($statut != 2) $sql.= " AND clos = '".$statut."'"; if ($statut != 2) $sql.= " AND clos = '".$statut."'";
@ -3349,6 +3354,7 @@ class Form
print '<option value="'.$obj->rowid.'">'; print '<option value="'.$obj->rowid.'">';
} }
print trim($obj->label); print trim($obj->label);
if ($showcurrency) print ' ('.$obj->currency_code.')';
if ($statut == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')'; if ($statut == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')';
print '</option>'; print '</option>';
$i++; $i++;
@ -5213,15 +5219,16 @@ class Form
*/ */
static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0) static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0)
{ {
global $langs; global $conf, $langs;
global $delayedhtmlcontent; global $delayedhtmlcontent;
$tmpplugin='select2'; // TODO Use an internal dolibarr component instead of select2
if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return '';
$out='<input type="text" class="'.$htmlname.($morecss?' '.$morecss:'').'" '.($moreparam?$moreparam.' ':'').'name="'.$htmlname.'">'; $out='<input type="text" class="'.$htmlname.($morecss?' '.$morecss:'').'" '.($moreparam?$moreparam.' ':'').'name="'.$htmlname.'">';
// TODO Use an internal dolibarr component instead of select2 $tmpplugin='select2';
$outdelayed='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' --> $outdelayed="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
@ -5323,7 +5330,7 @@ class Form
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))
{ {
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT; $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' --> $out.="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
<script type="text/javascript"> <script type="text/javascript">
function formatResult(record) {'."\n"; function formatResult(record) {'."\n";
if ($elemtype == 'category') if ($elemtype == 'category')
@ -5549,8 +5556,8 @@ class Form
{ {
$nbofdifferenttypes = count($object->linkedObjects); $nbofdifferenttypes = count($object->linkedObjects);
print '<br><!-- showLinkedObjectBlock -->'; print '<!-- showLinkedObjectBlock -->';
print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, ''); print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, '', 0, 0, 'showlinkedobjectblock');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -5826,7 +5833,7 @@ class Form
* @param int $useempty 1=Add empty line * @param int $useempty 1=Add empty line
* @return string See option * @return string See option
*/ */
function selectyesno($htmlname,$value='',$option=0,$disabled=false,$useempty='') function selectyesno($htmlname, $value='', $option=0, $disabled=false, $useempty='')
{ {
global $langs; global $langs;

View File

@ -152,7 +152,7 @@ class FormActions
* *
* @param Object $object Object * @param Object $object Object
* @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter' * @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter'
* @param int $socid socid of user * @param int $socid Socid of user
* @param int $forceshowtitle Show title even if there is no actions to show * @param int $forceshowtitle Show title even if there is no actions to show
* @param string $morecss More css on table * @param string $morecss More css on table
* @param int $max Max number of record * @param int $max Max number of record
@ -186,20 +186,23 @@ class FormActions
elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter');
elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
else $title=$langs->trans("Actions"); elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
else $title=$langs->trans("LatestLinkedEvents", $max?$max:'');
$urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:'');
$buttontoaddnewevent = '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.'&socid='.$object->socid.'&projectid='.$object->fk_project.'&backtopage='.urlencode($urlbacktopage).'">'; $buttontoaddnewevent = '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.'&socid='.$object->socid.'&projectid='.$object->fk_project.'&backtopage='.urlencode($urlbacktopage).'">';
$buttontoaddnewevent.= $langs->trans("AddEvent"); $buttontoaddnewevent.= $langs->trans("AddEvent");
$buttontoaddnewevent.= '</a>'; $buttontoaddnewevent.= '</a>';
print '<!-- formactions->showactions -->'."\n";
print load_fiche_titre($title, $buttontoaddnewevent, ''); print load_fiche_titre($title, $buttontoaddnewevent, '');
$page=0; $param=''; $page=0; $param='';
$total = 0; $total = 0;
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">'; print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
@ -213,6 +216,8 @@ class FormActions
$userstatic = new User($this->db); $userstatic = new User($this->db);
if (count($listofactions))
{
$cursorevent = 0; $cursorevent = 0;
foreach($listofactions as $action) foreach($listofactions as $action)
{ {
@ -266,10 +271,15 @@ class FormActions
$cursorevent++; $cursorevent++;
} }
}
else
{
print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
if ($max && $num > $max) if ($max && $num > $max)
{ {
print '<tr class="oddeven"><td colspan="6">'.$langs->trans("More").'...</td></tr>'; print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>';
} }
print '</table>'; print '</table>';

View File

@ -293,12 +293,16 @@ class FormMail extends Form
} }
// Get message template for $this->param["models"] into c_email_templates // Get message template for $this->param["models"] into c_email_templates
$arraydefaultmessage=array();
if ($this->param['models'] != 'none')
{
$model_id=0; $model_id=0;
if (array_key_exists('models_id',$this->param)) if (array_key_exists('models_id',$this->param))
{ {
$model_id=$this->param["models_id"]; $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);
}
//var_dump($this->param["models"]); //var_dump($this->param["models"]);
//var_dump($model_id); //var_dump($model_id);
//var_dump($arraydefaultmessage); //var_dump($arraydefaultmessage);
@ -325,6 +329,8 @@ class FormMail extends Form
$out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n"; $out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n";
} }
if ($this->param['models'] != 'none')
{
$result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
if ($result < 0) if ($result < 0)
{ {
@ -332,16 +338,26 @@ class FormMail extends Form
} }
$modelmail_array=array(); $modelmail_array=array();
foreach($this->lines_model as $line) foreach($this->lines_model as $line)
{
$langs->trans("members");
if (preg_match('/\((.*)\)/', $line->label, $reg))
{
$modelmail_array[$line->id]=$langs->trans($reg[1]); // langs->trans when label is __(xxx)__
}
else
{ {
$modelmail_array[$line->id]=$line->label; $modelmail_array[$line->id]=$line->label;
}
if ($line->lang) $modelmail_array[$line->id].=' ('.$line->lang.')'; if ($line->lang) $modelmail_array[$line->id].=' ('.$line->lang.')';
if ($line->private) $modelmail_array[$line->id].=' - '.$langs->trans("Private"); if ($line->private) $modelmail_array[$line->id].=' - '.$langs->trans("Private");
//if ($line->fk_user != $user->id) $modelmail_array[$line->id].=' - '.$langs->trans("By").' '; //if ($line->fk_user != $user->id) $modelmail_array[$line->id].=' - '.$langs->trans("By").' ';
} }
}
// Zone to select its email template // Zone to select email template
if (count($modelmail_array)>0) if (count($modelmail_array)>0)
{ {
// If list of template is filled
$out.= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; $out.= '<div class="center" style="padding: 0px 0 12px 0">'."\n";
$out.= '<span class="opacitymedium">'.$langs->trans('SelectMailModel').':</span> '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100'); $out.= '<span class="opacitymedium">'.$langs->trans('SelectMailModel').':</span> '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100');
if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1);
@ -356,6 +372,7 @@ class FormMail extends Form
'invoice_supplier_send','thirdparty','contract','all' 'invoice_supplier_send','thirdparty','contract','all'
))) )))
{ {
// If list of template is empty
$out.= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; $out.= '<div class="center" style="padding: 0px 0 12px 0">'."\n";
$out.= $langs->trans('SelectMailModel').': <select name="modelmailselected" disabled="disabled"><option value="none">'.$langs->trans("NoTemplateDefined").'</option></select>'; // Do not put 'disabled' on 'option' tag, it is already on 'select' and it makes chrome crazy. $out.= $langs->trans('SelectMailModel').': <select name="modelmailselected" disabled="disabled"><option value="none">'.$langs->trans("NoTemplateDefined").'</option></select>'; // Do not put 'disabled' on 'option' tag, it is already on 'select' and it makes chrome crazy.
if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1);
@ -495,6 +512,7 @@ class FormMail extends Form
} }
else else
{ {
// Note withto may be a text like 'AllRecipientSelected'
$out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:"";
} }
} }
@ -524,10 +542,22 @@ class FormMail extends Form
$out.= "</td></tr>\n"; $out.= "</td></tr>\n";
} }
// withoptiononeemailperrecipient
if (! empty($this->withoptiononeemailperrecipient))
{
$out.= '<tr><td>';
$out.= $langs->trans("GroupEmails");
$out.= '</td><td>';
$out.=' <input type="checkbox" name="oneemailperrecipient"'.($this->withoptiononeemailperrecipient > 0?' checked="checked"':'').'> ';
$out.= $langs->trans("OneEmailPerRecipient").' - ';
$out.= $langs->trans("WarningIfYouCheckOneRecipientPerEmail");
$out.= '</td></tr>';
}
// CC // CC
if (! empty($this->withtocc) || is_array($this->withtocc)) if (! empty($this->withtocc) || is_array($this->withtocc))
{ {
$out.= '<tr><td width="180">'; $out.= '<tr><td>';
$out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out.= '</td><td>'; $out.= '</td><td>';
if ($this->withtoccreadonly) if ($this->withtoccreadonly)
@ -556,7 +586,7 @@ class FormMail extends Form
// CCC // CCC
if (! empty($this->withtoccc) || is_array($this->withtoccc)) if (! empty($this->withtoccc) || is_array($this->withtoccc))
{ {
$out.= '<tr><td width="180">'; $out.= '<tr><td>';
$out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out.= '</td><td>'; $out.= '</td><td>';
if (! empty($this->withtocccreadonly)) if (! empty($this->withtocccreadonly))
@ -624,7 +654,7 @@ class FormMail extends Form
// Ask delivery receipt // Ask delivery receipt
if (! empty($this->withdeliveryreceipt)) if (! empty($this->withdeliveryreceipt))
{ {
$out.= '<tr><td width="180">'.$langs->trans("DeliveryReceipt").'</td><td>'; $out.= '<tr><td>'.$langs->trans("DeliveryReceipt").'</td><td>';
if (! empty($this->withdeliveryreceiptreadonly)) if (! empty($this->withdeliveryreceiptreadonly))
{ {
@ -656,7 +686,7 @@ class FormMail extends Form
$defaulttopic=make_substitutions($defaulttopic,$this->substit); $defaulttopic=make_substitutions($defaulttopic,$this->substit);
$out.= '<tr>'; $out.= '<tr>';
$out.= '<td class="fieldrequired" width="180">'.$langs->trans("MailTopic").'</td>'; $out.= '<td class="fieldrequired">'.$langs->trans("MailTopic").'</td>';
$out.= '<td>'; $out.= '<td>';
if ($this->withtopicreadonly) if ($this->withtopicreadonly)
{ {
@ -674,7 +704,7 @@ class FormMail extends Form
if (! empty($this->withfile)) if (! empty($this->withfile))
{ {
$out.= '<tr>'; $out.= '<tr>';
$out.= '<td width="180">'.$langs->trans("MailFile").'</td>'; $out.= '<td>'.$langs->trans("MailFile").'</td>';
$out.= '<td>'; $out.= '<td>';
if (! empty($this->withmaindocfile)) if (! empty($this->withmaindocfile))
@ -764,13 +794,14 @@ class FormMail extends Form
$typeforonlinepayment='free'; $typeforonlinepayment='free';
if ($this->param["models"]=='order_send') $typeforonlinepayment='order'; // TODO use detection on something else than template if ($this->param["models"]=='order_send') $typeforonlinepayment='order'; // TODO use detection on something else than template
if ($this->param["models"]=='facture_send') $typeforonlinepayment='invoice'; // TODO use detection on something else than template if ($this->param["models"]=='facture_send') $typeforonlinepayment='invoice'; // TODO use detection on something else than template
if ($this->param["models"]=='member_send') $typeforonlinepayment='member'; // TODO use detection on something else than template
$url=getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); $url=getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']);
//$paymenturl=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url)); //$paymenturl=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url));
$paymenturl=$url; $paymenturl=$url;
} }
} }
$this->substit['__PERSONALIZED__']=$paymenturl; $this->substit['__PERSONALIZED__']=$paymenturl; // deprecated
$this->substit['__ONLINE_PAYMENT_URL__']='YY'.$paymenturl; $this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl;
//Add lines substitution key from each line //Add lines substitution key from each line
$lines = ''; $lines = '';
@ -804,7 +835,7 @@ class FormMail extends Form
} }
$out.= '<tr>'; $out.= '<tr>';
$out.= '<td width="180" valign="top">'.$langs->trans("MailText").'</td>'; $out.= '<td valign="top">'.$langs->trans("MailText").'</td>';
$out.= '<td>'; $out.= '<td>';
if ($this->withbodyreadonly) if ($this->withbodyreadonly)
{ {
@ -876,8 +907,8 @@ class FormMail extends Form
/** /**
* Return templates of email with type = $type_template or type = 'all' * Return templates of email with type = $type_template or type = 'all'.
* This search into table c_email_templates. * This search into table c_email_templates. Used by the get_form function.
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param string $type_template Get message for type=$type_template, type='all' also included. * @param string $type_template Get message for type=$type_template, type='all' also included.
@ -887,7 +918,7 @@ class FormMail extends Form
* @param int $active 1=Only active template, 0=Only disabled, -1=All * @param int $active 1=Only active template, 0=Only disabled, -1=All
* @return array array('topic'=>,'content'=>,..) * @return array array('topic'=>,'content'=>,..)
*/ */
private function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1) public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1)
{ {
$ret=array(); $ret=array();
@ -999,7 +1030,7 @@ class FormMail extends Form
$sql = "SELECT rowid, label, topic, content, content_lines, lang, fk_user, private, position"; $sql = "SELECT rowid, label, topic, content, content_lines, lang, fk_user, private, position";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
$sql.= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; $sql.= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')";
$sql.= " AND entity IN (".getEntity('c_email_templates', 0).")"; $sql.= " AND entity IN (".getEntity('c_email_templates', 1).")";
$sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own. $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own.
if ($active >= 0) $sql.=" AND active = ".$active; if ($active >= 0) $sql.=" AND active = ".$active;
//if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; // Return all languages //if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; // Return all languages
@ -1038,8 +1069,7 @@ class FormMail extends Form
/** /**
* Set substit array from object. This is call when suggesting the email template into forms to send email. * Set substit array from object. This is call when suggesting the email template into forms before sending email.
* TODO Replace with getCommonSubstitutionArray with param onlykey = 2
* *
* @param CommonObject $object Object to use * @param CommonObject $object Object to use
* @param Translate $outputlangs Object lang * @param Translate $outputlangs Object lang
@ -1049,34 +1079,12 @@ class FormMail extends Form
function setSubstitFromObject($object, $outputlangs=null) function setSubstitFromObject($object, $outputlangs=null)
{ {
global $conf, $user; global $conf, $user;
$this->substit['__REF__'] = $object->ref;
$this->substit['__REFCLIENT__'] = isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : '');
$this->substit['__REFSUPPLIER__'] = isset($object->ref_supplier) ? $object->ref_supplier : '';
$this->substit['__DATE_YMD__'] = isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : ''; $parameters=array('mode'=>$mode);
$this->substit['__DATE_DUE_YMD__'] = isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : ''; $tmparray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
$this->substit['__AMOUNT__'] = price($object->total_ttc); complete_substitutions_array($tmparray, $outputlangs, null, $parameters);
$this->substit['__AMOUNT_WO_TAX__'] = price($object->total_ht);
$this->substit['__AMOUNT_VAT__'] = price($object->total_tva);
$this->substit['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); $this->substit=$tmparray;
$this->substit['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:'');
$this->substit['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:'');
$this->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:'');
$this->substit['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:'');
$this->substit['__SIGNATURE__'] = $user->signature;
$this->substit['__PERSONALIZED__'] = '';
$this->substit['__CONTACTCIVNAME__'] = ''; // Will be replace just before sending
// Create dynamic tags for __EXTRAFIELD_FIELD__
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element, true);
$object->fetch_optionals($object->id, $extralabels);
foreach ($extrafields->attribute_label as $key => $label) {
$this->substit['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
}
// Fill substit_lines with each object lines content // Fill substit_lines with each object lines content
if (is_array($object->lines)) if (is_array($object->lines))
@ -1094,7 +1102,7 @@ class FormMail extends Form
'__QUANTITY__' => $line->qty, '__QUANTITY__' => $line->qty,
'__SUBPRICE__' => price($line->subprice), '__SUBPRICE__' => price($line->subprice),
'__AMOUNT__' => price($line->total_ttc), '__AMOUNT__' => price($line->total_ttc),
'__AMOUNT_WO_TAX__' => price($line->total_ht), '__AMOUNT_EXCL_TAX__' => price($line->total_ht),
//'__PRODUCT_EXTRAFIELD_FIELD__' Done dinamically just after //'__PRODUCT_EXTRAFIELD_FIELD__' Done dinamically just after
); );
@ -1127,54 +1135,43 @@ class FormMail extends Form
{ {
global $conf, $langs; global $conf, $langs;
$vars=array();
if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines')
{ {
$vars=array( $parameters=array('mode'=>$mode);
'__REF__'=>'__REF__', $tmparray=getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects
'__REFCLIENT__'=>'__REFCLIENT__', complete_substitutions_array($tmparray, $langs, null, $parameters);
'__REFSUPPLIER__'=>'__REFSUPPLIER__',
'__THIRDPARTY_ID__'=>'__THIRDPARTY_ID__',
'__THIRDPARTY_NAME__'=>'__THIRDPARTY_NAME__',
'__PROJECT_ID__'=>'__PROJECT_ID__',
'__PROJECT_REF__'=>'__PROJECT_REF__',
'__PROJECT_NAME__'=>'__PROJECT_NAME__',
'__CONTACTCIVNAME__'=>'__CONTACTCIVNAME__',
'__AMOUNT__'=>'__AMOUNT__',
'__AMOUNT_WO_TAX__'=>'__AMOUNT_WO_TAX__',
'__AMOUNT_VAT__'=>'__AMOUNT_VAT__',
'__PERSONALIZED__'=>'__PERSONALIZED__', // Paypal link will be added here in form mode
'__SIGNATURE__'=>'__SIGNATURE__',
);
if ($mode == 'formwithlines') if ($mode == 'formwithlines')
{ {
$vars[] = '__LINES__'; // Will be set by the get_form function $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function
} }
if ($mode == 'formforlines') if ($mode == 'formforlines')
{ {
$vars[] = '__QUANTITY__'; // Will be set by the get_form function $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function
} }
} }
if ($mode == 'emailing') if ($mode == 'emailing')
{ {
$parameters=array('mode'=>$mode);
$tmparray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects
complete_substitutions_array($tmparray, $langs, null, $parameters);
// For mass emailing, we have different keys // For mass emailing, we have different keys
$vars=array( $tmparray['__ID__'] = 'IdRecord';
'__ID__' => 'IdRecord', $tmparray['__EMAIL__'] = 'EMailRecipient';
'__EMAIL__' => 'EMailRecipient', $tmparray['__LASTNAME__'] = 'Lastname';
'__LASTNAME__' => 'Lastname', $tmparray['__FIRSTNAME__'] = 'Firstname';
'__FIRSTNAME__' => 'Firstname', $tmparray['__MAILTOEMAIL__'] = 'TagMailtoEmail';
'__MAILTOEMAIL__' => 'TagMailtoEmail', $tmparray['__OTHER1__'] = 'Other1';
'__OTHER1__' => 'Other1', $tmparray['__OTHER2__'] = 'Other2';
'__OTHER2__' => 'Other2', $tmparray['__OTHER3__'] = 'Other3';
'__OTHER3__' => 'Other3', $tmparray['__OTHER4__'] = 'Other4';
'__OTHER4__' => 'Other4', $tmparray['__OTHER5__'] = 'Other5';
'__OTHER5__' => 'Other5', $tmparray['__SIGNATURE__'] = 'TagSignature';
'__SIGNATURE__' => 'TagSignature', $tmparray['__CHECK_READ__'] = 'TagCheckMail';
'__CHECK_READ__' => 'TagCheckMail', $tmparray['__UNSUBSCRIBE__'] = 'TagUnsubscribe';
'__UNSUBSCRIBE__' => 'TagUnsubscribe'
//,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing
);
$onlinepaymentenabled = 0; $onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
@ -1182,13 +1179,13 @@ class FormMail extends Form
if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++; if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++;
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{ {
$vars['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN; $tmparray['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN;
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
{ {
if ($conf->adherent->enabled) $vars['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember'; if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember';
if ($conf->facture->enabled) $vars['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice'; if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice';
if ($conf->commande->enabled) $vars['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder'; if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder';
if ($conf->contrat->enabled) $vars['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine'; if ($conf->contrat->enabled) $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine';
} }
} }
else else
@ -1201,36 +1198,16 @@ class FormMail extends Form
$vars['__SECUREKEYPAYMENT_CONTRACTLINE__']=''; $vars['__SECUREKEYPAYMENT_CONTRACTLINE__']='';
*/ */
} }
// Old vars removed from doc
/*
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
$vars['__SECUREKEYPAYPAL__']='SecureKeyPaypal';
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
{
if ($conf->adherent->enabled) $vars['__SECUREKEYPAYPAL_MEMBER__']='SecureKeyPaypalUniquePerMember';
if ($conf->facture->enabled) $vars['__SECUREKEYPAYPAL_INVOICE__']='SecureKeyPaypalUniquePerInvoice';
if ($conf->commande->enabled) $vars['__SECUREKEYPAYPAL_ORDER__']='SecureKeyPaypalUniquePerOrder';
if ($conf->contrat->enabled) $vars['__SECUREKEYPAYPAL_CONTRACTLINE__']='SecureKeyPaypalUniquePerContractLine';
}
}
else
{
$vars['__SECUREKEYPAYPAL__']='';
$vars['__SECUREKEYPAYPAL_MEMBER__']='';
}*/
} }
$parameters=array('mode'=>$mode); $tmparray['__(AnyTranslationKey)__']="Translation";
$tmparray=getCommonSubstitutionArray($langs, 2, null, $object);
complete_substitutions_array($tmparray, $langs, null, $parameters);
foreach($tmparray as $key => $val) foreach($tmparray as $key => $val)
{ {
$vars[$key]=$key; if (empty($val)) $tmparray[$key]=$key;
} }
return $vars; return $tmparray;
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -179,12 +179,18 @@ class Ldap
if (preg_match('/^ldap/',$host)) if (preg_match('/^ldap/',$host))
{ {
if ($this->serverPing($host) === true) {
$this->connection = ldap_connect($host); $this->connection = ldap_connect($host);
} }
else continue;
}
else else
{ {
if ($this->serverPing($host, $this->serverPort) === true) {
$this->connection = ldap_connect($host,$this->serverPort); $this->connection = ldap_connect($host,$this->serverPort);
} }
else continue;
}
if (is_resource($this->connection)) if (is_resource($this->connection))
{ {
@ -662,6 +668,24 @@ class Ldap
} }
} }
/**
* Ping a server before ldap_connect for avoid waiting
*
* @param string $host Server host or address
* @param int $port Server port (default 389)
* @param int $timeout Timeout in second (default 1s)
* @return boolean true or false
*/
function serverPing($host, $port=389, $timeout=1)
{
$op = @fsockopen($host, $port, $errno, $errstr, $timeout);
if (!$op) return false; //DC is N/A
else {
fclose($op); //explicitly close open socket connection
return true; //DC is up & running, we can safely connect with ldap_connect
}
}
// Attribute methods ----------------------------------------------------- // Attribute methods -----------------------------------------------------
@ -1387,13 +1411,16 @@ class Ldap
/** /**
* Return available value of group GID * Return available value of group GID
* *
* @param string $keygroup Key of group
* @return int gid number * @return int gid number
*/ */
function getNextGroupGid() function getNextGroupGid($keygroup='LDAP_KEY_GROUPS')
{ {
global $conf; global $conf;
$search='('.$conf->global->LDAP_KEY_GROUPS.'=*)'; if (empty($keygroup)) $keygroup='LDAP_KEY_GROUPS';
$search='('.$conf->global->$keygroup.'=*)';
$result = $this->search($this->groups,$search); $result = $this->search($this->groups,$search);
if($result) if($result)
{ {
@ -1411,5 +1438,3 @@ class Ldap
return 0; return 0;
} }
} }

View File

@ -44,6 +44,35 @@ top_httphead('text/javascript; charset=UTF-8');
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
else header('Cache-Control: no-cache'); else header('Cache-Control: no-cache');
?> ?>
// Javascript libraries for Dolibarr ERP CRM (https://www.dolibarr.org)
/**
* Set select2 translations (if module was loaded).
*/
(function ($) {
"use strict";
if (typeof $.fn.select2 != "undefined") {
/* console.log($.fn.select2);
console.log("ok"); */
$.fn.select2.locales['xx'] = {
formatMatches: function (matches) { return matches + " <?php echo dol_escape_js($langs->trans("Select2ResultFoundUseArrows")); ?>"; },
formatNoMatches: function () { return "<?php echo dol_escape_js($langs->trans("Select2NotFound")); ?>"; },
formatInputTooShort: function (input, min) { var n = min - input.length;
if (n > 1) return "<?php echo dol_escape_js($langs->trans("Select2Enter")); ?> " + n + " <?php echo dol_escape_js($langs->trans("Select2MoreCharacters")); ?>";
else return "<?php echo dol_escape_js($langs->trans("Select2Enter")); ?> " + n + " <?php echo dol_escape_js($langs->trans("Select2MoreCharacter")); ?>"
},
formatLoadMore: function (pageNumber) { return "<?php echo dol_escape_js($langs->trans("Select2LoadingMoreResults")); ?>"; },
formatSearching: function () { return "<?php echo dol_escape_js($langs->trans("Select2SearchInProgress")); ?>"; }
};
$.extend($.fn.select2.defaults, $.fn.select2.locales['xx']);
}
})(jQuery);
/* /*
* ================================================================= * =================================================================
@ -53,6 +82,7 @@ else header('Cache-Control: no-cache');
* SimpleDateFormat a utiliser pour retour * SimpleDateFormat a utiliser pour retour
* ================================================================== * ==================================================================
*/ */
/*
function showDP(base,dateFieldID,format,codelang) function showDP(base,dateFieldID,format,codelang)
{ {
// check to see if another box is already showing // check to see if another box is already showing
@ -136,7 +166,7 @@ function resetDP(base,dateFieldID,format,codelang)
function loadMonth(base,month,year,ymd,codelang) function loadMonth(base,month,year,ymd,codelang)
{ {
/* showDP.box.innerHTML="Loading..."; */ // showDP.box.innerHTML="Loading...";
// alert(codelang); // alert(codelang);
var theURL=base+"datepicker.php?cm=shw&lang="+codelang; var theURL=base+"datepicker.php?cm=shw&lang="+codelang;
theURL+="&m="+encodeURIComponent(month); theURL+="&m="+encodeURIComponent(month);
@ -163,37 +193,6 @@ function closeDPBox()
showDP.datefieldID=null; showDP.datefieldID=null;
} }
function dpChangeDay(dateFieldID,format)
{
showDP.datefieldID=dateFieldID;
console.log("Call dpChangeDay, we save date into detailed fields.");
var thefield=getObjectFromID(showDP.datefieldID);
var thefieldday=getObjectFromID(showDP.datefieldID+"day");
var thefieldmonth=getObjectFromID(showDP.datefieldID+"month");
var thefieldyear=getObjectFromID(showDP.datefieldID+"year");
var date=getDateFromFormat(thefield.value,format);
if (date)
{
thefieldday.value=date.getDate();
if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
thefieldmonth.value=date.getMonth()+1;
if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
thefieldyear.value=date.getFullYear();
if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
}
else
{
thefieldday.value='';
if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
thefieldmonth.value='';
if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
thefieldyear.value='';
if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
}
}
function dpClickDay(year,month,day,format) function dpClickDay(year,month,day,format)
{ {
var thefield=getObjectFromID(showDP.datefieldID); var thefield=getObjectFromID(showDP.datefieldID);
@ -221,16 +220,6 @@ function dpHighlightDay(year,month,day,months){
displayinfo.innerHTML=months[month-1]+" "+day+", "+year; displayinfo.innerHTML=months[month-1]+" "+day+", "+year;
} }
// Returns an object given an id
function getObjectFromID(id){
var theObject;
if(document.getElementById)
theObject=document.getElementById(id);
else
theObject=document.all[id];
return theObject;
}
// This Function returns the top position of an object // This Function returns the top position of an object
function getTop(theitem){ function getTop(theitem){
var offsetTrail = theitem; var offsetTrail = theitem;
@ -257,6 +246,85 @@ function getLeft(theitem){
return offsetLeft; return offsetLeft;
} }
// To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and
// not put popup completely on the front)
// Used only bu popup calendar
function hideSelectBoxes() {
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1)
{
for(var i = 0; i < document.all.length; i++)
{
if(document.all[i].tagName)
if(document.all[i].tagName == "SELECT")
document.all[i].style.visibility="hidden";
}
}
}
// To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and
// not put popup completely on the front)
// Used only bu popup calendar
function displaySelectBoxes() {
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1)
{
for(var i = 0; i < document.all.length; i++)
{
if(document.all[i].tagName)
if(document.all[i].tagName == "SELECT")
document.all[i].style.visibility="visible";
}
}
}
*/
// Returns an object given an id
function getObjectFromID(id){
var theObject;
if(document.getElementById)
theObject=document.getElementById(id);
else
theObject=document.all[id];
return theObject;
}
// Called after selection of a date to save details into detailed fields
function dpChangeDay(dateFieldID,format)
{
//showDP.datefieldID=dateFieldID;
console.log("Call dpChangeDay, we save date into detailed fields.");
var thefield=getObjectFromID(dateFieldID);
var thefieldday=getObjectFromID(dateFieldID+"day");
var thefieldmonth=getObjectFromID(dateFieldID+"month");
var thefieldyear=getObjectFromID(dateFieldID+"year");
var date=getDateFromFormat(thefield.value,format);
if (date)
{
thefieldday.value=date.getDate();
if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
thefieldmonth.value=date.getMonth()+1;
if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
thefieldyear.value=date.getFullYear();
if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
}
else
{
thefieldday.value='';
if(thefieldday.onchange) thefieldday.onchange.call(thefieldday);
thefieldmonth.value='';
if(thefieldmonth.onchange) thefieldmonth.onchange.call(thefieldmonth);
thefieldyear.value='';
if(thefieldyear.onchange) thefieldyear.onchange.call(thefieldyear);
}
}
// Create XMLHttpRequest object and load url // Create XMLHttpRequest object and load url
// Used by calendar or other ajax processes // Used by calendar or other ajax processes
@ -316,40 +384,6 @@ function loadXMLDoc(url,readyStateFunction,async)
return req; return req;
} }
/* To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and
* not put popup completely on the front)
* Used only bu popup calendar
*/
function hideSelectBoxes() {
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1)
{
for(var i = 0; i < document.all.length; i++)
{
if(document.all[i].tagName)
if(document.all[i].tagName == "SELECT")
document.all[i].style.visibility="hidden";
}
}
}
/* To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and
* not put popup completely on the front)
* Used only bu popup calendar
*/
function displaySelectBoxes() {
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1)
{
for(var i = 0; i < document.all.length; i++)
{
if(document.all[i].tagName)
if(document.all[i].tagName == "SELECT")
document.all[i].style.visibility="visible";
}
}
}
/* /*
* ================================================================= * =================================================================

View File

@ -1,67 +0,0 @@
<?php
/* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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/core/js/select2_locale.js.php
* \brief File that include javascript functions for timepicker
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1);
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1);
if (! defined('NOLOGIN')) define('NOLOGIN',1);
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
session_cache_limiter(FALSE);
require_once '../../main.inc.php';
// Define javascript type
top_httphead('text/javascript; charset=UTF-8');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
else header('Cache-Control: no-cache');
?>
/**
* Select2 French translation
*/
(function ($) {
"use strict";
$.fn.select2.locales['xx'] = {
formatMatches: function (matches) { return matches + " <?php echo dol_escape_js($langs->trans("Select2ResultFoundUseArrows")); ?>"; },
formatNoMatches: function () { return "<?php echo dol_escape_js($langs->trans("Select2NotFound")); ?>"; },
formatInputTooShort: function (input, min) { var n = min - input.length;
if (n > 1) return "<?php echo dol_escape_js($langs->trans("Select2Enter")); ?> " + n + " <?php echo dol_escape_js($langs->trans("Select2MoreCharacters")); ?>";
else return "<?php echo dol_escape_js($langs->trans("Select2Enter")); ?> " + n + " <?php echo dol_escape_js($langs->trans("Select2MoreCharacter")); ?>"
},
formatLoadMore: function (pageNumber) { return "<?php echo dol_escape_js($langs->trans("Select2LoadingMoreResults")); ?>"; },
formatSearching: function () { return "<?php echo dol_escape_js($langs->trans("Select2SearchInProgress")); ?>"; }
};
$.extend($.fn.select2.defaults, $.fn.select2.locales['xx']);
})(jQuery);
<?php
if (is_object($db)) $db->close();

View File

@ -396,14 +396,15 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $
global $conf; global $conf;
if (! empty($conf->browser->phone)) return ''; // select2 disabled for smartphones with standard browser (does not works, popup appears outside screen) if (! empty($conf->browser->phone)) return ''; // select2 disabled for smartphones with standard browser (does not works, popup appears outside screen)
if (! empty($conf->dol_use_jmobile)) return ''; // select2 works with jmobile but it breaks the autosize feature of jmobile. //if (! empty($conf->dol_use_jmobile)) return ''; // select2 works with jmobile but it breaks the autosize feature of jmobile.
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
if (empty($conf->use_javascript_ajax)) return ''; if (empty($conf->use_javascript_ajax)) return '';
if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return '';
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0; if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
$tmpplugin='select2'; $tmpplugin='select2';
$msg='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' --> $msg="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$(\''.(preg_match('/^\./',$htmlname)?$htmlname:'#'.$htmlname).'\').'.$tmpplugin.'({ $(\''.(preg_match('/^\./',$htmlname)?$htmlname:'#'.$htmlname).'\').'.$tmpplugin.'({

View File

@ -1369,8 +1369,8 @@ function dol_meta_create($object)
DATE=\"" . dol_print_date($object->date,'') . "\" DATE=\"" . dol_print_date($object->date,'') . "\"
NB_ITEMS=\"" . $nblignes . "\" NB_ITEMS=\"" . $nblignes . "\"
CLIENT=\"" . $client . "\" CLIENT=\"" . $client . "\"
AMOUNT_WO_TAX=\"" . $object->total_ht . "\" AMOUNT_EXCL_TAX=\"" . $object->total_ht . "\"
AMOUNT_INC_TAX=\"" . $object->total_ttc . "\"\n"; AMOUNT=\"" . $object->total_ttc . "\"\n";
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
{ {

View File

@ -129,7 +129,7 @@ function getEntity($element, $shared=1)
else else
{ {
$out=''; $out='';
$addzero = array('user', 'usergroup', 'email_template', 'default_values'); $addzero = array('user', 'usergroup', 'c_email_templates', 'email_template', 'default_values');
if (in_array($element, $addzero)) $out.= '0,'; if (in_array($element, $addzero)) $out.= '0,';
$out.= $conf->entity; $out.= $conf->entity;
return $out; return $out;
@ -601,9 +601,10 @@ function dol_include_once($relpath, $classname='')
* *
* @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile * @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile
* @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file) * @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file)
* @return string Full filesystem path (if mode=0), Full url path (if mode=1) * @param int $returnemptyifnotfound If path==0 and if file was not found, do not return default path but an empty string
* @return string Full filesystem path (if path=0), Full url path (if mode=1)
*/ */
function dol_buildpath($path, $type=0) function dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
{ {
global $conf; global $conf;
@ -611,16 +612,20 @@ function dol_buildpath($path, $type=0)
if (empty($type)) // For a filesystem path if (empty($type)) // For a filesystem path
{ {
$res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard value $res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard default path
foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
{ {
if ($key == 'main') continue; if ($key == 'main') continue;
if (file_exists($dirroot.'/'.$path)) if (file_exists($dirroot.'/'.$path))
{ {
$res=$dirroot.'/'.$path; $res=$dirroot.'/'.$path;
break; return $res;
} }
} }
if ($returnemptyifnotfound) // Not found, we return empty string
{
return '';
}
} }
else // For an url path else // For an url path
{ {
@ -1011,11 +1016,12 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
* @param int $notab -1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required. * @param int $notab -1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required.
* @param string $picto Add a picto on tab title * @param string $picto Add a picto on tab title
* @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto.
* @param string $morehtmlright Add more html content on right of tabs title
* @return void * @return void
*/ */
function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0) function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
{ {
print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath); print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright);
} }
/** /**
@ -1027,14 +1033,17 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto
* @param int $notab -1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required. * @param int $notab -1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required.
* @param string $picto Add a picto on tab title * @param string $picto Add a picto on tab title
* @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto.
* @param string $morehtmlright Add more html content on right of tabs title
* @return string * @return string
*/ */
function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0) function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
{ {
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
$out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n"; $out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n";
if ($morehtmlright) $out.='<div class="inline-block floatright tabsElem">'.$morehtmlright.'</div>'; // Output right area first so when space is missing, text is in front of tabs and not under.
// Show title // Show title
$showtitle=1; $showtitle=1;
if (! empty($conf->dol_optimize_smallscreen)) $showtitle=0; if (! empty($conf->dol_optimize_smallscreen)) $showtitle=0;
@ -1055,6 +1064,8 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
if (count($keys)) $maxkey=max($keys); if (count($keys)) $maxkey=max($keys);
} }
//$conf->global->MAIN_MAXTABS_IN_CARD=3;
// Show tabs // Show tabs
$bactive=false; $bactive=false;
// if =0 we don't use the feature // if =0 we don't use the feature
@ -1142,7 +1153,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
{ {
$tabsname=str_replace("@", "", $picto); $tabsname=str_replace("@", "", $picto);
$out.='<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">'; $out.='<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">';
$out.='<a href="#" data-role="button" class="tab moretab inline-block">'.$langs->trans("More").'... ('.$nbintab.')</a>'; $out.='<a href="#" data-role="button" class="tab moretab inline-block tabunactive">'.$langs->trans("More").'... ('.$nbintab.')</a>';
$out.='<div id="moretabsList'.$tabsname.'" style="position: absolute; left: -999em;text-align: left;margin:0px;padding:2px">'.$outmore.'</div>'; $out.='<div id="moretabsList'.$tabsname.'" style="position: absolute; left: -999em;text-align: left;margin:0px;padding:2px">'.$outmore.'</div>';
$out.="</div>\n"; $out.="</div>\n";
@ -3780,7 +3791,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
if (! preg_match('/\//', $rate)) $ret=price($rate,0,'',0,0).($addpercent?'%':''); if (! preg_match('/\//', $rate)) $ret=price($rate,0,'',0,0).($addpercent?'%':'');
else else
{ {
// TODO Split on / and output with a price2num to have clean numbers with ton of 000. // TODO Split on / and output with a price2num to have clean numbers without ton of 000.
$ret=$rate.($addpercent?'%':''); $ret=$rate.($addpercent?'%':'');
} }
if ($info_bits & 1) $ret.=' *'; if ($info_bits & 1) $ret.=' *';
@ -5208,9 +5219,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
if (empty($exclude) || ! in_array('system', $exclude)) if (empty($exclude) || ! in_array('system', $exclude))
{ {
$substitutionarray=array_merge($substitutionarray, array( $substitutionarray['__(AnyTranslationKey)__']=$outputlangs->trans('TranslationKey');
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT $substitutionarray['__DOL_MAIN_URL_ROOT__']=DOL_MAIN_URL_ROOT;
));
} }
if (empty($exclude) || ! in_array('mycompany', $exclude)) if (empty($exclude) || ! in_array('mycompany', $exclude))
{ {
@ -5227,13 +5237,67 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
'__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id
)); ));
} }
if (is_object($object) && (empty($exclude) || ! in_array('object', $exclude))) if (($onlykey || is_object($object)) && (empty($exclude) || ! in_array('object', $exclude)))
{
if ($onlykey)
{
$substitutionarray['__ID__'] = '__ID__';
$substitutionarray['__REF__'] = '__REF__';
$substitutionarray['__REFCLIENT__'] = '__REFCLIENT__';
$substitutionarray['__REFSUPPLIER__'] = '__REFSUPPLIER__';
$substitutionarray['__EXTRAFIELD_XXX__'] = '__EXTRAFIELD_XXX__';
$substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__';
$substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__';
$substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__';
$substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__';
$substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__';
$substitutionarray['__PROJECT_ID__'] = '__PROJECT_ID__';
$substitutionarray['__PROJECT_REF__'] = '__PROJECT_REF__';
$substitutionarray['__PROJECT_NAME__'] = '__PROJECT_REF__';
$substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = 'Highest date planned for a service start';
$substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = 'Highest date and hour planned for service start';
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = 'Lowest data for planned expiration of service';
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = 'Lowest date and hour for planned expiration of service';
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'LinkToPayOnlineIfApplicable';
$substitutionarray['__SECUREKEYPAYMENT__'] = 'Security key (if key is not unique per record)';
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = 'Security key for payment on a member subscription (one key per member)';
$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = 'Security key for payment on an order';
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = 'Security key for payment on an invoice';
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'Security key for payment on a a service';
}
else
{ {
$substitutionarray['__ID__'] = $object->id; $substitutionarray['__ID__'] = $object->id;
$substitutionarray['__REF__'] = $object->ref; $substitutionarray['__REF__'] = $object->ref;
$substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : '')); $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : ''));
$substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : ''); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : '');
// TODO USe this ?
$msgishtml = 0;
if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
$substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname;
$substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname;
if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($langs)):$object->getFullName($langs);
$substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe;
$substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address;
$substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip;
$substitutionarray['__MEMBER_TOWN__']=$msgishtml?dol_htmlentitiesbr($object->town):$object->town;
$substitutionarray['__MEMBER_COUNTRY__']=$msgishtml?dol_htmlentitiesbr($object->country):$object->country;
$substitutionarray['__MEMBER_EMAIL__']=$msgishtml?dol_htmlentitiesbr($object->email):$object->email;
$substitutionarray['__MEMBER_BIRTH__']=$msgishtml?dol_htmlentitiesbr($birthday):$birthday;
$substitutionarray['__MEMBER_PHOTO__']=$msgishtml?dol_htmlentitiesbr($object->photo):$object->photo;
$substitutionarray['__MEMBER_LOGIN__']=$msgishtml?dol_htmlentitiesbr($object->login):$object->login;
$substitutionarray['__MEMBER_PASSWORD__']=$msgishtml?dol_htmlentitiesbr($object->pass):$object->pass;
$substitutionarray['__MEMBER_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone;
$substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso;
$substitutionarray['__MEMBER_PHONEMOBILE__']=$msgishtml?dol_htmlentitiesbr($object->phone_mobile):$object->phone_mobile;
if (is_object($object->thirdparty) && $object->thirdparty->id > 0) if (is_object($object->thirdparty) && $object->thirdparty->id > 0)
{ {
$substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:'');
@ -5258,14 +5322,30 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
} }
} }
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'LinkToPayOnlineIfApplicable'; if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
{
$dateplannedstart='';
$datenextexpiration='';
foreach($object->lines as $line)
{
if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue;
if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue;
}
$substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc');
$substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard');
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'TODO';
}
} }
if (empty($exclude) || ! in_array('objectamount', $exclude)) if (empty($exclude) || ! in_array('objectamount', $exclude))
{ {
$substitutionarray['__DATE_YMD__'] = is_object($object)?(isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : '') : ''; $substitutionarray['__DATE_YMD__'] = is_object($object)?(isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : '') : '';
$substitutionarray['__DATE_DUE_YMD__'] = is_object($object)?(isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : '') : ''; $substitutionarray['__DATE_DUE_YMD__'] = is_object($object)?(isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : '') : '';
$substitutionarray['__AMOUNT__'] = is_object($object)?$object->total_ttc:''; $substitutionarray['__AMOUNT__'] = is_object($object)?$object->total_ttc:'';
$substitutionarray['__AMOUNT_WO_TAX__']= is_object($object)?$object->total_ht:''; $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object)?$object->total_ht:'';
$substitutionarray['__AMOUNT_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; $substitutionarray['__AMOUNT_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):'';
// For backward compatibility // For backward compatibility
if ($onlykey != 2) if ($onlykey != 2)
@ -5280,41 +5360,35 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
{ {
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! empty($onlykey))
{
$tmp=$tmp2=$tmp3=$tmp4=$tmp5=array();
}
else
{
$tmp=dol_getdate(dol_now(), true); $tmp=dol_getdate(dol_now(), true);
$tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp3=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $tmp3=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp5=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $tmp5=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']);
}
$substitutionarray=array_merge($substitutionarray, array( $substitutionarray=array_merge($substitutionarray, array(
'__DAY__' => $tmp['mday'], '__DAY__' => (string) $tmp['mday'],
'__MONTH__' => $tmp['mon'], '__MONTH__' => (string) $tmp['mon'],
'__YEAR__' => $tmp['year'], '__YEAR__' => (string) $tmp['year'],
'__PREVIOUS_DAY__' => $tmp2['day'], '__PREVIOUS_DAY__' => (string) $tmp2['day'],
'__PREVIOUS_MONTH__' => $tmp3['month'], '__PREVIOUS_MONTH__' => (string) $tmp3['month'],
'__PREVIOUS_YEAR__' => ($tmp['year'] - 1), '__PREVIOUS_YEAR__' => (string) ($tmp['year'] - 1),
'__NEXT_DAY__' => $tmp4['day'], '__NEXT_DAY__' => (string) $tmp4['day'],
'__NEXT_MONTH__' => $tmp5['month'], '__NEXT_MONTH__' => (string) $tmp5['month'],
'__NEXT_YEAR__' => ($tmp['year'] + 1), '__NEXT_YEAR__' => (string) ($tmp['year'] + 1),
)); ));
} }
if (empty($exclude) || ! in_array('user', $exclude)) if (empty($exclude) || ! in_array('user', $exclude))
{ {
$substitutionarray=array_merge($substitutionarray, array( $substitutionarray=array_merge($substitutionarray, array(
'__USER_ID__' => $user->id, '__USER_ID__' => (string) $user->id,
'__USER_LOGIN__' => $user->login, '__USER_LOGIN__' => (string) $user->login,
'__USER_LASTNAME__' => $user->lastname, '__USER_LASTNAME__' => (string) $user->lastname,
'__USER_FIRSTNAME__' => $user->firstname, '__USER_FIRSTNAME__' => (string) $user->firstname,
'__USER_FULLNAME__' => $user->getFullName($outputlangs), '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs),
'__USER_SUPERVISOR_ID__' => $user->fk_user, '__USER_SUPERVISOR_ID__' => (string) $user->fk_user,
'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '') '__SIGNATURE__' => (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '')
)); ));
} }
if (! empty($conf->multicompany->enabled)) if (! empty($conf->multicompany->enabled))
@ -5369,8 +5443,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
} }
/** /**
* Complete the $substitutionarray with more entries. * Complete the $substitutionarray with more entries coming from external module that had set the "substitutions=1" into module_part array.
* Can also add substitution keys coming from external module that had set the "substitutions=1" into module_part array. In this case, method completesubstitutionarray provided by module is called. * In this case, method completesubstitutionarray provided by module is called.
* *
* @param array $substitutionarray Array substitution old value => new value value * @param array $substitutionarray Array substitution old value => new value value
* @param Translate $outputlangs Output language * @param Translate $outputlangs Output language
@ -5386,13 +5460,8 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Add a substitution key for each object property
if (is_object($object))
{
// TODO
}
// Add a substitution key for each extrafields, using key __EXTRA_XXX__ // Add a substitution key for each extrafields, using key __EXTRA_XXX__
// TODO Remove this. Already available into the getCommonSubstitutionArray used to build the substitution array.
if (is_object($object) && is_array($object->array_options)) if (is_object($object) && is_array($object->array_options))
{ {
foreach($object->array_options as $key => $val) foreach($object->array_options as $key => $val)

View File

@ -75,6 +75,14 @@ function ldap_prepare_head()
$h++; $h++;
} }
if (! empty($conf->adherent->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
{
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_members_types.php";
$head[$h][1] = $langs->trans("LDAPMembersTypesSynchro");
$head[$h][2] = 'memberstypes';
$h++;
}
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // 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 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab

View File

@ -124,6 +124,16 @@ function member_type_prepare_head(AdherentType $object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
{
$langs->load("ldap");
$head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id;
$head[$h][1] = $langs->trans("LDAPCard");
$head[$h][2] = 'ldap';
$h++;
}
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // 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 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab

View File

@ -34,7 +34,7 @@
* @param string $readdir Directory source (use $destdir when not defined) * @param string $readdir Directory source (use $destdir when not defined)
* @param string $addfieldentry Array of the field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure') * @param string $addfieldentry Array of the field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure')
* @param string $delfieldentry Id of field to remove * @param string $delfieldentry Id of field to remove
* @return int <=0 if KO, >0 if OK * @return int|object <=0 if KO, Object if OK
*/ */
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array() ,$delfieldentry='') function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array() ,$delfieldentry='')
{ {
@ -43,13 +43,29 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
if (empty($objectname)) return -1; if (empty($objectname)) return -1;
if (empty($readdir)) $readdir=$destdir; if (empty($readdir)) $readdir=$destdir;
if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval']))
{
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
return -1;
}
// Check parameters // Check parameters
if (count($addfieldentry) > 0) if (count($addfieldentry) > 0)
{ {
if (empty($addfieldentry['name']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
return -2;
}
if (empty($addfieldentry['label']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
if (! preg_match('/^(integer|date|timestamp|varchar|double)/', $addfieldentry['type'])) if (! preg_match('/^(integer|date|timestamp|varchar|double)/', $addfieldentry['type']))
{ {
setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null, 'errors'); setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
return -1; return -2;
} }
} }
@ -59,7 +75,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors'); setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -1; return -3;
} }
//$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp'; //$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp';
@ -69,7 +85,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
{ {
include_once $pathoffiletoeditsrc; include_once $pathoffiletoeditsrc;
if (class_exists($objectname)) $object=new $objectname($db); if (class_exists($objectname)) $object=new $objectname($db);
else return -1; else return -4;
// Backup old file // Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1); dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
@ -84,6 +100,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
{ {
$name=$addfieldentry['name']; $name=$addfieldentry['name'];
unset($addfieldentry['name']); unset($addfieldentry['name']);
$object->fields[$name]=$addfieldentry; $object->fields[$name]=$addfieldentry;
} }
if (! empty($delfieldentry)) if (! empty($delfieldentry))
@ -104,6 +121,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
if (count($object->fields)) if (count($object->fields))
{ {
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$i++; $i++;
@ -117,11 +135,24 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
if ($val['comment']) $texttoinsert.= " 'comment'=>'".$val['comment']."',"; if ($val['comment']) $texttoinsert.= " 'comment'=>'".$val['comment']."',";
if ($val['isameasure']) $texttoinsert.= " 'isameasure'=>'".$val['isameasure']."',"; if ($val['isameasure']) $texttoinsert.= " 'isameasure'=>'".$val['isameasure']."',";
if ($val['help']) $texttoinsert.= " 'help'=>'".$val['help']."',"; if ($val['help']) $texttoinsert.= " 'help'=>'".$val['help']."',";
if ($val['arrayofkeyval'])
{
$texttoinsert.= " 'arrayofkeyval'=>array(";
$i=0;
foreach($val['arrayofkeyval'] as $key2 => $val2)
{
if ($i) $texttoinsert.=", ";
$texttoinsert.="'".$key2."'=>'".$val2."'";
$i++;
}
$texttoinsert.= ")";
}
$texttoinsert.= "),\n"; $texttoinsert.= "),\n";
} }
} }
$texttoinsert.= "\t".');'."\n"; $texttoinsert.= "\t".');'."\n";
//print ($texttoinsert);exit;
if (count($object->fields)) if (count($object->fields))
{ {
@ -152,12 +183,12 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass); file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass);
@chmod($pathoffiletoedittarget, octdec($newmask)); @chmod($pathoffiletoedittarget, octdec($newmask));
return 1; return $object;
} }
catch(Exception $e) catch(Exception $e)
{ {
print $e->getMessage(); print $e->getMessage();
return -1; return -5;
} }
} }
@ -169,12 +200,15 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
* @param string $objectname Name of object * @param string $objectname Name of object
* @param string $newmask New mask * @param string $newmask New mask
* @param string $readdir Directory source (use $destdir when not defined) * @param string $readdir Directory source (use $destdir when not defined)
* @param Object $object If object was already loaded/known, it is pass to avaoid another include and new.
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
*/ */
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='') function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $object=null)
{ {
global $db, $langs; global $db, $langs;
$error = 0;
if (empty($objectname)) return -1; if (empty($objectname)) return -1;
if (empty($readdir)) $readdir=$destdir; if (empty($readdir)) $readdir=$destdir;
@ -190,12 +224,16 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
return -1; return -1;
} }
// Load object from myobject.class.php
try try
{
if (! is_object($object))
{ {
include_once $pathoffiletoclasssrc; include_once $pathoffiletoclasssrc;
if (class_exists($objectname)) $object=new $objectname($db); if (class_exists($objectname)) $object=new $objectname($db);
else return -1; else return -1;
} }
}
catch(Exception $e) catch(Exception $e)
{ {
print $e->getMessage(); print $e->getMessage();
@ -225,9 +263,15 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql); $contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
file_put_contents($pathoffiletoedittarget, $contentsql); $result = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask)); @chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
// Edit .key.sql file // Edit .key.sql file
$pathoffiletoeditsrc=$destdir.'/sql/llx_'.strtolower($objectname).'.key.sql'; $pathoffiletoeditsrc=$destdir.'/sql/llx_'.strtolower($objectname).'.key.sql';
@ -255,10 +299,17 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
dol_mkdir(dirname($pathoffiletoedittarget)); dol_mkdir(dirname($pathoffiletoedittarget));
file_put_contents($pathoffiletoedittarget, $contentsql); $result2 = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask)); @chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
return 1; return $error ? -1 : 1;
} }

View File

@ -184,7 +184,7 @@ function dol_loginfunction($langs,$conf,$mysoc)
// Set cookie for timeout management // Set cookie for timeout management
$prefix=dol_getprefix(); $prefix=dol_getprefix();
$sessiontimeout='DOLSESSTIMEOUT_'.$prefix; $sessiontimeout='DOLSESSTIMEOUT_'.$prefix;
if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0); if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true);
if (GETPOST('urlfrom','alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom','alpha'); if (GETPOST('urlfrom','alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom','alpha');
else unset($_SESSION["urlfrom"]); else unset($_SESSION["urlfrom"]);

View File

@ -175,7 +175,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1700__+MAX_llx_menu__, 'billing', 'customer_bills', 6__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills', 'BillsCustomers', 0, 'bills', '$user->rights->facture->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1700__+MAX_llx_menu__, 'billing', 'customer_bills', 6__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills', 'BillsCustomers', 0, 'bills', '$user->rights->facture->lire', '', 2, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1701__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/card.php?action=create&amp;leftmenu=customers_bills', 'NewBill', 1, 'bills', '$user->rights->facture->creer', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1701__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/card.php?action=create&amp;leftmenu=customers_bills', 'NewBill', 1, 'bills', '$user->rights->facture->creer', '', 2, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1705__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills', 'List', 1, 'bills', '$user->rights->facture->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1705__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills', 'List', 1, 'bills', '$user->rights->facture->lire', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1702__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/fiche-rec.php?leftmenu=customers_bills', 'ListOfTemplates', 1, 'bills', '$user->rights->facture->lire', '', 2, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1702__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/invoicetemplate_list.php?leftmenu=customers_bills', 'ListOfTemplates', 1, 'bills', '$user->rights->facture->lire', '', 2, 5, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1720__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills&amp;search_status=0', 'BillShortStatusDraft', 2, 'bills', '$user->rights->facture->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1720__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills&amp;search_status=0', 'BillShortStatusDraft', 2, 'bills', '$user->rights->facture->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1721__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills&amp;search_status=1', 'BillShortStatusNotPaid', 2, 'bills', '$user->rights->facture->lire', '', 2, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1721__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills&amp;search_status=1', 'BillShortStatusNotPaid', 2, 'bills', '$user->rights->facture->lire', '', 2, 2, __ENTITY__);

View File

@ -73,6 +73,13 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m
$showmode=dol_auguria_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal); $showmode=dol_auguria_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal);
if ($showmode == 1) if ($showmode == 1)
{ {
// $menu_array[$i]['url'] can be a relative url, a full external url or a dynamic value like '$conf->global->APARAM)
if (preg_match('/^\$conf->global->([^\?]+)/', $newTabMenu[$i]['url'], $reg))
{
$keyforsconst=$reg[1];
$newTabMenu[$i]['url'] = $conf->global->$keyforsconst;
}
$url = $shorturl = $newTabMenu[$i]['url']; $url = $shorturl = $newTabMenu[$i]['url'];
if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))

View File

@ -811,7 +811,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_paid&amp;search_status=2",$langs->trans("BillShortStatusPaid"),2,$user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_paid&amp;search_status=2",$langs->trans("BillShortStatusPaid"),2,$user->rights->facture->lire);
$newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_canceled&amp;search_status=3",$langs->trans("BillShortStatusCanceled"),2,$user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_canceled&amp;search_status=3",$langs->trans("BillShortStatusCanceled"),2,$user->rights->facture->lire);
} }
$newmenu->add("/compta/facture/fiche-rec.php",$langs->trans("ListOfTemplates"),1,$user->rights->facture->creer); // No need to see recurring invoices, if user has no permission to create invoice. $newmenu->add("/compta/facture/invoicetemplate_list.php",$langs->trans("ListOfTemplates"),1,$user->rights->facture->creer); // No need to see recurring invoices, if user has no permission to create invoice.
$newmenu->add("/compta/paiement/list.php",$langs->trans("Payments"),1,$user->rights->facture->lire); $newmenu->add("/compta/paiement/list.php",$langs->trans("Payments"),1,$user->rights->facture->lire);
@ -1598,6 +1598,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
} }
} }
// $menu_array[$i]['url'] can be a relative url, a full external url or a dynamic value like '$conf->global->APARAM)
if (preg_match('/^\$conf->global->([^\?]+)/', $menu_array[$i]['url'], $reg))
{
$keyforsconst=$reg[1];
$menu_array[$i]['url'] = $conf->global->$keyforsconst;
}
$url = $shorturl = $menu_array[$i]['url']; $url = $shorturl = $menu_array[$i]['url'];
if (! preg_match("/^(http:\/\/|https:\/\/)/i",$menu_array[$i]['url'])) if (! preg_match("/^(http:\/\/|https:\/\/)/i",$menu_array[$i]['url']))

View File

@ -260,10 +260,12 @@ class modProduct extends DolibarrModules
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields');
$this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'); $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation');
if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue'));
if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice'));
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR'));
if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type'));
if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type'));
if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode'));
if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
// Add extra fields // Add extra fields
@ -300,9 +302,12 @@ class modProduct extends DolibarrModules
$this->import_fields_array[$r]=array('sp.fk_product'=>"ProductOrService*", $this->import_fields_array[$r]=array('sp.fk_product'=>"ProductOrService*",
'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate',
'sp.price'=>"PriceQtyMinHT*", 'sp.price'=>"PriceQtyMinHT*",
'sp.unitprice'=>'UnitPriceHT*', // TODO Make this file not required and calculate it from price and qty 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
'sp.remise_percent'=>'DiscountQtyMin' 'sp.remise_percent'=>'DiscountQtyMin'
); );
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'NPR'));
if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
$this->import_convertvalue_array[$r]=array( $this->import_convertvalue_array[$r]=array(
'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'),

View File

@ -73,7 +73,7 @@ if ($conf->use_javascript_ajax && 1 == 2) // select2 is ko with jmobile
{ {
if (! is_object($form)) $form=new Form($db); if (! is_object($form)) $form=new Form($db);
$selected=-1; $selected=-1;
$searchform.='<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, 'data-role="none"', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0); $searchform.='<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
} }
else else
{ {

View File

@ -73,6 +73,8 @@ if ($action == 'presend')
// Build document if it not exists // Build document if it not exists
if (! $file || ! is_readable($file)) { if (! $file || ! is_readable($file)) {
if ($object->element != 'member')
{
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) { if ($result <= 0) {
dol_print_error($db, $object->error, $object->errors); dol_print_error($db, $object->error, $object->errors);
@ -81,6 +83,7 @@ if ($action == 'presend')
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname']; $file = $fileparams['fullname'];
} }
}
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>'; print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>'; print '<div class="clearboth"></div>';
@ -120,6 +123,10 @@ if ($action == 'presend')
$liste[$key] = $value; $liste[$key] = $value;
} }
} }
elseif ($object->element == 'member')
{
$liste['thirdparty'] = $object->getFullName($langs)." &lt;".$object->email."&gt;";
}
else else
{ {
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) { foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) {
@ -139,43 +146,8 @@ if ($action == 'presend')
// Make substitution in email content // Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : ''; $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
$substitutionarray['__PERSONALIZED__'] = ''; $substitutionarray['__PERSONALIZED__'] = ''; // deprecated
$substitutionarray['__CONTACTCIVNAME__'] = ''; $substitutionarray['__CONTACTCIVNAME__'] = '';
// Add specific substitution for contracts
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
{
$datenextexpiration = '';
foreach ($object->lines as $line)
{
if ($line->statut != 4)
continue;
if ($line->date_fin_prevue > $datenextexpiration)
$datenextexpiration = $line->date_fin_prevue;
}
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
// Choose one contact for the __CONTACTCIVNAME__ TODO Really not reliable.
/*
$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_commande_external_CUSTOMER')) { // TODO Use code and not label
$contactstatic = new Contact($db);
$contactstatic->fetch($contact ['id']);
$custcontact = $contactstatic->getFullName($langs, 1);
}
}
if (! empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
}
}*/
$parameters = array( $parameters = array(
'mode' => 'formemail' 'mode' => 'formemail'

View File

@ -74,7 +74,7 @@ if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAI
$formmail->frommail = dolAddEmailTrackId($formmail->frommail, $trackid); $formmail->frommail = dolAddEmailTrackId($formmail->frommail, $trackid);
} }
$formmail->withfrom = 1; $formmail->withfrom = 1;
$liste = $langs->trans("AllRecipientSelected", count($listofselectedthirdparties)); $liste = $langs->trans("AllRecipientSelected", count($arrayofselected));
if (count($listofselectedthirdparties) == 1) // Only 1 different recipient selected, we can suggest contacts if (count($listofselectedthirdparties) == 1) // Only 1 different recipient selected, we can suggest contacts
{ {
$liste = array(); $liste = array();
@ -97,8 +97,10 @@ if (count($listofselectedthirdparties) == 1) // Only 1 different recipient selec
} else { } else {
$formmail->withtoreadonly = 1; $formmail->withtoreadonly = 1;
} }
$formmail->withto = $liste;
$formmail->withtofree = 0; $formmail->withoptiononeemailperrecipient = empty($liste)?0:((GETPOST('oneemailperrecipient')=='on')?1:-1);
$formmail->withto = empty($liste)?(GETPOST('sendto','alpha')?GETPOST('sendto','alpha'):array()):$liste;
$formmail->withtofree = empty($liste)?1:0;
$formmail->withtocc = 1; $formmail->withtocc = 1;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic = $langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); $formmail->withtopic = $langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__');
@ -117,22 +119,8 @@ $formmail->withcancel = 1;
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto; $substitutionarray['__EMAIL__'] = $sendto;
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : ''; $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
$substitutionarray['__PERSONALIZED__'] = ''; $substitutionarray['__PERSONALIZED__'] = ''; // deprecated
$substitutionarray['__CONTACTCIVNAME__'] = ''; $substitutionarray['__CONTACTCIVNAME__'] = '';
// Add specific substitution for contracts
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
{
$datenextexpiration = '';
foreach ($object->lines as $line)
{
if ($line->statut != 4)
continue;
if ($line->date_fin_prevue > $datenextexpiration)
$datenextexpiration = $line->date_fin_prevue;
}
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
$parameters = array( $parameters = array(
'mode' => 'formemail' 'mode' => 'formemail'

View File

@ -317,7 +317,7 @@ else {
<td align="right" class="nobottom margininfos linecolmargin"> <td align="right" class="nobottom margininfos linecolmargin">
<!-- For predef product --> <!-- For predef product -->
<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?> <?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
<select id="fournprice_predef" name="fournprice_predef" class="flat" data-role="none" style="display: none;"></select> <select id="fournprice_predef" name="fournprice_predef" class="flat" style="display: none;"></select>
<?php } ?> <?php } ?>
<!-- For free product --> <!-- For free product -->
<input type="text" size="5" id="buying_price" name="buying_price" class="flat right" value="<?php echo (isset($_POST["buying_price"])?GETPOST("buying_price",'alpha',2):''); ?>"> <input type="text" size="5" id="buying_price" name="buying_price" class="flat right" value="<?php echo (isset($_POST["buying_price"])?GETPOST("buying_price",'alpha',2):''); ?>">

View File

@ -179,7 +179,7 @@ $coldisplay=-1; // We remove first td
<td align="right" class="margininfos"><?php $coldisplay++; ?> <td align="right" class="margininfos"><?php $coldisplay++; ?>
<!-- For predef product --> <!-- For predef product -->
<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?> <?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
<select id="fournprice_predef" name="fournprice_predef" class="flat right" data-role="none" style="display: none;"></select> <select id="fournprice_predef" name="fournprice_predef" class="flat right" style="display: none;"></select>
<?php } ?> <?php } ?>
<!-- For free product --> <!-- For free product -->
<input class="flat right" type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>"> <input class="flat right" type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>">

View File

@ -55,7 +55,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
// Proposals to order // Proposals to order
if ($action == 'PROPAL_CLOSE_SIGNED') if ($action == 'PROPAL_CLOSE_SIGNED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER))
{ {
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
@ -74,7 +74,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
// Order to invoice // Order to invoice
if ($action == 'ORDER_CLOSE') if ($action == 'ORDER_CLOSE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_ORDER_AUTOCREATE_INVOICE)) if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_ORDER_AUTOCREATE_INVOICE))
{ {
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -90,12 +90,10 @@ class InterfaceWorkflowManager extends DolibarrTriggers
} }
} }
// Order classify billed proposal // Order classify billed proposal
if ($action == 'ORDER_CLASSIFY_BILLED') if ($action == 'ORDER_CLASSIFY_BILLED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG); dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id );
if (! empty($conf->propal->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) if (! empty($conf->propal->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL))
{ {
$object->fetchObjectLinked('','propal',$object->id,$object->element); $object->fetchObjectLinked('','propal',$object->id,$object->element);
@ -106,8 +104,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers
{ {
if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht;
} }
dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG); dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) );
if ($totalonlinkedelements == $object->total_ht) if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) )
{ {
foreach($object->linkedObjects['propal'] as $element) foreach($object->linkedObjects['propal'] as $element)
{ {
@ -119,33 +117,12 @@ class InterfaceWorkflowManager extends DolibarrTriggers
} }
} }
// classify billed order // classify billed order & billed propososal
if ($action == 'BILL_VALIDATE') if ($action == 'BILL_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG); dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id );
if (! empty($conf->propal->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL))
{
$object->fetchObjectLinked('','propal',$object->id,$object->element);
if (! empty($object->linkedObjects))
{
$totalonlinkedelements=0;
foreach($object->linkedObjects['propal'] as $element)
{
if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht;
}
dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
if ($totalonlinkedelements == $object->total_ht)
{
foreach($object->linkedObjects['propal'] as $element)
{
$ret=$element->classifyBilled($user);
}
}
}
return $ret;
}
// First classify billed the order to allow the proposal classify process
if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER))
{ {
$object->fetchObjectLinked('','commande',$object->id,$object->element); $object->fetchObjectLinked('','commande',$object->id,$object->element);
@ -156,8 +133,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers
{ {
if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht;
} }
dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG); dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) );
if ($totalonlinkedelements == $object->total_ht) if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) )
{ {
foreach($object->linkedObjects['commande'] as $element) foreach($object->linkedObjects['commande'] as $element)
{ {
@ -167,12 +144,36 @@ class InterfaceWorkflowManager extends DolibarrTriggers
} }
return $ret; return $ret;
} }
// Second classify billed the proposal.
if (! empty($conf->propal->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL))
{
$object->fetchObjectLinked('','propal',$object->id,$object->element);
if (! empty($object->linkedObjects))
{
$totalonlinkedelements=0;
foreach($object->linkedObjects['propal'] as $element)
{
if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht;
}
dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) );
if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) )
{
foreach($object->linkedObjects['propal'] as $element)
{
$ret=$element->classifyBilled($user);
}
}
}
return $ret;
}
} }
// Invoice classify billed order // Invoice classify billed order
if ($action == 'BILL_PAYED') if ($action == 'BILL_PAYED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG); dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id );
if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER)) if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER))
{ {
@ -184,8 +185,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers
{ {
if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht;
} }
dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG); dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) );
if ($totalonlinkedelements == $object->total_ht) if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) )
{ {
foreach($object->linkedObjects['commande'] as $element) foreach($object->linkedObjects['commande'] as $element)
{ {
@ -199,8 +200,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($action=='SHIPPING_VALIDATE') if ($action=='SHIPPING_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG); dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id );
if (! empty($conf->commande->enabled) && ! empty($conf->expedition->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING)) if (! empty($conf->commande->enabled) && ! empty($conf->expedition->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING))
{ {
@ -234,6 +234,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
} }
} }
} }
//Build array of quantity ordered by product //Build array of quantity ordered by product
if (is_array($order->lines) && count($order->lines)>0) { if (is_array($order->lines) && count($order->lines)>0) {
foreach($order->lines as $orderline) { foreach($order->lines as $orderline) {

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -58,6 +59,8 @@ class InterfaceLdapsynchro extends DolibarrTriggers
return 0; return 0;
} }
$result=0;
// Users // Users
if ($action == 'USER_CREATE') if ($action == 'USER_CREATE')
{ {
@ -65,17 +68,17 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->add($dn,$info,$user); $result=$ldap->add($dn,$info,$user);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'USER_MODIFY') elseif ($action == 'USER_MODIFY')
@ -84,8 +87,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
@ -108,11 +113,9 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'USER_NEW_PASSWORD') elseif ($action == 'USER_NEW_PASSWORD')
@ -121,8 +124,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
@ -145,11 +150,9 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'USER_ENABLEDISABLE') elseif ($action == 'USER_ENABLEDISABLE')
@ -162,17 +165,17 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn); $result=$ldap->delete($dn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'USER_SETINGROUP') elseif ($action == 'USER_SETINGROUP')
@ -181,8 +184,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
// Must edit $object->newgroupid // Must edit $object->newgroupid
$usergroup=new UserGroup($this->db); $usergroup=new UserGroup($this->db);
if ($object->newgroupid > 0) if ($object->newgroupid > 0)
@ -205,12 +210,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$dn=$usergroup->_load_ldap_dn($info); $dn=$usergroup->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'USER_REMOVEFROMGROUP') elseif ($action == 'USER_REMOVEFROMGROUP')
@ -219,8 +222,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
// Must edit $object->newgroupid // Must edit $object->newgroupid
$usergroup=new UserGroup($this->db); $usergroup=new UserGroup($this->db);
if ($object->oldgroupid > 0) if ($object->oldgroupid > 0)
@ -243,12 +248,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$dn=$usergroup->_load_ldap_dn($info); $dn=$usergroup->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
@ -259,21 +262,22 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
// Get a gid number for objectclass PosixGroup // Get a gid number for objectclass PosixGroup
if(in_array('posixGroup',$info['objectclass'])) if (in_array('posixGroup',$info['objectclass'])) {
$info['gidNumber'] = $ldap->getNextGroupGid(); $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
}
$result=$ldap->add($dn,$info,$user); $result=$ldap->add($dn,$info,$user);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'GROUP_MODIFY') elseif ($action == 'GROUP_MODIFY')
@ -282,8 +286,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
@ -306,11 +312,9 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'GROUP_DELETE') elseif ($action == 'GROUP_DELETE')
@ -319,17 +323,17 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn); $result=$ldap->delete($dn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
@ -340,17 +344,17 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_CONTACT_ACTIVE)) if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->add($dn,$info,$user); $result=$ldap->add($dn,$info,$user);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'CONTACT_MODIFY') elseif ($action == 'CONTACT_MODIFY')
@ -359,8 +363,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_CONTACT_ACTIVE)) if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
@ -383,11 +389,9 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'CONTACT_DELETE') elseif ($action == 'CONTACT_DELETE')
@ -396,17 +400,17 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_CONTACT_ACTIVE)) if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn); $result=$ldap->delete($dn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
@ -417,17 +421,45 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->add($dn,$info,$user); $result=$ldap->add($dn,$info,$user);
if ($result < 0)
// For member type
if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
{ {
$this->error="ErrorLDAP ".$ldap->error; $membertype=new AdherentType($this->db);
if ($object->typeid > 0)
{
$membertype->fetch($object->typeid);
$membertype->listMembersForMemberType();
$oldinfo=$membertype->_load_ldap_info();
$olddn=$membertype->_load_ldap_dn($oldinfo);
// Verify if entry exist
$container=$membertype->_load_ldap_dn($oldinfo,1);
$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
$records=$ldap->search($container,$search);
if (count($records) && $records['count'] == 0)
{
$olddn = '';
} }
return $result;
$info=$membertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
$dn=$membertype->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn);
}
}
}
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'MEMBER_VALIDATE') elseif ($action == 'MEMBER_VALIDATE')
@ -439,18 +471,18 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$olddn=$dn; // We know olddn=dn as we change only status $olddn=$dn; // We know olddn=dn as we change only status
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
} }
@ -467,18 +499,18 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|| $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION) || $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$olddn=$dn; // We know olddn=dn as we change only subscriptions $olddn=$dn; // We know olddn=dn as we change only subscriptions
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
} }
@ -488,8 +520,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
@ -512,11 +546,64 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
// For member type
if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
{ {
$this->error="ErrorLDAP ".$ldap->error; /*
* Change member info
*/
$newmembertype=new AdherentType($this->db);
$newmembertype->fetch($object->typeid);
$newmembertype->listMembersForMemberType();
$oldinfo=$newmembertype->_load_ldap_info();
$olddn=$newmembertype->_load_ldap_dn($oldinfo);
// Verify if entry exist
$container=$newmembertype->_load_ldap_dn($oldinfo,1);
$search = "(".$newmembertype->_load_ldap_dn($oldinfo,2).")";
$records=$ldap->search($container,$search);
if (count($records) && $records['count'] == 0)
{
$olddn = '';
} }
return $result;
$info=$newmembertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
$dn=$newmembertype->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn);
if ($object->oldcopy->typeid != $object->typeid)
{
/*
* Remove member in old member type
*/
$oldmembertype=new AdherentType($this->db);
$oldmembertype->fetch($object->oldcopy->typeid);
$oldmembertype->listMembersForMemberType();
$oldinfo=$oldmembertype->_load_ldap_info();
$olddn=$oldmembertype->_load_ldap_dn($oldinfo);
// Verify if entry exist
$container=$oldmembertype->_load_ldap_dn($oldinfo,1);
$search = "(".$oldmembertype->_load_ldap_dn($oldinfo,2).")";
$records=$ldap->search($container,$search);
if (count($records) && $records['count'] == 0)
{
$olddn = '';
}
$info=$oldmembertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
$dn=$oldmembertype->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn);
}
}
}
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
elseif ($action == 'MEMBER_NEW_PASSWORD') elseif ($action == 'MEMBER_NEW_PASSWORD')
@ -528,18 +615,18 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED)
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$olddn=$dn; // We know olddn=dn as we change only password $olddn=$dn; // We know olddn=dn as we change only password
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
} }
@ -552,18 +639,18 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$olddn=$dn; // We know olddn=dn as we change only status $olddn=$dn; // We know olddn=dn as we change only status
$result=$ldap->update($dn,$info,$user,$olddn); $result=$ldap->update($dn,$info,$user,$olddn);
if ($result < 0)
{
$this->error="ErrorLDAP ".$ldap->error;
} }
return $result;
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
} }
} }
} }
@ -573,29 +660,138 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{ {
$ldap=new Ldap(); $ldap=new Ldap();
$ldap->connect_bind(); $result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info(); $info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn); $result=$ldap->delete($dn);
if ($result < 0)
// For member type
if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
{ {
$this->error="ErrorLDAP ".$ldap->error; if ($object->typeid > 0)
{
/*
* Remove member in member type
*/
$membertype=new AdherentType($this->db);
$membertype->fetch($object->typeid);
$membertype->listMembersForMemberType('a.rowid != ' . $object->id); // remove deleted member from the list
$oldinfo=$membertype->_load_ldap_info();
$olddn=$membertype->_load_ldap_dn($oldinfo);
// Verify if entry exist
$container=$membertype->_load_ldap_dn($oldinfo,1);
$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
$records=$ldap->search($container,$search);
if (count($records) && $records['count'] == 0)
{
$olddn = '';
}
$info=$membertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
$dn=$membertype->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn);
} }
return $result;
} }
} }
// If not found if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
/*
else
{
dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action.");
return -1;
} }
*/ }
return 0;
// Members types
elseif ($action == 'MEMBER_TYPE_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
{
$ldap=new Ldap();
$result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
// Get a gid number for objectclass PosixGroup
if (in_array('posixGroup',$info['objectclass'])) {
$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPE');
}
$result=$ldap->add($dn,$info,$user);
}
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
}
}
elseif ($action == 'MEMBER_TYPE_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
{
$ldap=new Ldap();
$result=$ldap->connect_bind();
if ($result > 0)
{
if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
$object->oldcopy = clone $object;
}
$object->oldcopy->listMembersForMemberType();
$oldinfo=$object->oldcopy->_load_ldap_info();
$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
// Verify if entry exist
$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
$records=$ldap->search($container,$search);
if (count($records) && $records['count'] == 0)
{
$olddn = '';
}
$object->listMembersForMemberType();
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user,$olddn);
}
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
}
}
elseif ($action == 'MEMBER_TYPE_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
{
$ldap=new Ldap();
$result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn);
}
if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
}
}
return $result;
} }
} }

View File

@ -148,7 +148,7 @@ if ($action=='add')
$object->params=GETPOST('params'); $object->params=GETPOST('params');
$object->md5params=GETPOST('md5params'); $object->md5params=GETPOST('md5params');
$object->module_name=GETPOST('module_name','alpha'); $object->module_name=GETPOST('module_name','alpha');
$object->note=GETPOST('note'); $object->note=GETPOST('note','none');
$object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int'));
$object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int'));
$object->datenextrun=dol_mktime(GETPOST('datenextrunhour','int'), GETPOST('datenextrunmin','int'), 0, GETPOST('datenextrunmonth','int'), GETPOST('datenextrunday','int'), GETPOST('datenextrunyear','int')); $object->datenextrun=dol_mktime(GETPOST('datenextrunhour','int'), GETPOST('datenextrunmin','int'), 0, GETPOST('datenextrunmonth','int'), GETPOST('datenextrunday','int'), GETPOST('datenextrunyear','int'));
@ -184,7 +184,7 @@ if ($action=='update')
$object->params=GETPOST('params'); $object->params=GETPOST('params');
$object->md5params=GETPOST('md5params'); $object->md5params=GETPOST('md5params');
$object->module_name=GETPOST('module_name','alpha'); $object->module_name=GETPOST('module_name','alpha');
$object->note=GETPOST('note'); $object->note=GETPOST('note','none');
$object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int'));
$object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int'));
$object->datenextrun=dol_mktime(GETPOST('datenextrunhour','int'), GETPOST('datenextrunmin','int'), 0, GETPOST('datenextrunmonth','int'), GETPOST('datenextrunday','int'), GETPOST('datenextrunyear','int')); $object->datenextrun=dol_mktime(GETPOST('datenextrunhour','int'), GETPOST('datenextrunmin','int'), 0, GETPOST('datenextrunmonth','int'), GETPOST('datenextrunday','int'), GETPOST('datenextrunyear','int'));

View File

@ -219,8 +219,8 @@ if (empty($reshook))
$object->shipping_method_id = GETPOST('shipping_method_id','int'); $object->shipping_method_id = GETPOST('shipping_method_id','int');
$object->tracking_number = GETPOST('tracking_number','alpha'); $object->tracking_number = GETPOST('tracking_number','alpha');
$object->ref_int = GETPOST('ref_int','alpha'); $object->ref_int = GETPOST('ref_int','alpha');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@ -781,6 +781,12 @@ if ($action == 'create')
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) { if (empty($reshook) && ! empty($extrafields->attribute_label)) {
// copy from order
$orderExtrafields = new Extrafields($db);
$orderExtrafieldLabels = $orderExtrafields->fetch_name_optionals_label($object->table_element);
if ($object->fetch_optionals($object->id, $orderExtrafieldLabels) > 0) {
$expe->array_options = array_merge($expe->array_options, $object->array_options);
}
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
@ -1304,8 +1310,13 @@ if ($action == 'create')
if (is_array($extralabelslines) && count($extralabelslines)>0) if (is_array($extralabelslines) && count($extralabelslines)>0)
{ {
$colspan=5; $colspan=5;
$orderLineExtrafields = new Extrafields($db);
$orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line);
$srcLine = new OrderLine($db);
$srcLine->fetch_optionals($line->id,$orderLineExtrafieldLabels); // fetch extrafields also available in orderline
$line = new ExpeditionLigne($db); $line = new ExpeditionLigne($db);
$line->fetch_optionals($object->id,$extralabelslines); $line->fetch_optionals($object->id,$extralabelslines);
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
print '</tr>'; print '</tr>';

View File

@ -213,8 +213,8 @@ if (empty($reshook))
$object->fk_statut = 1; $object->fk_statut = 1;
$object->fk_c_paiement = GETPOST('fk_c_paiement','int'); $object->fk_c_paiement = GETPOST('fk_c_paiement','int');
$object->fk_user_validator = GETPOST('fk_user_validator','int'); $object->fk_user_validator = GETPOST('fk_user_validator','int');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
if (! $error) if (! $error)
{ {
@ -264,8 +264,8 @@ if (empty($reshook))
} }
$object->fk_c_paiement = GETPOST('fk_c_paiement','int'); $object->fk_c_paiement = GETPOST('fk_c_paiement','int');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->fk_user_modif = $user->id; $object->fk_user_modif = $user->id;
$result = $object->update($user); $result = $object->update($user);

View File

@ -64,7 +64,7 @@ $confirm = GETPOST('confirm','alpha');
$mesg = GETPOST('msg','alpha'); $mesg = GETPOST('msg','alpha');
$origin=GETPOST('origin','alpha'); $origin=GETPOST('origin','alpha');
$originid=(GETPOST('originid','int')?GETPOST('originid','int'):GETPOST('origin_id','int')); // For backward compatibility $originid=(GETPOST('originid','int')?GETPOST('originid','int'):GETPOST('origin_id','int')); // For backward compatibility
$note_public = GETPOST('note_public'); $note_public = GETPOST('note_public','none');
$lineid = GETPOST('line_id','int'); $lineid = GETPOST('line_id','int');
//PDF //PDF
@ -208,8 +208,8 @@ if (empty($reshook))
$object->description = GETPOST('description'); $object->description = GETPOST('description');
$object->ref = $ref; $object->ref = $ref;
$object->modelpdf = GETPOST('model','alpha'); $object->modelpdf = GETPOST('model','alpha');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
if ($object->socid > 0) if ($object->socid > 0)
{ {
@ -877,8 +877,8 @@ if ($action == 'create')
$soc = $objectsrc->client; $soc = $objectsrc->client;
$note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private'))); $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private','none')));
$note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public')); $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public','none'));
// Object source contacts list // Object source contacts list
$srccontactslist = $objectsrc->liste_contact(-1,'external',1); $srccontactslist = $objectsrc->liste_contact(-1,'external',1);

View File

@ -279,11 +279,12 @@ class CommandeFournisseur extends CommonOrder
$this->fetchObjectLinked(); $this->fetchObjectLinked();
//$result=$this->fetch_lines();
$this->lines=array(); $this->lines=array();
$sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description, l.qty,"; $sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description, l.qty,";
$sql.= " l.vat_src_code, l.tva_tx, l.remise_percent, l.subprice,"; $sql.= " l.vat_src_code, l.tva_tx, l.remise_percent, l.subprice,";
$sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,"; $sql.= " l.localtax1_tx, l. localtax2_tx, l.localtax1_type, l. localtax2_type, l.total_localtax1, l.total_localtax2,";
$sql.= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,"; $sql.= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,";
$sql.= " l.fk_unit,"; $sql.= " l.fk_unit,";
@ -315,6 +316,8 @@ class CommandeFournisseur extends CommonOrder
$line->tva_tx = $objp->tva_tx; $line->tva_tx = $objp->tva_tx;
$line->localtax1_tx = $objp->localtax1_tx; $line->localtax1_tx = $objp->localtax1_tx;
$line->localtax2_tx = $objp->localtax2_tx; $line->localtax2_tx = $objp->localtax2_tx;
$line->localtax1_type = $objp->localtax1_type;
$line->localtax2_type = $objp->localtax2_type;
$line->subprice = $objp->subprice; $line->subprice = $objp->subprice;
$line->pu_ht = $objp->subprice; $line->pu_ht = $objp->subprice;
$line->remise_percent = $objp->remise_percent; $line->remise_percent = $objp->remise_percent;
@ -2977,7 +2980,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
public function fetch($rowid) public function fetch($rowid)
{ {
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx,'; $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx,';
$sql.= ' cd.localtax1_tx, cd.localtax2_tx, cd.ref,'; $sql.= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref,';
$sql.= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql.= ' cd.remise, cd.remise_percent, cd.subprice,';
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
$sql.= ' cd.total_localtax1, cd.total_localtax2,'; $sql.= ' cd.total_localtax1, cd.total_localtax2,';
@ -3003,6 +3006,8 @@ class CommandeFournisseurLigne extends CommonOrderLine
$this->tva_tx = $objp->tva_tx; $this->tva_tx = $objp->tva_tx;
$this->localtax1_tx = $objp->localtax1_tx; $this->localtax1_tx = $objp->localtax1_tx;
$this->localtax2_tx = $objp->localtax2_tx; $this->localtax2_tx = $objp->localtax2_tx;
$this->localtax1_type = $objp->localtax1_type;
$this->localtax2_type = $objp->localtax2_type;
$this->remise = $objp->remise; $this->remise = $objp->remise;
$this->remise_percent = $objp->remise_percent; $this->remise_percent = $objp->remise_percent;
$this->fk_product = $objp->fk_product; $this->fk_product = $objp->fk_product;

View File

@ -640,7 +640,7 @@ class FactureFournisseur extends CommonInvoice
function fetch_lines() function fetch_lines()
{ {
$sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx'; $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx';
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn '; $sql.= ', f.localtax1_tx, f.localtax2_tx, f.localtax1_type, f.localtax2_type, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn ';
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit'; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
$sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; $sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc';
@ -681,6 +681,8 @@ class FactureFournisseur extends CommonInvoice
$line->tva_tx = $obj->tva_tx; $line->tva_tx = $obj->tva_tx;
$line->localtax1_tx = $obj->localtax1_tx; $line->localtax1_tx = $obj->localtax1_tx;
$line->localtax2_tx = $obj->localtax2_tx; $line->localtax2_tx = $obj->localtax2_tx;
$line->localtax1_type = $obj->localtax1_type;
$line->localtax2_type = $obj->localtax2_type;
$line->qty = $obj->qty; $line->qty = $obj->qty;
$line->remise_percent = $obj->remise_percent; $line->remise_percent = $obj->remise_percent;
$line->tva = $obj->total_tva; $line->tva = $obj->total_tva;

View File

@ -180,16 +180,18 @@ class ProductFournisseur extends Product
* @param Societe $fourn Supplier * @param Societe $fourn Supplier
* @param int $availability Product availability * @param int $availability Product availability
* @param string $ref_fourn Supplier ref * @param string $ref_fourn Supplier ref
* @param float $tva_tx VAT rate * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string)
* @param string $charges costs affering to product * @param string $charges costs affering to product
* @param float $remise_percent Discount regarding qty (percent) * @param float $remise_percent Discount regarding qty (percent)
* @param float $remise Discount regarding qty (amount) * @param float $remise Discount regarding qty (amount)
* @param int $newnpr Set NPR or not * @param int $newnpr Set NPR or not
* @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined.
* @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER)
* @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
* @param string $newdefaultvatcode Default vat code
* @return int <0 if KO, >=0 if OK * @return int <0 if KO, >=0 if OK
*/ */
function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0, $delivery_time_days=0, $supplier_reputation='') function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0, $delivery_time_days=0, $supplier_reputation='', $localtaxes_array=array(), $newdefaultvatcode='')
{ {
global $conf, $langs; global $conf, $langs;
//global $mysoc; //global $mysoc;
@ -217,6 +219,25 @@ class ProductFournisseur extends Product
$now=dol_now(); $now=dol_now();
$newvat = $tva_tx;
if (count($localtaxes_array) > 0)
{
$localtaxtype1=$localtaxes_array['0'];
$localtax1=$localtaxes_array['1'];
$localtaxtype2=$localtaxes_array['2'];
$localtax2=$localtaxes_array['3'];
}
else // old method. deprecated because ot can't retreive type
{
$localtaxtype1='0';
$localtax1=get_localtax($newvat,1);
$localtaxtype2='0';
$localtax2=get_localtax($newvat,2);
}
if (empty($localtax1)) $localtax1=0; // If = '' then = 0
if (empty($localtax2)) $localtax2=0; // If = '' then = 0
$this->db->begin(); $this->db->begin();
if ($this->product_fourn_price_id > 0) if ($this->product_fourn_price_id > 0)
@ -230,9 +251,15 @@ class ProductFournisseur extends Product
$sql.= " remise = ".$remise.","; $sql.= " remise = ".$remise.",";
$sql.= " unitprice = ".$unitBuyPrice.","; $sql.= " unitprice = ".$unitBuyPrice.",";
$sql.= " unitcharges = ".$unitCharges.","; // deprecated $sql.= " unitcharges = ".$unitCharges.","; // deprecated
$sql.= " tva_tx = ".$tva_tx.",";
$sql.= " fk_availability = ".$availability.","; $sql.= " fk_availability = ".$availability.",";
$sql.= " entity = ".$conf->entity.","; $sql.= " entity = ".$conf->entity.",";
$sql.= " tva_tx = ".price2num($tva_tx).",";
// TODO Add localtax1 and localtax2
//$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').",";
//$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').",";
//$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$localtaxtype1."'":"'0'").",";
//$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$localtaxtype2."'":"'0'").",";
$sql.= " default_vat_code=".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").",";
$sql.= " info_bits = ".$newnpr.","; $sql.= " info_bits = ".$newnpr.",";
$sql.= " charges = ".$charges.","; // deprecated $sql.= " charges = ".$charges.","; // deprecated
$sql.= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; $sql.= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').",";
@ -279,7 +306,7 @@ class ProductFournisseur extends Product
if ($resql) { if ($resql) {
// Add price for this quantity to supplier // Add price for this quantity to supplier
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price("; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price(";
$sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, info_bits, entity, delivery_time_days,supplier_reputation)"; $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)";
$sql .= " values('" . $this->db->idate($now) . "',"; $sql .= " values('" . $this->db->idate($now) . "',";
$sql .= " " . $this->id . ","; $sql .= " " . $this->id . ",";
$sql .= " " . $fourn->id . ","; $sql .= " " . $fourn->id . ",";
@ -294,6 +321,7 @@ class ProductFournisseur extends Product
$sql .= " " . $charges . ","; $sql .= " " . $charges . ",";
$sql .= " " . $unitCharges . ","; $sql .= " " . $unitCharges . ",";
$sql .= " " . $availability . ","; $sql .= " " . $availability . ",";
$sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").",";
$sql .= " " . $newnpr . ","; $sql .= " " . $newnpr . ",";
$sql .= $conf->entity . ","; $sql .= $conf->entity . ",";
$sql .= $delivery_time_days . ","; $sql .= $delivery_time_days . ",";
@ -364,9 +392,9 @@ class ProductFournisseur extends Product
function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) function fetch_product_fournisseur_price($rowid, $ignore_expression = 0)
{ {
global $conf; global $conf;
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability,"; $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.fk_availability,";
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price
$sql.=" pfp.supplier_reputation"; $sql.= " pfp.supplier_reputation";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.rowid = ".$rowid; $sql.= " WHERE pfp.rowid = ".$rowid;
@ -392,11 +420,14 @@ class ProductFournisseur extends Product
$this->fourn_unitprice = $obj->unitprice; $this->fourn_unitprice = $obj->unitprice;
$this->fourn_unitcharges = $obj->unitcharges; // deprecated $this->fourn_unitcharges = $obj->unitcharges; // deprecated
$this->fourn_tva_tx = $obj->tva_tx; $this->fourn_tva_tx = $obj->tva_tx;
//$this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ? // TODO
// $this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ?
// Add also localtaxes
$this->fk_availability = $obj->fk_availability; $this->fk_availability = $obj->fk_availability;
$this->delivery_time_days = $obj->delivery_time_days; $this->delivery_time_days = $obj->delivery_time_days;
$this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression;
$this->supplier_reputation = $obj->supplier_reputation; $this->supplier_reputation = $obj->supplier_reputation;
$this->default_vat_code = $obj->default_vat_code;
if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression))
{ {

View File

@ -417,7 +417,7 @@ if (empty($reshook))
$localtax1_tx, $localtax1_tx,
$localtax2_tx, $localtax2_tx,
$idprod, $idprod,
$productsupplier->id, $productsupplier->product_fourn_price_id,
$productsupplier->fourn_ref, $productsupplier->fourn_ref,
$remise_percent, $remise_percent,
'HT', 'HT',
@ -552,19 +552,7 @@ if (empty($reshook))
*/ */
if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && ! GETPOST('cancel','alpha')) if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && ! GETPOST('cancel','alpha'))
{ {
$tva_tx = GETPOST('tva_tx'); $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0);
if (GETPOST('price_ht') != '')
{
$price_base_type = 'HT';
$ht = price2num(GETPOST('price_ht'));
}
else
{
$ttc = price2num(GETPOST('price_ttc'));
$ht = $ttc / (1 + ($tva_tx / 100));
$price_base_type = 'HT';
}
if ($lineid) if ($lineid)
{ {
@ -576,8 +564,34 @@ if (empty($reshook))
$date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$localtax1_tx=get_localtax($tva_tx,1,$mysoc,$object->thirdparty); // Define info_bits
$localtax2_tx=get_localtax($tva_tx,2,$mysoc,$object->thirdparty); $info_bits = 0;
if (preg_match('/\*/', $vat_rate))
$info_bits |= 0x01;
// Define vat_rate
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty);
$localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty);
if (GETPOST('price_ht') != '')
{
$price_base_type = 'HT';
$ht = price2num(GETPOST('price_ht'));
}
else
{
$vatratecleaned = $vat_rate;
if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)"
{
$vatratecleaned = trim($reg[1]);
$vatratecode = $reg[2];
}
$ttc = price2num(GETPOST('price_ttc'));
$ht = $ttc / (1 + ($vatratecleaned / 100));
$price_base_type = 'HT';
}
$pu_ht_devise = GETPOST('multicurrency_subprice'); $pu_ht_devise = GETPOST('multicurrency_subprice');
@ -598,9 +612,9 @@ if (empty($reshook))
$ht, $ht,
$_POST['qty'], $_POST['qty'],
$_POST['remise_percent'], $_POST['remise_percent'],
$tva_tx, $vat_rate,
$localtax1_tx, $localtax1_rate,
$localtax2_tx, $localtax2_rate,
$price_base_type, $price_base_type,
0, 0,
isset($_POST["type"])?$_POST["type"]:$line->product_type, isset($_POST["type"])?$_POST["type"]:$line->product_type,
@ -988,8 +1002,8 @@ if (empty($reshook))
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->date_livraison = $datelivraison; $object->date_livraison = $datelivraison;
$object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@ -1534,7 +1548,7 @@ if ($action=='create')
print '<tr><td>'.$langs->trans('NotePublic').'</td>'; print '<tr><td>'.$langs->trans('NotePublic').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public','none'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td>'; print '</td>';
//print '<textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea>'; //print '<textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea>';
@ -1542,7 +1556,7 @@ if ($action=='create')
print '<tr><td>'.$langs->trans('NotePrivate').'</td>'; print '<tr><td>'.$langs->trans('NotePrivate').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private','none'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td>'; print '</td>';
//print '<td><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>'; //print '<td><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>';

View File

@ -155,8 +155,8 @@ if (($action == 'create' || $action == 'add') && ! $error) {
$object->libelle = GETPOST('libelle'); $object->libelle = GETPOST('libelle');
$object->date = $datefacture; $object->date = $datefacture;
$object->date_echeance = $datedue; $object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$projectid = GETPOST('projectid'); $projectid = GETPOST('projectid');

View File

@ -328,7 +328,7 @@ if (empty($reshook))
// Multicurrency rate // Multicurrency rate
else if ($action == 'setmulticurrencyrate' && $user->rights->facture->creer) { else if ($action == 'setmulticurrencyrate' && $user->rights->facture->creer) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx', 'alpha')));
} }
// bank account // bank account
@ -443,8 +443,8 @@ if (empty($reshook))
$object->libelle = GETPOST('label'); $object->libelle = GETPOST('label');
$object->date = $datefacture; $object->date = $datefacture;
$object->date_echeance = $datedue; $object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
@ -507,8 +507,8 @@ if (empty($reshook))
$object->libelle = $_POST['label']; $object->libelle = $_POST['label'];
$object->date = $datefacture; $object->date = $datefacture;
$object->date_echeance = $datedue; $object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
@ -616,8 +616,8 @@ if (empty($reshook))
$object->libelle = $_POST['label']; $object->libelle = $_POST['label'];
$object->date = $datefacture; $object->date = $datefacture;
$object->date_echeance = $datedue; $object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public','none');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private','none');
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
@ -1683,8 +1683,8 @@ if ($action == 'create')
print $desc; print $desc;
print '<div id="credit_note_options" class="clearboth">'; print '<div id="credit_note_options" class="clearboth">';
print '&nbsp;&nbsp;&nbsp; <input data-role="none" type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>"; print '&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '<br>&nbsp;&nbsp;&nbsp; <input data-role="none" type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>"; print '<br>&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
print '</div>'; print '</div>';
print '</div></div>'; print '</div></div>';

View File

@ -57,7 +57,7 @@ if ($action == 'setnote' && $user->rights->fournisseur->facture->creer)
$db->begin(); $db->begin();
$object->fetch($id); $object->fetch($id);
$result = $object->update_note(GETPOST('note')); $result = $object->update_note(GETPOST('note','none'));
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();

View File

@ -41,6 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
$myparam = GETPOST("myparam"); $myparam = GETPOST("myparam");
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$id=GETPOST('id', 'int'); $id=GETPOST('id', 'int');
$fuserid = (GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id);
// Protection if external user // Protection if external user
if ($user->societe_id > 0) accessforbidden(); if ($user->societe_id > 0) accessforbidden();

View File

@ -73,6 +73,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping',20); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping',20);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping',21); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping',21);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_VALIDATE','Member validated','Executed when a member is validated','member',22); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_VALIDATE','Member validated','Executed when a member is validated','member',22);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SENTBYMAIL','Mails sent from member card','Executed when you send email from member card','member',23);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION','Member subscribed','Executed when a member is subscribed','member',24); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION','Member subscribed','Executed when a member is subscribed','member',24);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_RESILIATE','Member resiliated','Executed when a member is resiliated','member',25); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_RESILIATE','Member resiliated','Executed when a member is resiliated','member',25);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_DELETE','Member deleted','Executed when a member is deleted','member',26); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_DELETE','Member deleted','Executed when a member is deleted','member',26);

View File

@ -0,0 +1,23 @@
-- Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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/>.
--
--
--
-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors
-- de l'install et tous les sigles '--' sont supprimés.
--
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(ThisIsContentOfYourCard)__<br />\n__(ID)__ : __ID__<br />\n__(Civiliyty)__ : __MEMBER_CIVILITY__<br />\n__(Firstname)__ : __MEMBER_FIRSTNAME__<br />\n__(Lastname)__ : __MEMBER_LASTNAME__<br />\n__(Fullname)__ : __MEMBER_FULLNAME__<br />\n__(Company)__ : __MEMBER_COMPANY__<br />\n__(Address)__ : __MEMBER_ADDRESS__<br />\n__(Zip)__ : __MEMBER_ZIP__<br />\n__(Town)__ : __MEMBER_TOWN__<br />\n__(Country)__ : __MEMBER_COUNTRY__<br />\n__(Email)__ : __MEMBER_EMAIL__<br />\n__(Birthday)__ : __MEMBER_BIRTH__<br />\n__(Photo)__ : __MEMBER_PHOTO__<br />\n__(Login)__ : __MEMBER_LOGIN__<br />\n__(Password)__ : __MEMBER_PASSWORD__<br />\n__(Phone)__ : __MEMBER_PHONE__<br />\n__(PhonePerso)__ : __MEMBER_PHONEPRO__<br />\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null);

View File

@ -88,6 +88,8 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 9
-- CYPRUS (id country=78) -- CYPRUS (id country=78)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (781, 78, '19','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (781, 78, '19','0','VAT standard rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (782, 78, '9','0','VAT Rate 9',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (783, 78, '5','0','VAT Rate 5',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (784, 78, '0','0','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (784, 78, '0','0','VAT Rate 0',1);
-- DANMERK (id country=80) -- DANMERK (id country=80)
@ -138,8 +140,14 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (11
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1173, 117, '1','0','VAT super-reduced rate',0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1173, 117, '1','0','VAT super-reduced rate',0);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1174, 117, '0','0','VAT Rate 0', 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1174, 117, '0','0','VAT Rate 0', 0);
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'CGST+SGST', 0, 9, '1', 9, '1', 0, 'CGST+SGST - Same state sales', 1); insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1178, 117, 'C+S-5', 0, 2.5, '1', 2.5, '1', 0, 'CGST+SGST - Same state sales', 1);
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'IGST' , 18, 0, '0', 0, '0', 0, 'IGST', 1); insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1179, 117, 'I-5' , 5, 0, '0', 0, '0', 0, 'IGST', 1);
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1180, 117, 'C+S-12', 0, 6, '1', 6, '1', 0, 'CGST+SGST - Same state sales', 1);
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1181, 117, 'I-12' , 12, 0, '0', 0, '0', 0, 'IGST', 1);
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'C+S-18', 0, 9, '1', 9, '1', 0, 'CGST+SGST - Same state sales', 1);
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'I-18' , 18, 0, '0', 0, '0', 0, 'IGST', 1);
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1182, 117, 'C+S-28', 0, 14, '1', 14, '1', 0, 'CGST+SGST - Same state sales', 1);
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1183, 117, 'I-28' , 28, 0, '0', 0, '0', 0, 'IGST', 1);
-- IRELAND (id country=8) -- IRELAND (id country=8)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (81, 8, '0','0','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (81, 8, '0','0','VAT Rate 0',1);

View File

@ -4,6 +4,7 @@
-- when current version is 5.0.0 or higher. -- when current version is 5.0.0 or higher.
-- --
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; -- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
-- -- VPGSQL8.2 ALTER SEQUENCE IF EXISTS llx_table_rowid_seq RENAME TO llx_table_new_rowid_seq;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; -- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); -- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; -- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
@ -121,6 +122,8 @@ create table llx_expensereport_extrafields
ALTER TABLE llx_expensereport_extrafields ADD INDEX idx_expensereport_extrafields (fk_object); ALTER TABLE llx_expensereport_extrafields ADD INDEX idx_expensereport_extrafields (fk_object);
ALTER TABLE llx_cotisation RENAME TO llx_subscription; ALTER TABLE llx_cotisation RENAME TO llx_subscription;
-- VPGSQL8.2 ALTER SEQUENCE IF EXISTS llx_cotisation_rowid_seq RENAME TO llx_subscription_rowid_seq;
ALTER TABLE llx_subscription ADD UNIQUE INDEX uk_subscription (fk_adherent,dateadh); ALTER TABLE llx_subscription ADD UNIQUE INDEX uk_subscription (fk_adherent,dateadh);
ALTER TABLE llx_subscription CHANGE COLUMN cotisation subscription real; ALTER TABLE llx_subscription CHANGE COLUMN cotisation subscription real;
ALTER TABLE llx_adherent_type CHANGE COLUMN cotisation subscription varchar(3) NOT NULL DEFAULT '1'; ALTER TABLE llx_adherent_type CHANGE COLUMN cotisation subscription varchar(3) NOT NULL DEFAULT '1';

View File

@ -338,6 +338,7 @@ UPDATE llx_const SET value = __ENCRYPT('moono-lisa')__ WHERE value = __ENCRYPT
DELETE FROM llx_document_model where nom = 'fsfe.fr.php' and type='donation'; DELETE FROM llx_document_model where nom = 'fsfe.fr.php' and type='donation';
ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) AFTER tva_tx; ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) AFTER tva_tx;
ALTER TABLE llx_product_customer_price ADD COLUMN default_vat_code varchar(10) AFTER tva_tx;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) AFTER tva_tx; ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) AFTER tva_tx;
ALTER TABLE llx_user ADD COLUMN model_pdf varchar(255); ALTER TABLE llx_user ADD COLUMN model_pdf varchar(255);

View File

@ -41,6 +41,13 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;
-- For 7.0 -- For 7.0
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_tx double(6,3) DEFAULT 0;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0';
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax2_tx double(6,3) DEFAULT 0;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0';
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SENTBYMAIL','Mails sent from member card','Executed when you send email from member card','member',23);
ALTER TABLE llx_ecm_files MODIFY label varchar(128) NOT NULL; ALTER TABLE llx_ecm_files MODIFY label varchar(128) NOT NULL;
ALTER TABLE llx_ecm_files ADD COLUMN share varchar(128) NULL after label; ALTER TABLE llx_ecm_files ADD COLUMN share varchar(128) NULL after label;
@ -64,6 +71,8 @@ ALTER TABLE llx_contrat MODIFY COLUMN ref_ext varchar(50);
UPDATE llx_c_email_templates SET position = 0 WHERE position IS NULL; UPDATE llx_c_email_templates SET position = 0 WHERE position IS NULL;
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(ThisIsContentOfYourCard)__<br />\n__(ID)__ : __ID__<br />\n__(Civiliyty)__ : __MEMBER_CIVILITY__<br />\n__(Firstname)__ : __MEMBER_FIRSTNAME__<br />\n__(Lastname)__ : __MEMBER_LASTNAME__<br />\n__(Fullname)__ : __MEMBER_FULLNAME__<br />\n__(Company)__ : __MEMBER_COMPANY__<br />\n__(Address)__ : __MEMBER_ADDRESS__<br />\n__(Zip)__ : __MEMBER_ZIP__<br />\n__(Town)__ : __MEMBER_TOWN__<br />\n__(Country)__ : __MEMBER_COUNTRY__<br />\n__(Email)__ : __MEMBER_EMAIL__<br />\n__(Birthday)__ : __MEMBER_BIRTH__<br />\n__(Photo)__ : __MEMBER_PHOTO__<br />\n__(Login)__ : __MEMBER_LOGIN__<br />\n__(Password)__ : __MEMBER_PASSWORD__<br />\n__(Phone)__ : __MEMBER_PHONE__<br />\n__(PhonePerso)__ : __MEMBER_PHONEPRO__<br />\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null);
INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VENTES', 'Income of products/services', 'Exemple: 7xxxxx', 0, 0, '', '10', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VENTES', 'Income of products/services', 'Exemple: 7xxxxx', 0, 0, '', '10', 1, 1);
INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'DEPENSES', 'Expenses of products/services', 'Exemple: 6xxxxx', 0, 0, '', '20', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'DEPENSES', 'Expenses of products/services', 'Exemple: 6xxxxx', 0, 0, '', '20', 1, 1);
INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 3, 'PROFIT', 'Balance', '', 0, 1, 'VENTES+DEPENSES', '30', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 3, 'PROFIT', 'Balance', '', 0, 1, 'VENTES+DEPENSES', '30', 1, 1);

View File

@ -38,6 +38,10 @@ create table llx_product_fournisseur_price
unitcharges double(24,8) DEFAULT 0, -- deprecated unitcharges double(24,8) DEFAULT 0, -- deprecated
default_vat_code varchar(10), default_vat_code varchar(10),
tva_tx double(6,3) NOT NULL, tva_tx double(6,3) NOT NULL,
localtax1_tx double(6,3) DEFAULT 0,
localtax1_type varchar(10) NOT NULL DEFAULT '0',
localtax2_tx double(6,3) DEFAULT 0,
localtax2_type varchar(10) NOT NULL DEFAULT '0',
info_bits integer NOT NULL DEFAULT 0, info_bits integer NOT NULL DEFAULT 0,
fk_user integer, fk_user integer,
fk_supplier_price_expression integer, -- Link to the rule for dynamic price calculation fk_supplier_price_expression integer, -- Link to the rule for dynamic price calculation

View File

@ -1253,6 +1253,7 @@ LDAPUsersSynchro=Users
LDAPGroupsSynchro=Groups LDAPGroupsSynchro=Groups
LDAPContactsSynchro=Contacts LDAPContactsSynchro=Contacts
LDAPMembersSynchro=Members LDAPMembersSynchro=Members
LDAPMembersTypesSynchro=Members types
LDAPSynchronization=LDAP synchronisation LDAPSynchronization=LDAP synchronisation
LDAPFunctionsNotAvailableOnPHP=LDAP functions are not available on your PHP LDAPFunctionsNotAvailableOnPHP=LDAP functions are not available on your PHP
LDAPToDolibarr=LDAP -> Dolibarr LDAPToDolibarr=LDAP -> Dolibarr
@ -1262,6 +1263,7 @@ LDAPSynchronizeUsers=Organization of users in LDAP
LDAPSynchronizeGroups=Organization of groups in LDAP LDAPSynchronizeGroups=Organization of groups in LDAP
LDAPSynchronizeContacts=Organization of contacts in LDAP LDAPSynchronizeContacts=Organization of contacts in LDAP
LDAPSynchronizeMembers=Organization of foundation's members in LDAP LDAPSynchronizeMembers=Organization of foundation's members in LDAP
LDAPSynchronizeMembersTypes=Organization of foundation's members types in LDAP
LDAPPrimaryServer=Primary server LDAPPrimaryServer=Primary server
LDAPSecondaryServer=Secondary server LDAPSecondaryServer=Secondary server
LDAPServerPort=Server port LDAPServerPort=Server port
@ -1285,12 +1287,18 @@ LDAPDnContactActive=Contacts' synchronization
LDAPDnContactActiveExample=Activated/Unactivated synchronization LDAPDnContactActiveExample=Activated/Unactivated synchronization
LDAPDnMemberActive=Members' synchronization LDAPDnMemberActive=Members' synchronization
LDAPDnMemberActiveExample=Activated/Unactivated synchronization LDAPDnMemberActiveExample=Activated/Unactivated synchronization
LDAPDnMemberTypeActive=Members types' synchronization
LDAPDnMemberTypeActiveExample=Activated/Unactivated synchronization
LDAPContactDn=Dolibarr contacts' DN LDAPContactDn=Dolibarr contacts' DN
LDAPContactDnExample=Complete DN (ex: ou=contacts,dc=example,dc=com) LDAPContactDnExample=Complete DN (ex: ou=contacts,dc=example,dc=com)
LDAPMemberDn=Dolibarr members DN LDAPMemberDn=Dolibarr members DN
LDAPMemberDnExample=Complete DN (ex: ou=members,dc=example,dc=com) LDAPMemberDnExample=Complete DN (ex: ou=members,dc=example,dc=com)
LDAPMemberObjectClassList=List of objectClass LDAPMemberObjectClassList=List of objectClass
LDAPMemberObjectClassListExample=List of objectClass defining record attributes (ex: top,inetOrgPerson or top,user for active directory) LDAPMemberObjectClassListExample=List of objectClass defining record attributes (ex: top,inetOrgPerson or top,user for active directory)
LDAPMemberTypeDn=Dolibarr members types DN
LDAPMemberTypepDnExample=Complete DN (ex: ou=memberstypes,dc=example,dc=com)
LDAPMemberTypeObjectClassList=List of objectClass
LDAPMemberTypeObjectClassListExample=List of objectClass defining record attributes (ex: top,groupOfUniqueNames)
LDAPUserObjectClassList=List of objectClass LDAPUserObjectClassList=List of objectClass
LDAPUserObjectClassListExample=List of objectClass defining record attributes (ex: top,inetOrgPerson or top,user for active directory) LDAPUserObjectClassListExample=List of objectClass defining record attributes (ex: top,inetOrgPerson or top,user for active directory)
LDAPGroupObjectClassList=List of objectClass LDAPGroupObjectClassList=List of objectClass
@ -1302,6 +1310,7 @@ LDAPTestSynchroContact=Test contacts synchronization
LDAPTestSynchroUser=Test user synchronization LDAPTestSynchroUser=Test user synchronization
LDAPTestSynchroGroup=Test group synchronization LDAPTestSynchroGroup=Test group synchronization
LDAPTestSynchroMember=Test member synchronization LDAPTestSynchroMember=Test member synchronization
LDAPTestSynchroMemberType=Test member type synchronization
LDAPTestSearch= Test a LDAP search LDAPTestSearch= Test a LDAP search
LDAPSynchroOK=Synchronization test successful LDAPSynchroOK=Synchronization test successful
LDAPSynchroKO=Failed synchronization test LDAPSynchroKO=Failed synchronization test
@ -1367,6 +1376,7 @@ LDAPDescContact=This page allows you to define LDAP attributes name in LDAP tree
LDAPDescUsers=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr users. LDAPDescUsers=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr users.
LDAPDescGroups=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr groups. LDAPDescGroups=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr groups.
LDAPDescMembers=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr members module. LDAPDescMembers=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr members module.
LDAPDescMembersTypes=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr members types.
LDAPDescValues=Example values are designed for <b>OpenLDAP</b> with following loaded schemas: <b>core.schema, cosine.schema, inetorgperson.schema</b>). If you use thoose values and OpenLDAP, modify your LDAP config file <b>slapd.conf</b> to have all thoose schemas loaded. LDAPDescValues=Example values are designed for <b>OpenLDAP</b> with following loaded schemas: <b>core.schema, cosine.schema, inetorgperson.schema</b>). If you use thoose values and OpenLDAP, modify your LDAP config file <b>slapd.conf</b> to have all thoose schemas loaded.
ForANonAnonymousAccess=For an authenticated access (for a write access for example) ForANonAnonymousAccess=For an authenticated access (for a write access for example)
PerfDolibarr=Performance setup/optimizing report PerfDolibarr=Performance setup/optimizing report
@ -1390,7 +1400,7 @@ CompressionOfResources=Compression of HTTP responses
CompressionOfResourcesDesc=For exemple using the Apache directive "AddOutputFilterByType DEFLATE" CompressionOfResourcesDesc=For exemple using the Apache directive "AddOutputFilterByType DEFLATE"
TestNotPossibleWithCurrentBrowsers=Such an automatic detection is not possible with current browsers TestNotPossibleWithCurrentBrowsers=Such an automatic detection is not possible with current browsers
DefaultValuesDesc=You can define/force here the default value you want to get when your create a new record, and/or defaut filters or sort order when your list record. DefaultValuesDesc=You can define/force here the default value you want to get when your create a new record, and/or defaut filters or sort order when your list record.
DefaultCreateForm=Default values for new objects DefaultCreateForm=Default values for creation form
DefaultSearchFilters=Default search filters DefaultSearchFilters=Default search filters
DefaultSortOrder=Default sort orders DefaultSortOrder=Default sort orders
DefaultFocus=Default focus fields DefaultFocus=Default focus fields
@ -1694,6 +1704,7 @@ MailToSendSupplierOrder=To send supplier order
MailToSendSupplierInvoice=To send supplier invoice MailToSendSupplierInvoice=To send supplier invoice
MailToSendContract=To send a contract MailToSendContract=To send a contract
MailToThirdparty=To send email from third party page MailToThirdparty=To send email from third party page
MailToMember=To send email from member page
ByDefaultInList=Show by default on list view ByDefaultInList=Show by default on list view
YouUseLastStableVersion=You use the latest stable version YouUseLastStableVersion=You use the latest stable version
TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites) TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites)

View File

@ -149,7 +149,7 @@ ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice t
BillFrom=From BillFrom=From
BillTo=To BillTo=To
ActionsOnBill=Actions on invoice ActionsOnBill=Actions on invoice
RecurringInvoiceTemplate=Template/Recurring invoice RecurringInvoiceTemplate=Template / Recurring invoice
NoQualifiedRecurringInvoiceTemplateFound=No recurring template invoice qualified for generation. NoQualifiedRecurringInvoiceTemplateFound=No recurring template invoice qualified for generation.
FoundXQualifiedRecurringInvoiceTemplate=Found %s recurring template invoice(s) qualified for generation. FoundXQualifiedRecurringInvoiceTemplate=Found %s recurring template invoice(s) qualified for generation.
NotARecurringInvoiceTemplate=Not a recurring template invoice NotARecurringInvoiceTemplate=Not a recurring template invoice
@ -331,6 +331,7 @@ ListOfNextSituationInvoices=List of next situation invoices
FrequencyPer_d=Every %s days FrequencyPer_d=Every %s days
FrequencyPer_m=Every %s months FrequencyPer_m=Every %s months
FrequencyPer_y=Every %s years FrequencyPer_y=Every %s years
FrequencyUnit=Frequency unit
toolTipFrequency=Examples:<br><b>Set 7, Day</b>: give a new invoice every 7 days<br><b>Set 3, Month</b>: give a new invoice every 3 month toolTipFrequency=Examples:<br><b>Set 7, Day</b>: give a new invoice every 7 days<br><b>Set 3, Month</b>: give a new invoice every 3 month
NextDateToExecution=Date for next invoice generation NextDateToExecution=Date for next invoice generation
DateLastGeneration=Date of latest generation DateLastGeneration=Date of latest generation

View File

@ -104,6 +104,7 @@ ErrorForbidden2=Permission for this login can be defined by your Dolibarr admini
ErrorForbidden3=It seems that Dolibarr is not used through an authenticated session. Take a look at Dolibarr setup documentation to know how to manage authentications (htaccess, mod_auth or other...). ErrorForbidden3=It seems that Dolibarr is not used through an authenticated session. Take a look at Dolibarr setup documentation to know how to manage authentications (htaccess, mod_auth or other...).
ErrorNoImagickReadimage=Class Imagick is not found in this PHP. No preview can be available. Administrators can disable this tab from menu Setup - Display. ErrorNoImagickReadimage=Class Imagick is not found in this PHP. No preview can be available. Administrators can disable this tab from menu Setup - Display.
ErrorRecordAlreadyExists=Record already exists ErrorRecordAlreadyExists=Record already exists
ErrorLabelAlreadyExists=This label already exists
ErrorCantReadFile=Failed to read file '%s' ErrorCantReadFile=Failed to read file '%s'
ErrorCantReadDir=Failed to read directory '%s' ErrorCantReadDir=Failed to read directory '%s'
ErrorBadLoginPassword=Bad value for login or password ErrorBadLoginPassword=Bad value for login or password
@ -157,7 +158,7 @@ ErrorPriceExpression22=Negative result '%s'
ErrorPriceExpressionInternal=Internal error '%s' ErrorPriceExpressionInternal=Internal error '%s'
ErrorPriceExpressionUnknown=Unknown error '%s' ErrorPriceExpressionUnknown=Unknown error '%s'
ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs
ErrorTryToMakeMoveOnProductRequiringBatchData=Error, trying to make a stock movement without lot/serial information, on a product requiring lot/serial information ErrorTryToMakeMoveOnProductRequiringBatchData=Error, trying to make a stock movement without lot/serial information, on product '%s' requiring lot/serial information
ErrorCantSetReceptionToTotalDoneWithReceptionToApprove=All recorded receptions must first be verified (approved or denied) before being allowed to do this action ErrorCantSetReceptionToTotalDoneWithReceptionToApprove=All recorded receptions must first be verified (approved or denied) before being allowed to do this action
ErrorCantSetReceptionToTotalDoneWithReceptionDenied=All recorded receptions must first be verified (approved) before being allowed to do this action ErrorCantSetReceptionToTotalDoneWithReceptionDenied=All recorded receptions must first be verified (approved) before being allowed to do this action
ErrorGlobalVariableUpdater0=HTTP request failed with error '%s' ErrorGlobalVariableUpdater0=HTTP request failed with error '%s'

View File

@ -6,6 +6,7 @@ LDAPInformationsForThisContact=Information in LDAP database for this contact
LDAPInformationsForThisUser=Information in LDAP database for this user LDAPInformationsForThisUser=Information in LDAP database for this user
LDAPInformationsForThisGroup=Information in LDAP database for this group LDAPInformationsForThisGroup=Information in LDAP database for this group
LDAPInformationsForThisMember=Information in LDAP database for this member LDAPInformationsForThisMember=Information in LDAP database for this member
LDAPInformationsForThisMemberType=Information in LDAP database for this member type
LDAPAttributes=LDAP attributes LDAPAttributes=LDAP attributes
LDAPCard=LDAP card LDAPCard=LDAP card
LDAPRecordNotFound=Record not found in LDAP database LDAPRecordNotFound=Record not found in LDAP database
@ -20,6 +21,7 @@ LDAPFieldSkypeExample=Example : skypeName
UserSynchronized=User synchronized UserSynchronized=User synchronized
GroupSynchronized=Group synchronized GroupSynchronized=Group synchronized
MemberSynchronized=Member synchronized MemberSynchronized=Member synchronized
MemberTypeSynchronized=Member type synchronized
ContactSynchronized=Contact synchronized ContactSynchronized=Contact synchronized
ForceSynchronize=Force synchronizing Dolibarr -> LDAP ForceSynchronize=Force synchronizing Dolibarr -> LDAP
ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility. ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility.

View File

@ -70,7 +70,10 @@ EMailSentToNRecipients=EMail sent to %s recipients.
EMailSentForNElements=EMail sent for %s elements. EMailSentForNElements=EMail sent for %s elements.
XTargetsAdded=<b>%s</b> recipients added into target list XTargetsAdded=<b>%s</b> recipients added into target list
OnlyPDFattachmentSupported=If the PDF documents were already generated for the objects to send, they will be attached to email. If not, no email will be sent (also, note that only pdf documents are supported as attachment in mass sending in this version). OnlyPDFattachmentSupported=If the PDF documents were already generated for the objects to send, they will be attached to email. If not, no email will be sent (also, note that only pdf documents are supported as attachment in mass sending in this version).
AllRecipientSelected=The %s unique recipients selected (1 email per recipient), and if an email is set. AllRecipientSelected=The recipients of the %s record selected (if their email is known).
GroupEmails=Group emails
OneEmailPerRecipient=One email per recipient (by default, one email per record selected)
WarningIfYouCheckOneRecipientPerEmail=Warning, if you check this box, it means only one email will be sent for several different record selected, so, if your message contains substitution variables that refers to data of a record, it becomes not possible to replace them.
ResultOfMailSending=Result of mass EMail sending ResultOfMailSending=Result of mass EMail sending
NbSelected=Nb selected NbSelected=Nb selected
NbIgnored=Nb ignored NbIgnored=Nb ignored
@ -159,5 +162,5 @@ OutGoingEmailSetup=Outgoing email setup
InGoingEmailSetup=Incoming email setup InGoingEmailSetup=Incoming email setup
OutGoingEmailSetupForEmailing=Outgoing email setup (for mass emailing) OutGoingEmailSetupForEmailing=Outgoing email setup (for mass emailing)
DefaultOutgoingEmailSetup=Default outgoing email setup DefaultOutgoingEmailSetup=Default outgoing email setup
Information=Information

View File

@ -376,12 +376,15 @@ VATIN=IGST
VATs=Sales taxes VATs=Sales taxes
VATINs=IGST taxes VATINs=IGST taxes
LT1=Sales tax 2 LT1=Sales tax 2
LT1Type=Sales tax 2 type
LT2=Sales tax 3 LT2=Sales tax 3
LT2Type=Sales tax 3 type
LT1ES=RE LT1ES=RE
LT2ES=IRPF LT2ES=IRPF
LT1IN=CGST LT1IN=CGST
LT2IN=SGST LT2IN=SGST
VATRate=Tax Rate VATRate=Tax Rate
DefaultTaxRate=Default tax rate
Average=Average Average=Average
Sum=Sum Sum=Sum
Delta=Delta Delta=Delta

Some files were not shown because too many files have changed in this diff Show More