\n";
if (!$i) {
$totalarray['nbfield']++;
@@ -515,7 +534,7 @@ if ($resql) {
// Account label to show (label short)
if (!empty($arrayfields['aa.labelshort']['checked'])) {
print "
\n";
if (!$i) {
$totalarray['nbfield']++;
@@ -549,10 +568,30 @@ if ($resql) {
}
}
- // Chart of accounts type
+ // Predefined group (deprecated)
if (!empty($arrayfields['aa.pcg_type']['checked'])) {
print "
';
- print $formaccounting->select_account($object->account_parent, 'account_parent', 1);
+ // Note: We accept disabled account as parent account so we can build a hierarchy and use only childs
+ print $formaccounting->select_account($object->account_parent, 'account_parent', 1, array(), 0, 0, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1, '');
print '
';
// Chart of accounts type
@@ -358,7 +359,7 @@ if ($action == 'create') {
print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc"));
print '';
print '
';
@@ -541,7 +555,7 @@ print "\n";
print '';
-if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report that should rely on result of this step ?
+if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This part of code looks strange. Why showing a report that should rely on result of this step ?
print ' ';
print ' ';
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index 25368f30c61..ea9841d2fbb 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -558,6 +558,10 @@ if ($result) {
print '
';
+ return $return;
+ }
}
diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php
index 6ab65697745..4a3db45ba03 100644
--- a/htdocs/adherents/class/adherent_type.class.php
+++ b/htdocs/adherents/class/adherent_type.class.php
@@ -129,6 +129,19 @@ class AdherentType extends CommonObject
/** @var string string other */
public $other = array();
+ /**
+ * @var string description
+ */
+ public $description;
+
+ /**
+ * @var string email
+ */
+ public $email;
+
+ /**
+ * @var array multilangs
+ */
public $multilangs = array();
@@ -472,7 +485,7 @@ class AdherentType extends CommonObject
}
/**
- * Function that retrieves the status of the member
+ * Function that retrieves the properties of a membership type
*
* @param int $rowid Id of member type to load
* @return int <0 if KO, >0 if OK
@@ -626,7 +639,7 @@ class AdherentType extends CommonObject
$sql .= ' AND ('.$excludefilter.')';
}
- dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
+ dol_syslog(get_class($this)."::listMembersForMemberType", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
@@ -927,4 +940,47 @@ class AdherentType extends CommonObject
return '';
}
+
+
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
+ * @param array $arraydata Array of data
+ * @return string HTML Code for Kanban thumb.
+ */
+ public function getKanbanView($option = '', $arraydata = null)
+ {
+ global $langs,$user;
+ $return = '
';
}
+
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@@ -819,38 +871,45 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
$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['d.datec']['checked'])) {
print '
';
print '
';
}
+
// Birthday
if (!empty($arrayfields['d.birth']['checked'])) {
print '
';
print '
';
}
+
// Date modification
if (!empty($arrayfields['d.tms']['checked'])) {
print '
';
print '
';
}
+
// Status
if (!empty($arrayfields['d.statut']['checked'])) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
- }
- print '';
+ if ($mode == 'kanban') {
+ if ($i == 0) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
- } else {
- if (!empty($obj->subscription)) {
- print ''.$langs->trans("SubscriptionNotReceived").'';
- if ($obj->statut > 0) {
- print " ".img_warning();
+ print '
';
+ }
+ // Technical ID
+ if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
+ print '
';
+ }
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (!empty($arrayfields['d.datec']['checked'])) {
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Birth
+ if (!empty($arrayfields['d.birth']['checked'])) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
'."\n";
+ print ''."\n";
+ }
$i++;
}
diff --git a/htdocs/adherents/partnership.php b/htdocs/adherents/partnership.php
index 805a3137226..3664187b34e 100644
--- a/htdocs/adherents/partnership.php
+++ b/htdocs/adherents/partnership.php
@@ -76,13 +76,13 @@ foreach ($object->fields as $key => $val) {
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
-$permissiontoread = $user->rights->partnership->read;
-$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
-$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php
-$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
+$permissiontoread = $user->hasRight('partnership', 'read');
+$permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissiontodelete = $user->hasRight('partnership', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
+$permissionnote = $user->hasRight('partnership', 'write'); // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $user->hasRight('partnership', 'write'); // Used by the include of actions_dellink.inc.php
+$usercanclose = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') {
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index 93b57a630e1..8c423d53029 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -151,9 +151,9 @@ if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'ye
}
}
-if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) {
+if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->hasRight('user', 'user', 'creer'))) {
$error = 0;
- if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only
+ if (!$user->hasRight('user', 'user', 'creer')) { // If can edit only itself user, we can link to itself only
if (GETPOST("userid", 'int') != $user->id && GETPOST("userid", 'int') != $object->user_id) {
$error++;
setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors');
@@ -201,7 +201,7 @@ if (empty($reshook) && $action == 'setsocid') {
}
}
-if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !$cancel) {
+if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscription' && !$cancel) {
$error = 0;
$langs->load("banks");
@@ -674,7 +674,7 @@ if ($rowid > 0) {
*/
// Button to create a new subscription if member no draft (-1) neither resiliated (0) neither excluded (-2)
- if ($user->rights->adherent->cotisation->creer) {
+ if ($user->hasRight('adherent', 'cotisation', 'creer')) {
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
print '
';
@@ -814,7 +814,7 @@ if ($rowid > 0) {
/*
* Add new subscription form
*/
- if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) {
+ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->hasRight('adherent', 'cotisation', 'creer')) {
print ' ';
print load_fiche_titre($langs->trans("NewCotisation"));
@@ -1142,7 +1142,7 @@ if ($rowid > 0) {
$tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>';
$helpcontent = '';
- $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.' '."\n";
+ $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').' '."\n";
$helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.' '."\n";
$helpcontent .= ''.$langs->trans("MailTopic").': '."\n";
if ($subjecttosend) {
diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php
index 83f1a01441c..ea47ffc9362 100644
--- a/htdocs/adherents/subscription/card.php
+++ b/htdocs/adherents/subscription/card.php
@@ -49,13 +49,13 @@ $note = GETPOST('note', 'alpha');
$typeid = (int) GETPOST('typeid', 'int');
$amount = price2num(GETPOST('amount', 'alpha'), 'MT');
-if (empty($user->rights->adherent->cotisation->lire)) {
+if (!$user->hasRight('adherent', 'cotisation', 'lire')) {
accessforbidden();
}
-$permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php
-$permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php
+$permissionnote = $user->hasRight('adherent', 'cotisation', 'creer'); // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $user->hasRight('adherent', 'cotisation', 'creer'); // Used by the include of actions_dellink.inc.php
+$permissiontoedit = $user->hasRight('adherent', 'cotisation', 'creer'); // Used by the include of actions_lineupdonw.inc.php
$hookmanager->initHooks(array('subscriptioncard', 'globalcard'));
@@ -78,7 +78,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, n
//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
-if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cancel) {
+if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'update' && !$cancel) {
// Load current object
$result = $object->fetch($rowid);
if ($result > 0) {
@@ -109,8 +109,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance
$object->dateh = dol_mktime(GETPOST('datesubhour', 'int'), GETPOST('datesubmin', 'int'), 0, GETPOST('datesubmonth', 'int'), GETPOST('datesubday', 'int'), GETPOST('datesubyear', 'int'));
$object->datef = dol_mktime(GETPOST('datesubendhour', 'int'), GETPOST('datesubendmin', 'int'), 0, GETPOST('datesubendmonth', 'int'), GETPOST('datesubendday', 'int'), GETPOST('datesubendyear', 'int'));
$object->fk_type = $typeid;
- $object->note = $note;
+ $object->note_public = $note;
$object->note_private = $note;
+
$object->amount = $amount;
$result = $object->update($user);
@@ -140,7 +141,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance
}
}
-if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer) {
+if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('adherent', 'cotisation', 'creer')) {
$result = $object->fetch($rowid);
$result = $object->delete($user);
if ($result > 0) {
@@ -166,7 +167,7 @@ llxHeader('', $langs->trans("SubscriptionCard"), $help_url);
dol_htmloutput_errors($errmsg);
-if ($user->rights->adherent->cotisation->creer && $action == 'edit') {
+if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'edit') {
/********************************************
*
* Subscription card in edit mode
@@ -350,7 +351,7 @@ if ($rowid && $action != 'edit') {
*/
print '
';
- if ($user->rights->adherent->cotisation->creer) {
+ if ($user->hasRight('adherent', 'cotisation', 'creer')) {
if (!empty($bankline->rappro)) {
print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->crowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- // Date creation
- if (!empty($arrayfields['c.datec']['checked'])) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->crowid, $arrayofselected)) {
- $selected = 1;
- }
- print '';
- }
- print '
';
- }
- print "";
$i++;
}
diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php
index 9539250cb44..85b346b4225 100644
--- a/htdocs/adherents/type_translation.php
+++ b/htdocs/adherents/type_translation.php
@@ -71,7 +71,7 @@ if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) {
}
// Add translation
-if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) {
+if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->hasRight('adherent', 'configurer')) {
$object = new AdherentType($db);
$object->fetch($id);
$current_lang = $langs->getDefaultLang();
@@ -99,7 +99,7 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->ad
}
// Edit translation
-if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) {
+if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->hasRight('adherent', 'configurer')) {
$object = new AdherentType($db);
$object->fetch($id);
$current_lang = $langs->getDefaultLang();
@@ -125,7 +125,7 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->a
}
// Delete translation
-if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) {
+if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->hasRight('adherent', 'configurer')) {
$object = new AdherentType($db);
$object->fetch($id);
$langtodelete = GETPOST('langdel', 'alpha');
diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php
index 1b5a0e5d0fe..618f2d50ffa 100644
--- a/htdocs/adherents/vcard.php
+++ b/htdocs/adherents/vcard.php
@@ -42,14 +42,14 @@ if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref);
// Define variables to know what current user can do on users
- $canadduser = ($user->admin || $user->rights->user->user->creer);
+ $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer'));
// Define variables to know what current user can do on properties of user linked to edited member
if ($object->user_id) {
// $User is the user who edits, $object->user_id is the id of the related user in the edited member
- $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
- || (($user->id != $object->user_id) && $user->rights->user->user->creer));
- $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
- || (($user->id != $object->user_id) && $user->rights->user->user->password));
+ $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer'))
+ || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer')));
+ $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password'))
+ || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password')));
}
}
@@ -122,18 +122,23 @@ if ($company->id) {
} elseif (empty(trim($object->email))) {
// when adherent e-mail is empty, use only company e-mail
$v->setEmail($company->email);
- } elseif (strtolower(end(explode("@", $object->email))) == strtolower(end(explode("@", $company->email)))) {
- // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second)
- $v->setEmail($object->email);
-
- // support by Microsoft Outlook (2019 and possible earlier)
- $v->setEmail($company->email, 'INTERNET');
} else {
- // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second)
- $v->setEmail($company->email);
+ $tmpobject = explode("@", trim($object->email));
+ $tmpcompany = explode("@", trim($company->email));
- // support by Microsoft Outlook (2019 and possible earlier)
- $v->setEmail($object->email, 'INTERNET');
+ if (strtolower(end($tmpobject)) == strtolower(end($tmpcompany))) {
+ // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second)
+ $v->setEmail($object->email);
+
+ // support by Microsoft Outlook (2019 and possible earlier)
+ $v->setEmail($company->email, 'INTERNET');
+ } else {
+ // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second)
+ $v->setEmail($company->email);
+
+ // support by Microsoft Outlook (2019 and possible earlier)
+ $v->setEmail($object->email, 'INTERNET');
+ }
}
// Si adherent lie a un tiers non de type "particulier"
diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php
index 7b057a0693c..aef46db26ef 100644
--- a/htdocs/admin/agenda_other.php
+++ b/htdocs/admin/agenda_other.php
@@ -54,6 +54,9 @@ $type = 'action';
* Actions
*/
+$error = 0;
+$errors = array();
+
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
$reg = array();
@@ -193,10 +196,9 @@ print dol_get_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action');
/*
- * Documents models for supplier orders
+ * Miscellaneous
*/
-
// Define array def of models
$def = array();
@@ -308,8 +310,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
}
}
print '
';
@@ -306,7 +355,7 @@ if (count($listinsetup) > 0) {
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
print '
';
print '
'.$langs->trans("URLOfServiceForAuthorization").'
';
- print '
';
+ print '
';
print '
';
print '
';
print '
';
diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php
index f798995d525..9a0532880cd 100644
--- a/htdocs/admin/oauthlogintokens.php
+++ b/htdocs/admin/oauthlogintokens.php
@@ -213,7 +213,13 @@ if ($mode == 'setup' && $user->admin) {
$urltocheckperms = '';
}
- $urltorenew .= '&keyforprovider='.urlencode($keyforprovider);
+ if ($urltorenew) {
+ $urltorenew .= '&keyforprovider='.urlencode($keyforprovider);
+ }
+ if ($urltodelete) {
+ $urltodelete .= '&keyforprovider='.urlencode($keyforprovider);
+ }
+
// Show value of token
$tokenobj = null;
diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php
index 59da712b266..7b0d0acbf06 100644
--- a/htdocs/admin/payment.php
+++ b/htdocs/admin/payment.php
@@ -51,9 +51,9 @@ if (empty($conf->global->PAYMENT_ADDON)) {
*/
if ($action == 'updateMask') {
- $maskconstpayment = GETPOST('maskconstpayment', 'alpha');
+ $maskconstpayment = GETPOST('maskconstpayment', 'aZ09');
$maskpayment = GETPOST('maskpayment', 'alpha');
- if ($maskconstpayment) {
+ if ($maskconstpayment && preg_match('/_MASK$/', $maskconstpayment)) {
$res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity);
}
diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php
index ef20ab6e205..42c766d1a22 100644
--- a/htdocs/admin/perms.php
+++ b/htdocs/admin/perms.php
@@ -227,7 +227,7 @@ if ($result) {
// Tick
if ($obj->bydefault == 1) {
print '
';
- print '';
+ print '';
//print img_edit_remove();
print img_picto('', 'switch_on');
print '';
diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php
index 7883cc7da20..10044e33b5b 100644
--- a/htdocs/admin/propal.php
+++ b/htdocs/admin/propal.php
@@ -58,9 +58,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
$error = 0;
if ($action == 'updateMask') {
- $maskconstpropal = GETPOST('maskconstpropal', 'alpha');
+ $maskconstpropal = GETPOST('maskconstpropal', 'aZ09');
$maskpropal = GETPOST('maskpropal', 'alpha');
- if ($maskconstpropal) {
+ if ($maskconstpropal && preg_match('/_MASK$/', $maskconstpropal)) {
$res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity);
}
diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php
index c86db66e464..32f6c5b226e 100644
--- a/htdocs/admin/reception_setup.php
+++ b/htdocs/admin/reception_setup.php
@@ -65,9 +65,9 @@ if (empty($conf->global->RECEPTION_ADDON_NUMBER)) {
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') {
- $maskconst = GETPOST('maskconstreception', 'alpha');
+ $maskconst = GETPOST('maskconstreception', 'aZ09');
$maskvalue = GETPOST('maskreception', 'alpha');
- if (!empty($maskconst)) {
+ if (!empty($maskconst) && preg_match('/_MASK$/', $maskconst)) {
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
}
diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php
index 33344363cf7..e30e50769bb 100644
--- a/htdocs/admin/security.php
+++ b/htdocs/admin/security.php
@@ -56,8 +56,8 @@ if ($action == 'activate_encrypt') {
$db->begin();
- // On old version a bug created the constant into user entity, so we delete it to be sure, such entry won't exists. We want it in entity 0 or nowhere.
- dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity);
+ // On old version, a bug created the constant into user entity, so we delete it to be sure such entry won't exists. We want it in entity 0 or nowhere.
+ dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity);
// We set entity=0 (all) because DATABASE_PWD_ENCRYPTED is a setup into conf file, so always shared for everybody
$entityforall = 0;
dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $entityforall);
diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php
index 1d73f5238ad..7a7e49a3129 100644
--- a/htdocs/admin/stock.php
+++ b/htdocs/admin/stock.php
@@ -247,7 +247,7 @@ if (isModEnabled('commande')) {
print "
';
}
diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php
index f885677225e..541682101c6 100644
--- a/htdocs/api/class/api_access.class.php
+++ b/htdocs/api/class/api_access.class.php
@@ -1,6 +1,7 @@
* Copyright (C) 2016 Laurent Destailleur
+ * Copyright (C) 2023 Ferran Marcet
*
* 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
@@ -142,12 +143,38 @@ class DolibarrApiAccess implements iAuthenticate
if (!$login) {
throw new RestException(503, 'Error when searching login user from api key');
}
+
+
+ $genericmessageerroruser = 'Error user not valid (not found or bad status or bad validity dates) (conf->entity='.$conf->entity.')';
+
$fuser = new User($this->db);
$result = $fuser->fetch('', $login, '', 0, (empty($userentity) ? -1 : $conf->entity)); // If user is not entity 0, we search in working entity $conf->entity (that may have been forced to a different value than user entity)
if ($result <= 0) {
- throw new RestException(503, 'Error when fetching user :'.$fuser->error.' (conf->entity='.$conf->entity.')');
+ throw new RestException(503, $genericmessageerroruser);
}
+ // Check if user status is enabled
+ if ($fuser->statut != $fuser::STATUS_ENABLED) {
+ // Status is disabled
+ dol_syslog("The user has been disabled");
+ throw new RestException(503, $genericmessageerroruser);
+ }
+
+ // Check if session was unvalidated by a password change
+ if (($fuser->flagdelsessionsbefore && !empty($_SESSION["dol_logindate"]) && $fuser->flagdelsessionsbefore > $_SESSION["dol_logindate"])) {
+ // Session is no more valid
+ dol_syslog("The user has a date for session invalidation = ".$fuser->flagdelsessionsbefore." and a session date = ".$_SESSION["dol_logindate"].". We must invalidate its sessions.");
+ throw new RestException(503, $genericmessageerroruser);
+ }
+
+ // Check date validity
+ if ($fuser->isNotIntoValidityDateRange()) {
+ // User validity dates are no more valid
+ dol_syslog("The user login has a validity between [".$fuser->datestartvalidity." and ".$fuser->dateendvalidity."], curren date is ".dol_now());
+ throw new RestException(503, $genericmessageerroruser);
+ }
+
+ // User seems valid
$fuser->getrights();
// Set the property $user to the $user of API
diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php
index d5362f4ac56..0b8d3e64828 100644
--- a/htdocs/api/class/api_login.class.php
+++ b/htdocs/api/class/api_login.class.php
@@ -121,6 +121,9 @@ class Login
include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$login = checkLoginPassEntity($login, $password, $entity, $authmode, 'api'); // Check credentials.
+ if ($login === '--bad-login-validity--') {
+ $login = '';
+ }
if (empty($login)) {
throw new RestException(403, 'Access denied');
}
diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php
index 9dcd168f344..17649370ae0 100644
--- a/htdocs/api/class/api_setup.class.php
+++ b/htdocs/api/class/api_setup.class.php
@@ -319,8 +319,8 @@ class Setup extends DolibarrApi
/**
* Get state by ID.
*
- * @param int $id ID of state
- * @return array Array of cleaned object properties
+ * @param int $id ID of state
+ * @return Object Object with cleaned properties
*
* @url GET dictionary/states/{id}
*
@@ -334,8 +334,8 @@ class Setup extends DolibarrApi
/**
* Get state by Code.
*
- * @param string $code Code of state
- * @return array Array of cleaned object properties
+ * @param string $code Code of state
+ * @return Object Object with cleaned properties
*
* @url GET dictionary/states/byCode/{code}
*
@@ -424,10 +424,9 @@ class Setup extends DolibarrApi
/**
* Get country by ID.
*
- * @param int $id ID of country
- * @param string $lang Code of the language the name of the
- * country must be translated to
- * @return array Array of cleaned object properties
+ * @param int $id ID of country
+ * @param string $lang Code of the language the name of the country must be translated to
+ * @return Object Object with cleaned properties
*
* @url GET dictionary/countries/{id}
*
@@ -441,10 +440,9 @@ class Setup extends DolibarrApi
/**
* Get country by Code.
*
- * @param string $code Code of country (2 characters)
- * @param string $lang Code of the language the name of the
- * country must be translated to
- * @return array Array of cleaned object properties
+ * @param string $code Code of country (2 characters)
+ * @param string $lang Code of the language the name of the country must be translated to
+ * @return Object Object with cleaned properties
*
* @url GET dictionary/countries/byCode/{code}
*
@@ -458,10 +456,9 @@ class Setup extends DolibarrApi
/**
* Get country by Iso.
*
- * @param string $iso ISO of country (3 characters)
- * @param string $lang Code of the language the name of the
- * country must be translated to
- * @return array Array of cleaned object properties
+ * @param string $iso ISO of country (3 characters)
+ * @param string $lang Code of the language the name of the country must be translated to
+ * @return Object Object with cleaned properties
*
* @url GET dictionary/countries/byISO/{iso}
*
@@ -475,9 +472,9 @@ class Setup extends DolibarrApi
/**
* Get state.
*
- * @param int $id ID of state
- * @param string $code Code of state
- * @return array Array of cleaned object properties
+ * @param int $id ID of state
+ * @param string $code Code of state
+ * @return Object Object with cleaned properties
*
* @throws RestException
*/
@@ -498,12 +495,11 @@ class Setup extends DolibarrApi
/**
* Get country.
*
- * @param int $id ID of country
- * @param string $code Code of country (2 characters)
- * @param string $iso ISO of country (3 characters)
- * @param string $lang Code of the language the name of the
- * country must be translated to
- * @return array Array of cleaned object properties
+ * @param int $id ID of country
+ * @param string $code Code of country (2 characters)
+ * @param string $iso ISO of country (3 characters)
+ * @param string $lang Code of the language the name of the country must be translated to
+ * @return Object Object with cleaned properties
*
* @throws RestException
*/
@@ -527,12 +523,12 @@ class Setup extends DolibarrApi
/**
* Get the list of delivery times.
*
- * @param string $sortfield Sort field
- * @param string $sortorder Sort order
- * @param int $limit Number of items per page
- * @param int $page Page number {@min 0}
- * @param int $active Delivery times is active or not {@min 0} {@max 1}
- * @param string $sqlfilters SQL criteria to filter with.
+ * @param string $sortfield Sort field
+ * @param string $sortorder Sort order
+ * @param int $limit Number of items per page
+ * @param int $page Page number {@min 0}
+ * @param int $active Delivery times is active or not {@min 0} {@max 1}
+ * @param string $sqlfilters SQL criteria to filter with.
*
* @url GET dictionary/availability
*
@@ -592,8 +588,8 @@ class Setup extends DolibarrApi
/**
* Clean sensible object datas
*
- * @param Object $object Object to clean
- * @return Object Object with cleaned properties
+ * @param Object $object Object to clean
+ * @return Object Object with cleaned properties
*/
protected function _cleanObjectDatas($object)
{
@@ -1686,6 +1682,68 @@ class Setup extends DolibarrApi
return $list;
}
+ /**
+ * Get the list of incoterms.
+ *
+ * @param string $sortfield Sort field
+ * @param string $sortorder Sort order
+ * @param int $limit Number of items per page
+ * @param int $page Page number (starting from zero)
+ * @param int $active Payment term is active or not {@min 0} {@max 1}
+ * @param string $lang Code of the language the label of the type must be translated to
+ * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
+ * @return array List of incoterm types
+ *
+ * @url GET dictionary/incoterms
+ *
+ * @throws RestException
+ */
+ public function getListOfIncoterms($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
+ {
+ $list = array();
+
+ $sql = "SELECT rowid, code, active";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_incoterms as t";
+ $sql .= " WHERE 1=1";
+
+ // Add sql filters
+ if ($sqlfilters) {
+ $errormessage = '';
+ if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ }
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
+ $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+ }
+
+
+ $sql .= $this->db->order($sortfield, $sortorder);
+
+ if ($limit) {
+ if ($page < 0) {
+ $page = 0;
+ }
+ $offset = $limit * $page;
+
+ $sql .= $this->db->plimit($limit, $offset);
+ }
+
+ $result = $this->db->query($sql);
+
+ if ($result) {
+ $num = $this->db->num_rows($result);
+ $min = min($num, ($limit <= 0 ? $num : $limit));
+ for ($i = 0; $i < $min; $i++) {
+ $type =$this->db->fetch_object($result);
+ $list[] = $type;
+ }
+ } else {
+ throw new RestException(503, 'Error when retrieving list of incoterm types : '.$this->db->lasterror());
+ }
+
+ return $list;
+ }
+
/**
* Get properties of company
*
@@ -1704,11 +1762,6 @@ class Setup extends DolibarrApi
throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_COMPANY');
}
- unset($mysoc->skype);
- unset($mysoc->twitter);
- unset($mysoc->facebook);
- unset($mysoc->linkedin);
-
unset($mysoc->pays);
unset($mysoc->note);
unset($mysoc->nom);
@@ -1786,8 +1839,8 @@ class Setup extends DolibarrApi
/**
* Get establishment by ID.
*
- * @param int $id ID of establishment
- * @return array Array of cleaned object properties
+ * @param int $id ID of establishment
+ * @return Object Object with cleaned properties
*
* @url GET establishments/{id}
*
@@ -1813,7 +1866,7 @@ class Setup extends DolibarrApi
* Note that conf variables that stores security key or password hashes can't be loaded with API.
*
* @param string $constantname Name of conf variable to get
- * @return array|mixed Data without useless information
+ * @return string Data without useless information
*
* @url GET conf/{constantname}
*
@@ -1825,7 +1878,7 @@ class Setup extends DolibarrApi
global $conf;
if (!DolibarrApiAccess::$user->admin
- && (empty($conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ)) {
+ && (!getDolGlobalString('API_LOGINS_ALLOWED_FOR_CONST_READ') || DolibarrApiAccess::$user->login != getDolGlobalString('API_LOGINS_ALLOWED_FOR_CONST_READ'))) {
throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_CONST_READ');
}
@@ -1836,7 +1889,7 @@ class Setup extends DolibarrApi
throw new RestException(403, 'Forbidden. This parameter cant be read with APIs');
}
- return $conf->global->$constantname;
+ return getDolGlobalString($constantname);
}
/**
diff --git a/htdocs/api/index.php b/htdocs/api/index.php
index 085dd338e69..4e4da2c94cc 100644
--- a/htdocs/api/index.php
+++ b/htdocs/api/index.php
@@ -389,13 +389,13 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
$usecompression = (empty($conf->global->API_DISABLE_COMPRESSION) && !empty($_SERVER['HTTP_ACCEPT_ENCODING']));
$foundonealgorithm = 0;
if ($usecompression) {
- if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress')) {
+ if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress')) {
$foundonealgorithm++;
}
- if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && is_callable('bzcompress')) {
+ if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) {
$foundonealgorithm++;
}
- if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && is_callable('gzencode')) {
+ if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) {
$foundonealgorithm++;
}
if (!$foundonealgorithm) {
@@ -413,13 +413,13 @@ $result = $api->r->handle();
if (Luracast\Restler\Defaults::$returnResponse) {
// We try to compress the data received data
- if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress')) {
+ if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress') && defined('BROTLI_TEXT')) {
header('Content-Encoding: br');
- $result = brotli_compress($result, 11, BROTLI_TEXT);
- } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && is_callable('bzcompress')) {
+ $result = brotli_compress($result, 11, constant('BROTLI_TEXT'));
+ } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) {
header('Content-Encoding: bz');
$result = bzcompress($result, 9);
- } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && is_callable('gzencode')) {
+ } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) {
header('Content-Encoding: gzip');
$result = gzencode($result, 9);
} else {
diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php
index 67448b0e304..1b107746319 100644
--- a/htdocs/asset/admin/setup.php
+++ b/htdocs/asset/admin/setup.php
@@ -68,16 +68,14 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
* Actions
*/
-if ((float) DOL_VERSION >= 6) {
- include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
-}
+include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') {
- $maskconstorder = GETPOST('maskconstorder', 'alpha');
- $maskorder = GETPOST('maskorder', 'alpha');
+ $maskconst = GETPOST('maskconst', 'alpha');
+ $mask = GETPOST('mask', 'alpha');
- if ($maskconstorder) {
- $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
+ if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
+ $res = dolibarr_set_const($db, $maskconst, $mask, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
@@ -206,7 +204,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
}
if ($myTmpObjectArray['includerefgeneration']) {
/*
- * Orders Numbering model
+ * Assets Numbering model
*/
$setupnotempty++;
@@ -475,14 +473,14 @@ if ($action == 'edit') {
if ($val['type'] == 'textarea') {
print '\n";
} elseif ($val['type']== 'html') {
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
- $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
+ $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
$doleditor->Create();
} elseif ($val['type'] == 'yesno') {
- print $form->selectyesno($constname, $conf->global->{$constname}, 1);
+ print $form->selectyesno($constname, getDolGlobalString($constname), 1);
} elseif (preg_match('/emailtemplate:/', $val['type'])) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
@@ -502,7 +500,7 @@ if ($action == 'edit') {
$arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
}
}
- print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
+ print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
} elseif (preg_match('/category:/', $val['type'])) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@@ -510,11 +508,11 @@ if ($action == 'edit') {
$tmp = explode(':', $val['type']);
print img_picto('', 'category', 'class="pictofixedwidth"');
- print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
+ print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
} elseif (preg_match('/thirdparty_type/', $val['type'])) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$formcompany = new FormCompany($db);
- print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname);
+ print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname);
} elseif ($val['type'] == 'securekey') {
print '';
if (!empty($conf->use_javascript_ajax)) {
@@ -526,11 +524,11 @@ if ($action == 'edit') {
print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
} elseif ($val['type'] == 'product') {
if (isModEnabled("product") || isModEnabled("service")) {
- $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
+ $selected = getDolGlobalString($constname);
$form->select_produits($selected, $constname, '', 0);
}
} elseif ($val['type'] == 'accountancy_code') {
- $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
+ $selected = getDolGlobalString($constname);
if (isModEnabled('accounting')) {
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$formaccounting = new FormAccounting($db);
@@ -539,7 +537,7 @@ if ($action == 'edit') {
print '';
}
} elseif ($val['type'] == 'accountancy_category') {
- $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
+ $selected = getDolGlobalString($constname);
if (isModEnabled('accounting')) {
print '';
// autosuggest from existing account types if found
@@ -589,9 +587,9 @@ if ($action == 'edit') {
print '
'."\n";
- // Common attributes
- include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
+ // Common attributes
+ include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
- // Other attributes
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
+ // Other attributes
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) {
- $selected = 1;
- }
- print '';
+ // mode view kanban
+ if ($mode == 'kanban') {
+ if ($i == 0) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($object->id, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
print '
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
- if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
- }
- if (!isset($totalarray['val'])) {
- $totalarray['val'] = array();
- }
- if (!isset($totalarray['val']['t.'.$key])) {
- $totalarray['val']['t.'.$key] = 0;
- }
- $totalarray['val']['t.'.$key] += $object->$key;
- }
}
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- // Action column
- if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) {
- $selected = 1;
+ foreach ($object->fields as $key => $val) {
+ $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
+ if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
}
- print '';
- }
- print '
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
+ }
+ if (!isset($totalarray['val'])) {
+ $totalarray['val'] = array();
+ }
+ if (!isset($totalarray['val']['t.'.$key])) {
+ $totalarray['val']['t.'.$key] = 0;
+ }
+ $totalarray['val']['t.'.$key] += $object->$key;
+ }
+ }
+ }
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Action column
+ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($object->id, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
}
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
-$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
+$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '
'."\n";
diff --git a/htdocs/bom/bom_net_needs.php b/htdocs/bom/bom_net_needs.php
index 1b8afa91e52..60736d085da 100644
--- a/htdocs/bom/bom_net_needs.php
+++ b/htdocs/bom/bom_net_needs.php
@@ -187,8 +187,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print dol_get_fiche_end();
- $viewlink = dolGetButtonTitle($langs->trans('GroupByProduct'), '', 'fa fa-bars imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':'')));
- $viewlink .= dolGetButtonTitle($langs->trans('TreeStructure'), '', 'fa fa-stream imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=treeview&token='.newToken(), '', 1, array('morecss' => 'reposition marginleftonly '.($action == 'treeview' ? 'btnTitleSelected':'')));
+ $viewlink = dolGetButtonTitle($langs->trans('GroupByX', $langs->transnoentitiesnoconv("Products")), '', 'fa fa-bars imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':'')));
+ $viewlink .= dolGetButtonTitle($langs->trans('TreeView'), '', 'fa fa-stream imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=treeview&token='.newToken(), '', 1, array('morecss' => 'reposition marginleftonly '.($action == 'treeview' ? 'btnTitleSelected':'')));
print load_fiche_titre($langs->trans("BOMNetNeeds"), $viewlink, '');
diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php
index c2df69b9012..1a42e17d875 100644
--- a/htdocs/bom/class/api_boms.class.php
+++ b/htdocs/bom/class/api_boms.class.php
@@ -205,6 +205,9 @@ class Boms extends DolibarrApi
foreach ($request_data as $field => $value) {
$this->bom->$field = $value;
}
+
+ $this->checkRefNumbering();
+
if (!$this->bom->create(DolibarrApiAccess::$user)) {
throw new RestException(500, "Error creating BOM", array_merge(array($this->bom->error), $this->bom->errors));
}
@@ -241,6 +244,8 @@ class Boms extends DolibarrApi
$this->bom->$field = $value;
}
+ $this->checkRefNumbering();
+
if ($this->bom->update(DolibarrApiAccess::$user) > 0) {
return $this->get($id);
} else {
@@ -536,4 +541,27 @@ class Boms extends DolibarrApi
}
return $myobject;
}
+
+ /**
+ * Validate the ref field and get the next Number if it's necessary.
+ *
+ * @return void
+ */
+ private function checkRefNumbering(): void
+ {
+ $ref = substr($this->bom->ref, 1, 4);
+ if ($this->bom->status > 0 && $ref == 'PROV') {
+ throw new RestException(400, "Wrong naming scheme '(PROV%)' is only allowed on 'DRAFT' status. For automatic increment use 'auto' on the 'ref' field.");
+ }
+
+ if (strtolower($this->bom->ref) == 'auto') {
+ if (empty($this->bom->id) && $this->bom->status == 0) {
+ $this->bom->ref = ''; // 'ref' will auto incremented with '(PROV' + newID + ')'
+ } else {
+ $this->bom->fetch_product();
+ $numref = $this->bom->getNextNumRef($this->bom->product);
+ $this->bom->ref = $numref;
+ }
+ }
+ }
}
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index cd5b119cabf..84bae509ebd 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -102,9 +102,9 @@ class BOM extends CommonObject
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'2', 'autofocusoncreate'=>1, 'css'=>'minwidth300 maxwidth400', 'csslist'=>'tdoverflowmax200'),
'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth175', 'csslist'=>'minwidth175 center'),
//'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>32, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing')),
- 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'picto'=>'product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'),
+ 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:((finished:is:null) or (finished:!=:0))', 'label'=>'Product', 'picto'=>'product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
- 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'),
+ 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth50imp right'),
//'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLossForProductProduced'),
'duration' => array('type'=>'duration', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'),
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'picto'=>'stock', 'enabled'=>1, 'visible'=>-1, 'position'=>102, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'),
@@ -476,7 +476,7 @@ class BOM extends CommonObject
$sql .= $this->getFieldList();
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
if ($this->ismultientitymanaged) {
- $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
+ $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
} else {
$sql .= ' WHERE 1 = 1';
}
@@ -1329,7 +1329,7 @@ class BOM extends CommonObject
* BOM costs calculation based on cost_price or pmp of each BOM line.
* Set the property ->total_cost and ->unit_cost of BOM.
*
- * @return void
+ * @return int <0 if KO, >0 if OK
*/
public function calculateCosts()
{
@@ -1378,7 +1378,8 @@ class BOM extends CommonObject
if ($res > 0) {
$bom_child->calculateCosts();
$line->childBom[] = $bom_child;
- $this->total_cost += $bom_child->total_cost * $line->qty;
+ $this->total_cost += price2num($bom_child->total_cost * $line->qty, 'MT');
+ $this->total_cost += $line->total_cost;
} else {
$this->error = $bom_child->error;
return -2;
@@ -1414,6 +1415,8 @@ class BOM extends CommonObject
$this->unit_cost = price2num($this->total_cost * $this->qty, 'MU');
}
}
+
+ return 1;
}
/**
@@ -1515,6 +1518,47 @@ class BOM extends CommonObject
}
}
}
+
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
+ * @param array $arraydata Array of data
+ * @return string HTML Code for Kanban thumb.
+ */
+ public function getKanbanView($option = '', $arraydata = null)
+ {
+ global $db,$langs;
+ $prod = new Product($db);
+ $prod->fetch($this->fk_product);
+
+ $return = '
';
if ($filtertype != 1) {
- if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+ if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '
' . $langs->trans('Unit') . '
';
}
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index b7087b27288..2dbc793fdf4 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -119,7 +119,7 @@ echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but
print '';
if ($filtertype != 1) {
- if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+ if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '
'."\n";
}
diff --git a/htdocs/bookcal/booking_note.php b/htdocs/bookcal/booking_note.php
index f68ffcbd72b..809f382cc16 100644
--- a/htdocs/bookcal/booking_note.php
+++ b/htdocs/bookcal/booking_note.php
@@ -22,63 +22,14 @@
* \brief Tab for notes on Booking
*/
-//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
-//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
-//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
-//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
-//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
-//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
-//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
-//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
-//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
-//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
-//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
-//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
-//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
-//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
-//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
-//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
-//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
-//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
-//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
-
// Load Dolibarr environment
-$res = 0;
-// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
-if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
- $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
-}
-// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
-$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
-while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
- $i--; $j--;
-}
-if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
- $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
-}
-if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
- $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
-}
-// Try main.inc.php using relative path
-if (!$res && file_exists("../main.inc.php")) {
- $res = @include "../main.inc.php";
-}
-if (!$res && file_exists("../../main.inc.php")) {
- $res = @include "../../main.inc.php";
-}
-if (!$res && file_exists("../../../main.inc.php")) {
- $res = @include "../../../main.inc.php";
-}
-if (!$res) {
- die("Include of main fails");
-}
+require '../main.inc.php';
-dol_include_once('/bookcal/class/booking.class.php');
-dol_include_once('/bookcal/lib/bookcal_booking.lib.php');
+require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php';
+require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php';
// Load translation files required by the page
-$langs->loadLangs(array("bookcal@bookcal", "companies"));
+$langs->loadLangs(array("agenda", "companies"));
// Get parameters
$id = GETPOST('id', 'int');
diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php
index cfbfc8eed88..6b4502e3364 100644
--- a/htdocs/bookcal/class/availabilities.class.php
+++ b/htdocs/bookcal/class/availabilities.class.php
@@ -74,7 +74,7 @@ class Availabilities extends CommonObject
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
* 'label' the translation key.
* 'picto' is code of a picto to show before value in forms
- * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or '!empty($conf->multicurrency->enabled)' ...)
+ * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled('multicurrency')' ...)
* 'position' is the sort order of field.
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
@@ -116,10 +116,10 @@ class Availabilities extends CommonObject
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'), 'validate'=>'1',),
- 'start' => array('type'=>'date', 'label'=>'Start Date', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'isameasure'=>'1',),
- 'end' => array('type'=>'date', 'label'=>'End Date', 'enabled'=>'1', 'position'=>45, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'isameasure'=>'1',),
+ 'start' => array('type'=>'date', 'label'=>'Start Date', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'searchall'=>1),
+ 'end' => array('type'=>'date', 'label'=>'End Date', 'enabled'=>'1', 'position'=>45, 'notnull'=>1, 'visible'=>1, 'searchall'=>1),
'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>49, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Customer', '1'=>'Supplier', '2'=>'Else'),),
- 'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>47, 'notnull'=>1, 'visible'=>1, 'default'=>'30', 'isameasure'=>'1',),
+ 'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>47, 'notnull'=>1, 'visible'=>1, 'default'=>'30'),
'startHour' => array('type'=>'integer', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>46, 'notnull'=>1, 'visible'=>-1,),
'endHour' => array('type'=>'integer', 'label'=>'End Hour', 'enabled'=>'1', 'position'=>46.5, 'notnull'=>1, 'visible'=>-1,),
);
@@ -842,7 +842,7 @@ class Availabilities extends CommonObject
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
- //$langs->load("bookcal@bookcal");
+ //$langs->load("agenda");
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
@@ -944,7 +944,7 @@ class Availabilities extends CommonObject
public function getNextNumRef()
{
global $langs, $conf;
- $langs->load("bookcal@bookcal");
+ $langs->load("agenda");
if (empty($conf->global->BOOKCAL_AVAILABILITIES_ADDON)) {
$conf->global->BOOKCAL_AVAILABILITIES_ADDON = 'mod_availabilities_standard';
@@ -1009,7 +1009,7 @@ class Availabilities extends CommonObject
$result = 0;
$includedocgeneration = 0;
- $langs->load("bookcal@bookcal");
+ $langs->load("agenda");
if (!dol_strlen($modele)) {
$modele = 'standard_availabilities';
diff --git a/htdocs/bookcal/class/booking.class.php b/htdocs/bookcal/class/booking.class.php
index a74cb87a43d..80807d7125f 100644
--- a/htdocs/bookcal/class/booking.class.php
+++ b/htdocs/bookcal/class/booking.class.php
@@ -74,7 +74,7 @@ class Booking extends CommonObject
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
* 'label' the translation key.
* 'picto' is code of a picto to show before value in forms
- * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or '!empty($conf->multicurrency->enabled)' ...)
+ * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled('multicurrency')' ...)
* 'position' is the sort order of field.
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
@@ -104,7 +104,7 @@ class Booking extends CommonObject
public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1.2, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"),
- 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"LinkToThirparty", 'validate'=>'1',),
+ 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"LinkToThirparty", 'validate'=>'1',),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'validate'=>'1',),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
@@ -842,7 +842,7 @@ class Booking extends CommonObject
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
- //$langs->load("bookcal@bookcal");
+ //$langs->load("agenda");
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
@@ -944,7 +944,7 @@ class Booking extends CommonObject
public function getNextNumRef()
{
global $langs, $conf;
- $langs->load("bookcal@bookcal");
+ $langs->load("agenda");
if (empty($conf->global->BOOKCAL_BOOKING_ADDON)) {
$conf->global->BOOKCAL_BOOKING_ADDON = 'mod_booking_standard';
@@ -1009,7 +1009,7 @@ class Booking extends CommonObject
$result = 0;
$includedocgeneration = 0;
- $langs->load("bookcal@bookcal");
+ $langs->load("agenda");
if (!dol_strlen($modele)) {
$modele = 'standard_booking';
diff --git a/htdocs/bookcal/lib/bookcal.lib.php b/htdocs/bookcal/lib/bookcal.lib.php
index bc60468fb1d..3f809da08d8 100644
--- a/htdocs/bookcal/lib/bookcal.lib.php
+++ b/htdocs/bookcal/lib/bookcal.lib.php
@@ -30,7 +30,7 @@ function bookcalAdminPrepareHead()
{
global $langs, $conf;
- $langs->load("bookcal@bookcal");
+ $langs->load("agenda");
$h = 0;
$head = array();
@@ -47,11 +47,6 @@ function bookcalAdminPrepareHead()
$h++;
*/
- $head[$h][0] = dol_buildpath("/bookcal/admin/about.php", 1);
- $head[$h][1] = $langs->trans("About");
- $head[$h][2] = 'about';
- $h++;
-
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
//$this->tabs = array(
diff --git a/htdocs/bookcal/lib/bookcal_availabilities.lib.php b/htdocs/bookcal/lib/bookcal_availabilities.lib.php
index 83d204a2d76..1fb4b2aed75 100644
--- a/htdocs/bookcal/lib/bookcal_availabilities.lib.php
+++ b/htdocs/bookcal/lib/bookcal_availabilities.lib.php
@@ -31,7 +31,7 @@ function availabilitiesPrepareHead($object)
{
global $db, $langs, $conf;
- $langs->load("bookcal@bookcal");
+ $langs->load("agenda");
$showtabofpagecontact = 1;
$showtabofpagenote = 1;
diff --git a/htdocs/bookcal/lib/bookcal_booking.lib.php b/htdocs/bookcal/lib/bookcal_booking.lib.php
index a6cb0e50df6..c0dec7d6d2e 100644
--- a/htdocs/bookcal/lib/bookcal_booking.lib.php
+++ b/htdocs/bookcal/lib/bookcal_booking.lib.php
@@ -31,7 +31,7 @@ function bookingPrepareHead($object)
{
global $db, $langs, $conf;
- $langs->load("bookcal@bookcal");
+ $langs->load("agenda");
$showtabofpagecontact = 1;
$showtabofpagenote = 1;
diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php
index d5258ba26f1..88cae3e4293 100644
--- a/htdocs/bookmarks/bookmarks.lib.php
+++ b/htdocs/bookmarks/bookmarks.lib.php
@@ -52,6 +52,7 @@ function printDropdownBookmarksList()
}
}
}
+
$tmpurl = '';
// No urlencode, all param $url will be urlencoded later
if ($sortfield) {
@@ -65,7 +66,13 @@ function printDropdownBookmarksList()
if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var))
&& $val != ''
&& !array_key_exists($key, $url_param)) {
- $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
+ if (is_array($val)) {
+ foreach ($val as $tmpsubval) {
+ $url_param[] = http_build_query(array(dol_escape_htmltag($key).'[]' => dol_escape_htmltag($tmpsubval)));
+ }
+ } elseif ($val != '') {
+ $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
+ }
}
}
}
@@ -203,11 +210,11 @@ function printDropdownBookmarksList()
$html .= '
'."\n";
@@ -1949,7 +1949,7 @@ if ($id > 0) {
// related contact
print '
';
+ // cache of user list (owners)
+ if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) {
+ $userstatic = new User($db);
+ $res = $userstatic->fetch($obj->fk_user_action);
+ if ($res > 0) {
+ $cache_user_list[$obj->fk_user_action] = $userstatic;
+ }
+ }
+
+ // get event style for user owner
+ $event_owner_style = '';
+ // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
+ if ($cache_user_list[$obj->fk_user_action]->color != '') {
+ $event_owner_style .= 'border-left: #' . $cache_user_list[$obj->fk_user_action]->color . ' 5px solid;';
+ }
+
+ // get event style for start and end date
+ $event_more_class = '';
+ $event_start_date_css = '';
+ $event_end_date_css = '';
+ $event_start_date_time = $actionstatic->datep;
+ if ($event_start_date_time > $now) {
+ // future event
+ $event_more_class = 'event-future';
+ $event_start_date_css = $event_end_date_css = $event_more_class;
+ } else {
+ if ($obj->fulldayevent == 1) {
+ $today_start_date_time = $today_start_time;
+ } else {
+ $today_start_date_time = $now;
+ }
+
+ // check event end date
+ $event_end_date_time = $db->jdate($obj->dp2);
+ if ($event_end_date_time != null && $event_end_date_time < $today_start_date_time) {
+ // past event
+ $event_more_class = 'event-past';
+ } elseif ($event_end_date_time == null && $event_start_date_time < $today_start_date_time) {
+ // past event
+ $event_more_class = 'event-past';
+ } else {
+ // current event
+ $event_more_class = 'event-current';
+ }
+ $event_start_date_css = $event_end_date_css = $event_more_class;
+ }
+ $event_start_date_css = $event_end_date_css = $event_more_class;
+
+ print '
';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '
';
@@ -955,10 +1010,16 @@ while ($i < $imaxinloop) {
// User owner
if (!empty($arrayfields['owner']['checked'])) {
- print '
'; // With edge and chrome the td overflow is not supported correctly when content is not full text.
- if ($obj->fk_user_action > 0) {
- $userstatic->fetch($obj->fk_user_action);
- print $userstatic->getNomUrl(-1);
+ print '
'; // With edge and chrome the td overflow is not supported correctly when content is not full text.
+ if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) {
+ $userstatic = new User($db);
+ $res = $userstatic->fetch($obj->fk_user_action);
+ if ($res > 0) {
+ $cache_user_list[$obj->fk_user_action] = $userstatic;
+ }
+ }
+ if (isset($cache_user_list[$obj->fk_user_action])) {
+ print $cache_user_list[$obj->fk_user_action]->getNomUrl(-1);
} else {
print ' ';
}
@@ -1006,13 +1067,14 @@ while ($i < $imaxinloop) {
// Start date
if (!empty($arrayfields['a.datep']['checked'])) {
- print '
';
}
// If the user can view prospects other than his'
@@ -1381,8 +1399,8 @@ if ($resql) {
}
if (!empty($arrayfields['u.login']['checked'])) {
// Author
- print '
';
- print '';
+ print '
';
+ print '';
print '
';
}
if (!empty($arrayfields['sale_representative']['checked'])) {
@@ -1438,8 +1456,8 @@ if ($resql) {
}
// Status
if (!empty($arrayfields['p.fk_statut']['checked'])) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Action column
+ if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
- print '';
- }
- print '
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
-
- if (!empty($arrayfields['p.ref']['checked'])) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Date modification
+ if (!empty($arrayfields['p.tms']['checked'])) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
- }
- print '';
+ if ($mode == 'kanban') {
+ if ($i == 0) {
+ print '
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
-
- // Third party
- if (!empty($arrayfields['s.nom']['checked'])) {
- print '
';
- print $getNomUrl_cache[$obj->socid];
-
- // If module invoices enabled and user with invoice creation permissions
- if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) {
- if ($user->rights->facture->creer) {
- if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
- print ' ';
- print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'';
+ // Action column
+ if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
}
+ print '';
+ }
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ print '
';
}
- if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service
- $nbprod++; // order contains real products
- $generic_product->id = $generic_commande->lines[$lig]->fk_product;
+ }
+ //else print $langs->trans("NoSalesRepresentativeAffected");
+ } else {
+ print ' ';
+ }
+ print '
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
- // Get local and virtual stock and store it into cache
- if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
- $generic_product->load_stock('nobatch,warehouseopen'); // ->load_virtual_stock() is already included into load_stock()
- $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel;
- $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
+ // Total buying or cost price
+ if (!empty($arrayfields['total_pa']['checked'])) {
+ print '
'.price($marginInfo['pa_total']).'
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+
+ // Total margin
+ if (!empty($arrayfields['total_margin']['checked'])) {
+ print '
'.price($marginInfo['total_margin']).'
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
+ }
+ $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
+ }
+
+ // Total margin rate
+ if (!empty($arrayfields['total_margin_rate']['checked'])) {
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Billed
+ if (!empty($arrayfields['c.facture']['checked'])) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
+ }
+ // If the user can view prospects other than his'
+ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
+ include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+ $moreforfilter .= '
';
+ }
+ if (!empty($arrayfields['sale_representative']['checked'])) {
+ print '
';
+ }
+ if (!empty($arrayfields['total_pa']['checked'])) {
+ print '
';
+ print '
';
+ }
+ if (!empty($arrayfields['total_margin']['checked'])) {
+ print '
';
+ print '
';
+ }
+ if (!empty($arrayfields['total_margin_rate']['checked'])) {
+ print '
';
+ print '
';
+ }
+ if (!empty($arrayfields['total_mark_rate']['checked'])) {
+ print '
';
+ print '
';
+ }
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
+ // 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['c.datec']['checked'])) {
+ print '
';
+ print '
';
+ }
+ // Date modification
+ if (!empty($arrayfields['c.tms']['checked'])) {
+ print '
';
+ print '
';
+ }
+ // Date cloture
+ if (!empty($arrayfields['c.date_cloture']['checked'])) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($objecttmp->id, $arrayofselected)) {
- $selected = 1;
+ if ($mode == 'kanban') {
+ if ($i == 0) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($objecttmp->id, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
- print '';
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($objecttmp->id, $arrayofselected)) {
- $selected = 1;
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($objecttmp->id, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
'."\n";
}
@@ -552,81 +556,101 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
// Store properties in $object
$object->setVarsFromFetchObj($obj);
- // Show here line of result
- $j = 0;
- print '
';
if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
+ $totalarray['nbfield']++;
}
- if (!isset($totalarray['val'])) {
- $totalarray['val'] = array();
+ if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
+ }
+ if (!isset($totalarray['val'])) {
+ $totalarray['val'] = array();
+ }
+ if (!isset($totalarray['val']['t.'.$key])) {
+ $totalarray['val']['t.'.$key] = 0;
+ }
+ $totalarray['val']['t.'.$key] += $object->$key;
}
- if (!isset($totalarray['val']['t.'.$key])) {
- $totalarray['val']['t.'.$key] = 0;
- }
- $totalarray['val']['t.'.$key] += $object->$key;
}
}
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- // Action column
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) {
- $selected = 1;
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Action column
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($object->id, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
print '';
@@ -5423,7 +5422,7 @@ if ($action == 'create') {
// Show object lines
if (!empty($object->lines)) {
- $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
+ $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
}
// Form to add new line
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index 4c1392e28eb..bae53bce6a8 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -65,9 +65,9 @@ class Invoices extends DolibarrApi
*
* Return an array with invoice informations
*
- * @param int $id ID of invoice
- * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses
- * @return array|mixed data without useless information
+ * @param int $id ID of invoice
+ * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses
+ * @return Object Object with cleaned properties
*
* @throws RestException
*/
@@ -81,9 +81,9 @@ class Invoices extends DolibarrApi
*
* Return an array with invoice informations
*
- * @param string $ref Ref of object
- * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
- * @return array|mixed data without useless information
+ * @param string $ref Ref of object
+ * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
+ * @return Object Object with cleaned properties
*
* @url GET ref/{ref}
*
@@ -99,9 +99,9 @@ class Invoices extends DolibarrApi
*
* Return an array with invoice informations
*
- * @param string $ref_ext External reference of object
- * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
- * @return array|mixed data without useless information
+ * @param string $ref_ext External reference of object
+ * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
+ * @return Object Object with cleaned properties
*
* @url GET ref_ext/{ref_ext}
*
@@ -117,11 +117,11 @@ class Invoices extends DolibarrApi
*
* Return an array with invoice informations
*
- * @param int $id ID of order
- * @param string $ref Ref of object
- * @param string $ref_ext External reference of object
- * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
- * @return array|mixed data without useless information
+ * @param int $id ID of order
+ * @param string $ref Ref of object
+ * @param string $ref_ext External reference of object
+ * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
+ * @return Object Object with cleaned properties
*
* @throws RestException
*/
@@ -325,12 +325,11 @@ class Invoices extends DolibarrApi
/**
* Create an invoice using an existing order.
*
- *
* @param int $orderid Id of the order
+ * @return Object Object with cleaned properties
*
* @url POST /createfromorder/{orderid}
*
- * @return int
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
@@ -338,7 +337,6 @@ class Invoices extends DolibarrApi
*/
public function createInvoiceFromOrder($orderid)
{
-
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (!DolibarrApiAccess::$user->rights->commande->lire) {
@@ -368,11 +366,10 @@ class Invoices extends DolibarrApi
/**
* Get lines of an invoice
*
- * @param int $id Id of invoice
+ * @param int $id Id of invoice
+ * @return array Array of lines
*
* @url GET {id}/lines
- *
- * @return int
*/
public function getLines($id)
{
@@ -399,14 +396,13 @@ class Invoices extends DolibarrApi
/**
* Update a line to a given invoice
*
- * @param int $id Id of invoice to update
- * @param int $lineid Id of line to update
- * @param array $request_data InvoiceLine data
+ * @param int $id Id of invoice to update
+ * @param int $lineid Id of line to update
+ * @param array $request_data InvoiceLine data
+ * @return Object Object with cleaned properties
*
* @url PUT {id}/lines/{lineid}
*
- * @return array
- *
* @throws RestException 304
* @throws RestException 401
* @throws RestException 404 Invoice not found
@@ -472,14 +468,13 @@ class Invoices extends DolibarrApi
/**
* Add a contact type of given invoice
*
- * @param int $id Id of invoice to update
- * @param int $contactid Id of contact to add
- * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER)
+ * @param int $id Id of invoice to update
+ * @param int $contactid Id of contact to add
+ * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER)
+ * @return array
*
* @url POST {id}/contact/{contactid}/{type}
*
- * @return int
- *
* @throws RestException 401
* @throws RestException 404
*/
@@ -509,20 +504,24 @@ class Invoices extends DolibarrApi
throw new RestException(500, 'Error when added the contact');
}
- return $this->_cleanObjectDatas($this->invoice);
+ return array(
+ 'success' => array(
+ 'code' => 200,
+ 'message' => 'Contact linked to the invoice'
+ )
+ );
}
/**
* Delete a contact type of given invoice
*
- * @param int $id Id of invoice to update
- * @param int $contactid Row key of the contact in the array contact_ids.
- * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
+ * @param int $id Id of invoice to update
+ * @param int $contactid Row key of the contact in the array contact_ids.
+ * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
+ * @return Object Object with cleaned properties
*
* @url DELETE {id}/contact/{contactid}/{type}
*
- * @return array
- *
* @throws RestException 401
* @throws RestException 404
* @throws RestException 500 System error
@@ -561,13 +560,12 @@ class Invoices extends DolibarrApi
/**
* Deletes a line of a given invoice
*
- * @param int $id Id of invoice
- * @param int $lineid Id of the line to delete
+ * @param int $id Id of invoice
+ * @param int $lineid Id of the line to delete
+ * @return Object Object with cleaned properties
*
* @url DELETE {id}/lines/{lineid}
*
- * @return array
- *
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
@@ -575,7 +573,6 @@ class Invoices extends DolibarrApi
*/
public function deleteLine($id, $lineid)
{
-
if (!DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
@@ -592,9 +589,7 @@ class Invoices extends DolibarrApi
throw new RestException(404, 'Invoice not found');
}
- // TODO Check the lineid $lineid is a line of ojbect
-
- $updateRes = $this->invoice->deleteline($lineid);
+ $updateRes = $this->invoice->deleteline($lineid, $id);
if ($updateRes > 0) {
return $this->get($id);
} else {
@@ -605,9 +600,9 @@ class Invoices extends DolibarrApi
/**
* Update invoice
*
- * @param int $id Id of invoice to update
- * @param array $request_data Datas
- * @return int
+ * @param int $id Id of invoice to update
+ * @param array $request_data Datas
+ * @return Object|false Object with cleaned properties
*/
public function put($id, $request_data = null)
{
@@ -648,8 +643,8 @@ class Invoices extends DolibarrApi
/**
* Delete invoice
*
- * @param int $id Invoice ID
- * @return array
+ * @param int $id Invoice ID
+ * @return array
*/
public function delete($id)
{
@@ -829,11 +824,10 @@ class Invoices extends DolibarrApi
*
* @param int $id Order ID
* @param int $idwarehouse Warehouse ID
+ * @return Object Object with cleaned properties
*
* @url POST {id}/settodraft
*
- * @return array
- *
* @throws RestException 304
* @throws RestException 401
* @throws RestException 404
@@ -887,10 +881,9 @@ class Invoices extends DolibarrApi
* @param int $id Invoice ID
* @param int $idwarehouse Warehouse ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return Object|false Object with cleaned properties
*
* @url POST {id}/validate
- *
- * @return array
*/
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
@@ -932,11 +925,10 @@ class Invoices extends DolibarrApi
* @param int $id Order ID
* @param string $close_code Code filled if we classify to 'Paid completely' when payment is not complete (for escompte for example)
* @param string $close_note Comment defined if we classify to 'Paid' when payment is not complete (for escompte for example)
+ * @return Object Object with cleaned properties
*
* @url POST {id}/settopaid
*
- * @return array An invoice object
- *
* @throws RestException 304
* @throws RestException 401
* @throws RestException 404
@@ -981,12 +973,11 @@ class Invoices extends DolibarrApi
/**
* Sets an invoice as unpaid
*
- * @param int $id Order ID
+ * @param int $id Order ID
+ * @return Object Object with cleaned properties
*
* @url POST {id}/settounpaid
*
- * @return array An invoice object
- *
* @throws RestException 304
* @throws RestException 401
* @throws RestException 404
@@ -1031,10 +1022,9 @@ class Invoices extends DolibarrApi
* Get discount from invoice
*
* @param int $id Id of invoice
+ * @return Object Object with cleaned properties
*
* @url GET {id}/discount
- *
- * @return mixed
*/
public function getDiscount($id)
{
@@ -1069,10 +1059,10 @@ class Invoices extends DolibarrApi
/**
* Create a discount (credit available) for a credit note or a deposit.
*
- * @param int $id Invoice ID
- * @url POST {id}/markAsCreditAvailable
+ * @param int $id Invoice ID
+ * @return Object Object with cleaned properties
*
- * @return array An invoice object
+ * @url POST {id}/markAsCreditAvailable
*
* @throws RestException 304
* @throws RestException 401
@@ -1241,11 +1231,10 @@ class Invoices extends DolibarrApi
*
* @param int $id Id of invoice
* @param int $discountid Id of discount
+ * @return int
*
* @url POST {id}/usediscount/{discountid}
*
- * @return int
- *
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
@@ -1253,7 +1242,6 @@ class Invoices extends DolibarrApi
*/
public function useDiscount($id, $discountid)
{
-
if (!DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
@@ -1288,11 +1276,10 @@ class Invoices extends DolibarrApi
*
* @param int $id Id of invoice
* @param int $discountid Id of a discount coming from a credit note
+ * @return int
*
* @url POST {id}/usecreditnote/{discountid}
*
- * @return int
- *
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
@@ -1300,7 +1287,6 @@ class Invoices extends DolibarrApi
*/
public function useCreditNote($id, $discountid)
{
-
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
if (!DolibarrApiAccess::$user->rights->facture->creer) {
@@ -1333,12 +1319,11 @@ class Invoices extends DolibarrApi
/**
* Get list of payments of a given invoice
*
- * @param int $id Id of invoice
+ * @param int $id Id of invoice
+ * @return array
*
* @url GET {id}/payments
*
- * @return array
- *
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
@@ -1395,8 +1380,6 @@ class Invoices extends DolibarrApi
*/
public function addPayment($id, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '')
{
- global $conf;
-
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
if (!DolibarrApiAccess::$user->rights->facture->creer) {
@@ -1509,6 +1492,7 @@ class Invoices extends DolibarrApi
* @url POST /paymentsdistributed
*
* @return int Payment ID
+ *
* @throws RestException 400
* @throws RestException 401
* @throws RestException 403
@@ -1516,8 +1500,6 @@ class Invoices extends DolibarrApi
*/
public function addPaymentDistributed($arrayofamounts, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '', $ref_ext = '', $accepthigherpayment = false)
{
- global $conf;
-
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
if (!DolibarrApiAccess::$user->rights->facture->creer) {
@@ -1645,6 +1627,7 @@ class Invoices extends DolibarrApi
* @url PUT payments/{id}
*
* @return array
+ *
* @throws RestException 400 Bad parameters
* @throws RestException 401 Not allowed
* @throws RestException 404 Not found
@@ -1708,8 +1691,8 @@ class Invoices extends DolibarrApi
/**
* Validate fields before create or update object
*
- * @param array|null $data Datas to validate
- * @return array
+ * @param array|null $data Datas to validate
+ * @return array
*
* @throws RestException
*/
@@ -1733,7 +1716,7 @@ class Invoices extends DolibarrApi
*
* @param int $id ID of template invoice
* @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses
- * @return array|mixed data without useless information
+ * @return Object Object with cleaned properties
*
* @url GET templates/{id}
*
@@ -1749,11 +1732,11 @@ class Invoices extends DolibarrApi
*
* Return an array with invoice informations
*
- * @param int $id ID of order
- * @param string $ref Ref of object
- * @param string $ref_ext External reference of object
- * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
- * @return array|mixed data without useless information
+ * @param int $id ID of order
+ * @param string $ref Ref of object
+ * @param string $ref_ext External reference of object
+ * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
+ * @return Object Object with cleaned properties
*
* @throws RestException
*/
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 3a586dfc3e5..269c5267ab3 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -169,7 +169,7 @@ class FactureRec extends CommonInvoice
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>15),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1),
- 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>25),
+ 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>25),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
//'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35),
'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
@@ -188,13 +188,12 @@ class FactureRec extends CommonInvoice
'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>105),
'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>110),
'modelpdf' =>array('type'=>'varchar(255)', 'label'=>'Modelpdf', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
- 'date_last_gen' =>array('type'=>'varchar(7)', 'label'=>'Last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>120),
- 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'Unit frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>125),
'date_when' =>array('type'=>'datetime', 'label'=>'Date when', 'enabled'=>1, 'visible'=>-1, 'position'=>130),
'date_last_gen' =>array('type'=>'datetime', 'label'=>'Date last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>135),
'nb_gen_done' =>array('type'=>'integer', 'label'=>'Nb gen done', 'enabled'=>1, 'visible'=>-1, 'position'=>140),
'nb_gen_max' =>array('type'=>'integer', 'label'=>'Nb gen max', 'enabled'=>1, 'visible'=>-1, 'position'=>145),
'frequency' =>array('type'=>'integer', 'label'=>'Frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>150),
+ 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'UnitFrequency', 'enabled'=>1, 'visible'=>-1, 'position'=>152),
'usenewprice' =>array('type'=>'integer', 'label'=>'UseNewPrice', 'enabled'=>1, 'visible'=>0, 'position'=>155),
'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>160, 'isameasure'=>1),
'auto_validate' =>array('type'=>'integer', 'label'=>'Auto validate', 'enabled'=>1, 'visible'=>-1, 'position'=>165),
@@ -1771,35 +1770,35 @@ class FactureRec extends CommonInvoice
/**
* Function used to replace a thirdparty id with another one.
*
- * @param DoliDB $db Database handler
- * @param int $origin_id Old thirdparty id
- * @param int $dest_id New thirdparty id
- * @return bool
+ * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
*/
- public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
{
$tables = array(
'facture_rec'
);
- return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
}
/**
* Function used to replace a product id with another one.
*
- * @param DoliDB $db Database handler
- * @param int $origin_id Old product id
- * @param int $dest_id New product id
- * @return bool
+ * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test
+ * @param int $origin_id Old product id
+ * @param int $dest_id New product id
+ * @return bool
*/
- public static function replaceProduct(DoliDB $db, $origin_id, $dest_id)
+ public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id)
{
$tables = array(
'facturedet_rec'
);
- return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables);
+ return CommonObject::commonReplaceProduct($dbs, $origin_id, $dest_id, $tables);
}
/**
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 87d28de8756..561ebf3e9ed 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1330,6 +1330,8 @@ class Facture extends CommonInvoice
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
+ $this->errors += $hookmanager->errors;
+ $this->error = $hookmanager->error;
$error++;
}
}
@@ -1463,6 +1465,8 @@ class Facture extends CommonInvoice
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
+ $this->errors += $hookmanager->errors;
+ $this->error = $hookmanager->error;
$error++;
}
@@ -1956,14 +1960,14 @@ class Facture extends CommonInvoice
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid';
if ($rowid) {
- $sql .= " WHERE f.rowid=".((int) $rowid);
+ $sql .= " WHERE f.rowid = ".((int) $rowid);
} else {
$sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Don't use entity if you use rowid
if ($ref) {
- $sql .= " AND f.ref='".$this->db->escape($ref)."'";
+ $sql .= " AND f.ref = '".$this->db->escape($ref)."'";
}
if ($ref_ext) {
- $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'";
+ $sql .= " AND f.ref_ext = '".$this->db->escape($ref_ext)."'";
}
}
@@ -4078,7 +4082,7 @@ class Facture extends CommonInvoice
*
* @param int $idline id of line to check
* @param float $situation_percent progress percentage need to be test
- * @return false if KO, true if OK
+ * @return bool false if KO, true if OK
*/
public function checkProgressLine($idline, $situation_percent)
{
@@ -4097,7 +4101,7 @@ class Facture extends CommonInvoice
if ($obj === null) {
return true;
} else {
- return $situation_percent < $obj->situation_percent;
+ return ($situation_percent < $obj->situation_percent);
}
}
@@ -4148,9 +4152,10 @@ class Facture extends CommonInvoice
* Delete line in database
*
* @param int $rowid Id of line to delete
+ * @param int $id Id of object (for a check)
* @return int <0 if KO, >0 if OK
*/
- public function deleteline($rowid)
+ public function deleteline($rowid, $id = 0)
{
global $user;
@@ -4161,6 +4166,22 @@ class Facture extends CommonInvoice
return -1;
}
+ $line = new FactureLigne($this->db);
+
+ $line->context = $this->context;
+
+ // Load line
+ $result = $line->fetch($rowid);
+ if (!($result > 0)) {
+ dol_print_error($this->db, $line->error, $line->errors);
+ return -1;
+ }
+
+ if ($id > 0 && $line->fk_facture != $id) {
+ $this->error = 'ErrorLineIDDoesNotMatchWithObjectID';
+ return -1;
+ }
+
$this->db->begin();
// Free discount linked to invoice line
@@ -4176,15 +4197,9 @@ class Facture extends CommonInvoice
return -1;
}
- $line = new FactureLigne($this->db);
-
- $line->context = $this->context;
-
- // For triggers
- $result = $line->fetch($rowid);
- if (!($result > 0)) {
- dol_print_error($this->db, $line->error, $line->errors);
- }
+ // Memorize previous line for triggers
+ $staticline = clone $line;
+ $line->oldline = $staticline;
if ($line->delete($user) > 0) {
$result = $this->update_price(1);
@@ -4213,7 +4228,7 @@ class Facture extends CommonInvoice
* @param User $user User that set discount
* @param double $remise Discount
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if ko, >0 if ok
+ * @return int <0 if KO, >0 if OK
*/
public function set_remise($user, $remise, $notrigger = 0)
{
@@ -4228,7 +4243,7 @@ class Facture extends CommonInvoice
* @param User $user User that set discount
* @param double $remise Discount
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if ko, >0 if ok
+ * @return int <0 if KO, >0 if OK
*/
public function setDiscount($user, $remise, $notrigger = 0)
{
@@ -4280,6 +4295,8 @@ class Facture extends CommonInvoice
return -1 * $error;
}
}
+
+ return 0;
}
@@ -4345,6 +4362,8 @@ class Facture extends CommonInvoice
return -1 * $error;
}
}
+
+ return 0;
}
/**
@@ -4636,8 +4655,8 @@ class Facture extends CommonInvoice
* Invoices matching the following rules are returned:
* (validated + payment on process) or classified (payed completely or payed partiely) + not already replaced + not already a credit note
*
- * @param int $socid Id thirdparty
- * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>)
+ * @param int $socid Id thirdparty
+ * @return array|int Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>)
*/
public function list_qualified_avoir_invoices($socid = 0)
{
@@ -4711,8 +4730,8 @@ class Facture extends CommonInvoice
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
- * @param User $user Object user
- * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
+ * @param User $user Object user
+ * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/
public function load_board($user)
{
@@ -5190,18 +5209,18 @@ class Facture extends CommonInvoice
/**
* Function used to replace a thirdparty id with another one.
*
- * @param DoliDB $db Database handler
- * @param int $origin_id Old third-party id
- * @param int $dest_id New third-party id
- * @return bool
+ * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
*/
- public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
{
$tables = array(
'facture'
);
- return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
}
/**
@@ -5731,6 +5750,40 @@ class Facture extends CommonInvoice
} else {
dol_print_error($this->db);
}
+
+ return array();
+ }
+
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
+ * @param array $arraydata Array of data
+ * @return string HTML Code for Kanban thumb.
+ */
+ public function getKanbanView($option = '', $arraydata = null)
+ {
+ $return = '
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Parent company
- if (!empty($arrayfields['s2.nom']['checked'])) {
- print '
';
- if ($obj->fk_parent > 0) {
- if (!isset($company_url_list[$obj->fk_parent])) {
- $companyparent = new Societe($db);
- $res = $companyparent->fetch($obj->fk_parent);
- if ($res > 0) {
- $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
+ // Action column
+ if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+ print '
';
+ if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->id, $arrayofselected)) {
+ $selected = 1;
}
+ print '';
}
- if (isset($company_url_list[$obj->fk_parent])) {
- print $company_url_list[$obj->fk_parent];
+ print '
';
+ }
+
+ // No
+ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
+ print '
'; // TODO Use a denormalized field
- if (!$i) {
- $totalarray['nbfield']++;
+ // Module Source
+ if (!empty($arrayfields['f.module_source']['checked'])) {
+ print '
'; // TODO Use a denormalized field
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
-
- // Total buying or cost price
- if (!empty($arrayfields['total_pa']['checked'])) {
- print '
'.price($marginInfo['pa_total']).'
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Total margin
- if (!empty($arrayfields['total_margin']['checked'])) {
- print '
'.price($marginInfo['total_margin']).'
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
- }
- $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
- }
- // Total margin rate
- if (!empty($arrayfields['total_margin_rate']['checked'])) {
- print '
'; // TODO Use a denormalized field
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+
+ // Pending amount
+ if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
+ print '
'; // TODO Use a denormalized field
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+
+ // Total buying or cost price
+ if (!empty($arrayfields['total_pa']['checked'])) {
+ print '
'.price($marginInfo['pa_total']).'
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+ // Total margin
+ if (!empty($arrayfields['total_margin']['checked'])) {
+ print '
'.price($marginInfo['total_margin']).'
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
+ }
+ $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
+ }
+ // Total margin rate
+ if (!empty($arrayfields['total_margin_rate']['checked'])) {
+ print '
";
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+
+ // Action column (Show the massaction button only when this page is not opend from the Extended POS)
+
+ if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+ print '
';
+ if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->id, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
";
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
-
- // Action column (Show the massaction button only when this page is not opend from the Extended POS)
-
- if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
- print '
';
- if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->id, $arrayofselected)) {
- $selected = 1;
- }
- print '';
- }
- print '
'; // TODO Use date hour
+ $account = new Account($db);
+ $account->fetch($objp->bid);
+ $checkdepositstatic->account_id = $account->getNomUrl(1);
- // Bank
- print '
';
@@ -389,16 +392,6 @@ if ($refresh === true) {
$hookmanager->initHooks(array('externalbalance'));
$reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!is_array($x_coll) && $coll_listbuy == -1) {
- $langs->load("errors");
- print '
';
}
if (!empty($arrayfields['p.import_key']['checked'])) {
@@ -1043,7 +1103,7 @@ if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
}
print '';
-// Ligne des titres
+// Title line
print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Action column
+ if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
- print '';
+ print '
';
}
- print '';
- }
- // ID
- if (!empty($arrayfields['p.rowid']['checked'])) {
- print '
';
- if (!$i) {
- $totalarray['nbfield']++;
+ // Company / Third Party
+ if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) {
+ print '
\n";
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Action column
- if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (!empty($arrayfields['p.datec']['checked'])) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
+ }
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+
+ print "\n";
+ }
$i++;
}
diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php
index fe11c90c0b9..d366d1c2b17 100644
--- a/htdocs/contact/vcard.php
+++ b/htdocs/contact/vcard.php
@@ -92,18 +92,23 @@ if ($company->id) {
} elseif (empty(trim($contact->email))) {
// when contact e-mail is empty, use only company e-mail
$v->setEmail($company->email);
- } elseif (strtolower(end(explode("@", $contact->email))) == strtolower(end(explode("@", $company->email)))) {
- // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second)
- $v->setEmail($contact->email);
-
- // support by Microsoft Outlook (2019 and possible earlier)
- $v->setEmail($company->email, 'INTERNET');
} else {
- // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second)
- $v->setEmail($company->email);
+ $tmpcontact = explode("@", trim($contact->email));
+ $tmpcompany = explode("@", trim($company->email));
- // support by Microsoft Outlook (2019 and possible earlier)
- $v->setEmail($contact->email, 'INTERNET');
+ if (strtolower(end($tmpcontact)) == strtolower(end($tmpcompany))) {
+ // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second)
+ $v->setEmail($contact->email);
+
+ // support by Microsoft Outlook (2019 and possible earlier)
+ $v->setEmail($company->email, 'INTERNET');
+ } else {
+ // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second)
+ $v->setEmail($company->email);
+
+ // support by Microsoft Outlook (2019 and possible earlier)
+ $v->setEmail($contact->email, 'INTERNET');
+ }
}
// Si contact lie a un tiers non de type "particulier"
diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php
index 3a3c5440b30..e631c6a4a60 100644
--- a/htdocs/contrat/agenda.php
+++ b/htdocs/contrat/agenda.php
@@ -41,7 +41,7 @@ if (GETPOST('actioncode', 'array')) {
$actioncode = '0';
}
} else {
- $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
+ $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
}
$search_agenda_label = GETPOST('search_agenda_label');
@@ -54,7 +54,11 @@ $ref = GETPOST('ref', 'alpha');
if ($user->socid) {
$socid = $user->socid;
}
-$result = restrictedArea($user, 'contrat', $id, '');
+
+// Security check
+$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
+$fieldtype = (!empty($id) ? 'rowid' : 'ref');
+$result = restrictedArea($user, 'contrat', $fieldvalue, '', '', '', $fieldtype);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
@@ -73,6 +77,13 @@ if (!$sortorder) {
$sortorder = 'DESC,DESC';
}
+
+$object = new Contrat($db);
+
+if ($id > 0 || !empty($ref)) {
+ $result = $object->fetch($id, $ref);
+}
+
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('agendacontract', 'globalcard'));
@@ -83,7 +94,7 @@ $permissiontoadd = $user->rights->contrat->creer; // Used by the include
* Actions
*/
-$parameters = array('id'=>$id);
+$parameters = array('id' => $id, 'ref' => $ref);
$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');
@@ -104,8 +115,6 @@ if (empty($reshook)) {
}
-
-
/*
* View
*/
@@ -116,7 +125,7 @@ if (isModEnabled('project')) {
$formproject = new FormProjets($db);
}
-if ($id > 0) {
+if ($object->id > 0) {
// Load object modContract
$module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis');
if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') {
@@ -130,8 +139,6 @@ if ($id > 0) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
- $object = new Contrat($db);
- $result = $object->fetch($id);
$object->fetch_thirdparty();
$title = $langs->trans("Agenda");
@@ -181,7 +188,7 @@ if ($id > 0) {
if ($action != 'classify') {
$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, '');
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
@@ -195,13 +202,13 @@ if ($id > 0) {
}
$morehtmlref .= '';
- dol_banner_tab($object, 'id', $linkback, 1, 'ref', 'none', $morehtmlref);
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
}
+ print '';
}
- //else print $langs->trans("NoSalesRepresentativeAffected");
- } else {
- print ' ';
+ print '
';
}
- print '';
- }
- // Date
- if (!empty($arrayfields['c.date_contrat']['checked'])) {
- print '
';
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- // Date creation
- if (!empty($arrayfields['c.datec']['checked'])) {
- print '
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Date lower end date
- if (!empty($arrayfields['lower_planned_end_date']['checked'])) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Ref
+ if (!empty($arrayfields['c.ref']['checked'])) {
+ print '
';
+ }
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (!empty($arrayfields['c.datec']['checked'])) {
+ print '
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+ // Date lower end date
+ if (!empty($arrayfields['lower_planned_end_date']['checked'])) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
\n";
+
+
$contractstatic = new Contrat($db);
$productstatic = new Product($db);
$i = 0;
-$totalarray = array();
+$totalarray = array('nbfield'=>0, 'cd.qty'=>0, 'cd.total_ht'=>0, 'cd.total_tva'=>0);
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
@@ -774,6 +812,13 @@ while ($i < min($num, $limit)) {
if (!$i) {
$totalarray['nbfield']++;
}
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 'cd.qty';
+ }
+ if (!$i) {
+ $totalarray['val']['cd.qty'] = $obj->qty;
+ }
+ $totalarray['val']['cd.qty'] += $obj->qty;
}
if (!empty($arrayfields['cd.total_ht']['checked'])) {
print '
';
@@ -912,6 +957,17 @@ while ($i < min($num, $limit)) {
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+// If no record found
+if ($num == 0) {
+ $colspan = 1;
+ foreach ($arrayfields as $key => $val) {
+ if (!empty($val['checked'])) {
+ $colspan++;
+ }
+ }
+ print '
';
-
- return $return;
- }
-
/**
* Return full address of contact
*
@@ -979,27 +961,6 @@ abstract class CommonObject
}
$outdone++;
}
- } else { // Old code to remove
- if (!empty($this->skype)) {
- $outsocialnetwork .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype');
- }
- $outdone++;
- if (!empty($this->jabberid)) {
- $outsocialnetwork .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber');
- }
- $outdone++;
- if (!empty($this->twitter)) {
- $outsocialnetwork .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter');
- }
- $outdone++;
- if (!empty($this->facebook)) {
- $outsocialnetwork .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook');
- }
- $outdone++;
- if (!empty($this->linkedin)) {
- $outsocialnetwork .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin');
- }
- $outdone++;
}
if ($outsocialnetwork) {
@@ -1309,11 +1270,11 @@ abstract class CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Delete all links between an object $this and all its contacts
+ * Delete all links between an object $this and all its contacts in llx_element_contact
*
* @param string $source '' or 'internal' or 'external'
* @param string $code Type of contact (code or id)
- * @return int >0 if OK, <0 if KO
+ * @return int <0 if KO, 0=Nothing done, >0 if OK
*/
public function delete_linked_contact($source = '', $code = '')
{
@@ -1329,11 +1290,15 @@ abstract class CommonObject
$listId = implode(",", $temp);
}
+ // If $listId is empty, we have not criteria on fk_c_type_contact so we will delete record on element_id for
+ // any type or record instead of only the ones of the current object. So we do nothing in such a case.
+ if (empty($listId)) {
+ return 0;
+ }
+
$sql = "DELETE FROM ".$this->db->prefix()."element_contact";
$sql .= " WHERE element_id = ".((int) $this->id);
- if (!empty($listId)) {
- $sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")";
- }
+ $sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")";
dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG);
if ($this->db->query($sql)) {
@@ -1415,6 +1380,7 @@ abstract class CommonObject
$transkey = "TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$i] = array(
+ 'parentId' => $this->id,
'source' => $obj->source,
'socid' => $obj->socid,
'id' => $obj->id,
@@ -2072,7 +2038,7 @@ abstract class CommonObject
$sql .= " WHERE ".$id_field." = ".((int) $id);
- dol_syslog(__METHOD__."", LOG_DEBUG);
+ dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if ($trigkey) {
@@ -3338,6 +3304,8 @@ abstract class CommonObject
$row = $this->db->fetch_row($resql);
return $row[0];
}
+
+ return 0;
}
/**
@@ -3361,6 +3329,8 @@ abstract class CommonObject
$row = $this->db->fetch_row($resql);
return $row[0];
}
+
+ return 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -3406,6 +3376,8 @@ abstract class CommonObject
return $row[0];
}
}
+
+ return 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -3796,7 +3768,7 @@ abstract class CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Add objects linked in llx_element_element.
+ * Add an object link into llx_element_element.
*
* @param string $origin Linked element type
* @param int $origin_id Linked element id
@@ -4118,6 +4090,21 @@ abstract class CommonObject
}
}
+ /**
+ * Clear the cache saying that all linked object were already loaded. So next fetchObjectLinked will reload all links.
+ *
+ * @return int <0 if KO, >0 if OK
+ * @see fetchObjectLinked()
+ */
+ public function clearObjectLinkedCache()
+ {
+ if ($this->id > 0 && !empty($this->linkedObjectsFullLoaded[$this->id])) {
+ unset($this->linkedObjectsFullLoaded[$this->id]);
+ }
+
+ return 1;
+ }
+
/**
* Update object linked of a current object
*
@@ -4518,6 +4505,8 @@ abstract class CommonObject
$row = $this->db->fetch_row($resql);
return $row[0];
}
+
+ return 0;
}
/**
@@ -5100,7 +5089,7 @@ abstract class CommonObject
print '
'.$langs->trans('PriceUHTCurrency').'
';
}
print '
'.$langs->trans('Qty').'
';
- if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+ if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '
'.$langs->trans('Unit').'
';
}
print '
'.$langs->trans('ReductionShort').'
';
@@ -5238,7 +5227,7 @@ abstract class CommonObject
$this->tpl['total_ht'] = price($line->total_ht);
$this->tpl['multicurrency_price'] = price($line->multicurrency_subprice);
$this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' ';
- if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+ if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long'));
}
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' ';
@@ -5717,15 +5706,16 @@ abstract class CommonObject
*
* @param string $fieldname Name of field
* @param string $alternatevalue Alternate value to use
+ * @param string $type Type of data
* @return string|string[] Default value (can be an array if the GETPOST return an array)
**/
- public function getDefaultCreateValueFor($fieldname, $alternatevalue = null)
+ public function getDefaultCreateValueFor($fieldname, $alternatevalue = null, $type = 'alphanohtml')
{
global $conf, $_POST;
// If param here has been posted, we use this value first.
if (GETPOSTISSET($fieldname)) {
- return GETPOST($fieldname, 'alphanohtml', 3);
+ return GETPOST($fieldname, $type, 3);
}
if (isset($alternatevalue)) {
@@ -5751,6 +5741,9 @@ abstract class CommonObject
}
// TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname
+ // store content into $conf->cache['overwrite_default']
+
+ return '';
}
@@ -6442,9 +6435,9 @@ abstract class CommonObject
return -1;
} elseif ($value == '') {
$new_array_languages[$key] = null;
+ } else {
+ $new_array_languages[$key] = $value;
}
- //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG);
- $new_array_languages[$key] = $value;
break;
/*case 'select': // Not required, we chosed value='0' for undefined values
if ($value=='-1')
@@ -7807,7 +7800,7 @@ abstract class CommonObject
* clear validation message result for a field
*
* @param string $fieldKey Key of attribute to clear
- * @return null
+ * @return void
*/
public function clearFieldError($fieldKey)
{
@@ -7820,12 +7813,14 @@ abstract class CommonObject
*
* @param string $fieldKey Key of attribute
* @param string $msg the field error message
- * @return null
+ * @return void
*/
public function setFieldError($fieldKey, $msg = '')
{
global $langs;
- if (empty($msg)) { $msg = $langs->trans("UnknowError"); }
+ if (empty($msg)) {
+ $msg = $langs->trans("UnknowError");
+ }
$this->error = $this->validateFieldsErrors[$fieldKey] = $msg;
}
@@ -7847,30 +7842,34 @@ abstract class CommonObject
/**
* Return validation test result for a field
*
- * @param array $val Array of properties of field to show
+ * @param array $fields Array of properties of field to show
* @param string $fieldKey Key of attribute
* @param string $fieldValue value of attribute
* @return bool return false if fail true on success, see $this->error for error message
*/
- public function validateField($val, $fieldKey, $fieldValue)
+ public function validateField($fields, $fieldKey, $fieldValue)
{
global $langs;
- if (!class_exists('Validate')) { require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php'; }
+ if (!class_exists('Validate')) {
+ require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php';
+ }
$this->clearFieldError($fieldKey);
- if (!isset($val[$fieldKey])) {
+ if (!isset($fields[$fieldKey])) {
$this->setFieldError($fieldKey, $langs->trans('FieldNotFoundInObject'));
return false;
}
+ $val = $fields[$fieldKey];
+
$param = array();
$param['options'] = array();
- $type = $val[$fieldKey]['type'];
+ $type = $val['type'];
$required = false;
- if (isset($val[$fieldKey]['notnull']) && $val[$fieldKey]['notnull'] === 1) {
+ if (isset($val['notnull']) && $val['notnull'] === 1) {
// 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
$required = true;
}
@@ -7881,6 +7880,7 @@ abstract class CommonObject
//
// PREPARE Elements
//
+ $reg = array();
// Convert var to be able to share same code than showOutputField of extrafields
if (preg_match('/varchar\((\d+)\)/', $type, $reg)) {
@@ -7894,7 +7894,7 @@ abstract class CommonObject
$type = 'select';
}
- if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) {
+ if (!empty($val['type']) && preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) {
$type = 'link';
}
@@ -8431,19 +8431,19 @@ abstract class CommonObject
* This function is meant to be called from replaceThirdparty with the appropriate tables
* Column name fk_soc MUST be used to identify thirdparties
*
- * @param DoliDB $db Database handler
+ * @param DoliDB $dbs Database handler
* @param int $origin_id Old thirdparty id (the thirdparty to delete)
* @param int $dest_id New thirdparty id (the thirdparty that will received element of the other)
* @param string[] $tables Tables that need to be changed
* @param int $ignoreerrors Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old thirdparty may already exists on new one)
* @return bool True if success, False if error
*/
- public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0)
+ public static function commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0)
{
foreach ($tables as $table) {
- $sql = 'UPDATE '.$db->prefix().$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id);
+ $sql = 'UPDATE '.$dbs->prefix().$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id);
- if (!$db->query($sql)) {
+ if (!$dbs->query($sql)) {
if ($ignoreerrors) {
return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B.
}
@@ -8460,19 +8460,19 @@ abstract class CommonObject
* This function is meant to be called from replaceProduct with the appropriate tables
* Column name fk_product MUST be used to identify products
*
- * @param DoliDB $db Database handler
+ * @param DoliDB $dbs Database handler
* @param int $origin_id Old product id (the product to delete)
* @param int $dest_id New product id (the product that will received element of the other)
* @param string[] $tables Tables that need to be changed
* @param int $ignoreerrors Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old product may already exists on new one)
* @return bool True if success, False if error
*/
- public static function commonReplaceProduct(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0)
+ public static function commonReplaceProduct(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0)
{
foreach ($tables as $table) {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_product = '.((int) $dest_id).' WHERE fk_product = '.((int) $origin_id);
- if (!$db->query($sql)) {
+ if (!$dbs->query($sql)) {
if ($ignoreerrors) {
return true; // TODO Not enough. If there is A-B on kept product and B-C on old one, we must get A-B-C after merge. Not A-B.
}
@@ -8553,21 +8553,21 @@ abstract class CommonObject
/**
* Show photos of an object (nbmax maximum), into several columns
*
- * @param string $modulepart 'product', 'ticket', ...
- * @param string $sdir Directory to scan (full absolute path)
- * @param int $size 0=original size, 1='small' use thumbnail if possible
- * @param int $nbmax Nombre maximum de photos (0=pas de max)
- * @param int $nbbyrow Number of image per line or -1 to use div separator or 0 to use no separator. Used only if size=1 or 'small'.
- * @param int $showfilename 1=Show filename
- * @param int $showaction 1=Show icon with action links (resize, delete)
- * @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image.
- * @param int $maxWidth Max width of original image when size='small'
- * @param int $nolink Do not add a href link to view enlarged imaged into a new tab
- * @param int $notitle Do not add title tag on image
- * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead)
- * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto
+ * @param string $modulepart 'product', 'ticket', ...
+ * @param string $sdir Directory to scan (full absolute path)
+ * @param int $size 0=original size, 1='small' use thumbnail if possible
+ * @param int $nbmax Nombre maximum de photos (0=pas de max)
+ * @param int $nbbyrow Number of image per line or -1 to use div separator or 0 to use no separator. Used only if size=1 or 'small'.
+ * @param int $showfilename 1=Show filename
+ * @param int $showaction 1=Show icon with action links (resize, delete)
+ * @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image.
+ * @param int $maxWidth Max width of original image when size='small'
+ * @param int $nolink Do not add a href link to view enlarged imaged into a new tab
+ * @param int|string $overwritetitle Do not add title tag on image
+ * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead)
+ * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto
*/
- public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0)
+ public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $overwritetitle = 0, $usesharelink = 0)
{
// phpcs:enable
global $conf, $user, $langs;
@@ -8635,7 +8635,10 @@ abstract class CommonObject
// Find name of thumb file
$photo_vignette = basename(getImageFileNameForSize($dir.$file, '_small'));
if (!dol_is_file($dirthumb.$photo_vignette)) {
- $photo_vignette = '';
+ // The thumb does not exists, so we will use the original file
+ $dirthumb = $dir;
+ $pdirthumb = $pdir;
+ $photo_vignette = basename($file);
}
// Get filesize of original file
@@ -8670,8 +8673,12 @@ abstract class CommonObject
// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
$alt = $langs->transnoentitiesnoconv('File').': '.$relativefile;
$alt .= ' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
- if ($notitle) {
- $alt = '';
+ if ($overwritetitle) {
+ if (is_numeric($overwritetitle)) {
+ $alt = '';
+ } else {
+ $alt = $overwritetitle;
+ }
}
$addphotorefcss = 1;
@@ -9316,7 +9323,7 @@ abstract class CommonObject
$sql .= ' WHERE 1 = 1'; // usage with empty id and empty ref is very rare
}
if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
- $sql .= ' AND t.entity IN ('.getEntity($this->table_element).')';
+ $sql .= ' AND t.entity IN ('.getEntity($this->element).')';
}
if ($morewhere) {
$sql .= $morewhere;
@@ -9600,6 +9607,12 @@ abstract class CommonObject
}
}
+ // Delete linked object
+ $res = $this->deleteObjectLinked();
+ if ($res < 0) {
+ $error++;
+ }
+
if (!$error && !empty($this->isextrafieldmanaged)) {
$result = $this->deleteExtraFields();
if ($result < 0) {
@@ -9723,23 +9736,24 @@ abstract class CommonObject
$tmpforobjectclass = get_class($this);
$tmpforobjectlineclass = ucfirst($tmpforobjectclass).'Line';
+ $this->db->begin();
+
// Call trigger
$result = $this->call_trigger('LINE'.strtoupper($tmpforobjectclass).'_DELETE', $user);
if ($result < 0) {
- return -1;
+ $error++;
}
// End call triggers
- $this->db->begin();
+ if (empty($error)) {
+ $sql = "DELETE FROM ".$this->db->prefix().$this->table_element_line;
+ $sql .= " WHERE rowid = ".((int) $idline);
- $sql = "DELETE FROM ".$this->db->prefix().$this->table_element_line;
- $sql .= " WHERE rowid = ".((int) $idline);
-
- dol_syslog(get_class($this)."::deleteLineCommon", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql) {
- $this->error = "Error ".$this->db->lasterror();
- $error++;
+ $resql = $this->db->query($sql);
+ if (!$resql) {
+ $this->error = "Error ".$this->db->lasterror();
+ $error++;
+ }
}
if (empty($error)) {
@@ -9935,7 +9949,7 @@ abstract class CommonObject
* @param int[]|int $categories Category ID or array of Categories IDs
* @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...) definied into const class Categorie type
* @param boolean $remove_existing True: Remove existings categories from Object if not supplies by $categories, False: let them
- * @return int <0 if KO, >0 if OK
+ * @return int <0 if KO, >0 if OK
*/
public function setCategoriesCommon($categories, $type_categ = '', $remove_existing = true)
{
diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php
index 966d7963d7c..65ae367c3b2 100644
--- a/htdocs/core/class/commonorder.class.php
+++ b/htdocs/core/class/commonorder.class.php
@@ -32,6 +32,41 @@ abstract class CommonOrder extends CommonObject
{
use CommonIncoterm;
+
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
+ * @param array $arraydata Array of data
+ * @return string HTML Code for Kanban thumb.
+ */
+ public function getKanbanView($option = '', $arraydata = null)
+ {
+ global $langs, $conf;
+
+ $return = '
';
+ return $return;
+ }
+
/**
* @var string code
*/
diff --git a/htdocs/core/class/commonsocialnetworks.class.php b/htdocs/core/class/commonsocialnetworks.class.php
new file mode 100644
index 00000000000..4ec32194f3d
--- /dev/null
+++ b/htdocs/core/class/commonsocialnetworks.class.php
@@ -0,0 +1,108 @@
+
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/core/class/commonincoterm.class.php
+ * \ingroup core
+ * \brief File of the superclass of object classes that support incoterm (customer and supplier)
+ */
+
+
+/**
+ * Superclass for social networks
+ */
+trait CommonSocialNetworks
+{
+ /**
+ * @var array array of socialnetworks
+ */
+ public $socialnetworks;
+
+
+ /**
+ * Show social network part if the module is enabled with hiding functionality
+ *
+ * @param array $socialnetworks Array of social networks
+ * @param int $colspan Colspan
+ * @return void
+ */
+ public function showSocialNetwork($socialnetworks, $colspan = 4)
+ {
+ global $object, $form, $langs;
+
+ $nbofnetworks = count($socialnetworks);
+ $nbactive = 0;
+ foreach ($socialnetworks as $key => $value) {
+ if (!empty($object->socialnetworks[$key])) {
+ $nbactive++;
+ }
+ }
+
+ if ($nbofnetworks > 1) {
+ print '
global->PRODUCT_USE_UNITS)) {
+ if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$coldisplay++;
print '
';
print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units");
@@ -511,7 +513,7 @@ if ((isModEnabled("service") || ($object->element == 'contrat')) && $dateSelecto
print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0);
print ' '.$langs->trans('to').' ';
print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0);
- };
+ }
if ($prefillDates) {
echo ' '.$langs->trans('FillWithLastServiceDates').'';
@@ -774,8 +776,37 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
// Now set the VAT
var stringforvatrateselection = tva_tx;
- if (typeof default_vat_code != 'undefined' && default_vat_code != null) {
+ if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') {
stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')';
+
+ console.log("MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA is on so we check if we need to autoswith the vat code");
+ console.log("mysoc->country_code=country_code; ?> thirdparty->country_code=thirdparty->country_code; ?>");
+ new_default_vat_code = default_vat_code;
+ country_code == 'IN' && !empty($object->thirdparty) && $object->thirdparty->country_code == 'IN' && $mysoc->state_code == $object->thirdparty->state_code) {
+ // We are in India and states are same, we revert the vat code "I-x" into "CS-x"
+ ?>
+ console.log("Countries are both IN and states are same, so we revert I into CS in default_vat_code="+default_vat_code);
+ new_default_vat_code = default_vat_code.replace(/^I\-/, 'C+S-');
+ country_code == 'IN' && !empty($object->thirdparty) && $object->thirdparty->country_code == 'IN' && $mysoc->state_code != $object->thirdparty->state_code) {
+ // We are in India and states differs, we revert the vat code "CS-x" into "I-x"
+ ?>
+ console.log("Countries are both IN and states differs, so we revert CS into I in default_vat_code="+default_vat_code);
+ new_default_vat_code = default_vat_code.replace(/^C\+S\-/, 'I-');
+
+ if (new_default_vat_code != default_vat_code && jQuery('#tva_tx option:contains("'+new_default_vat_code+'")').val()) {
+ console.log("We found en entry into VAT with new default_vat_code, we will use it");
+ stringforvatrateselection = jQuery('#tva_tx option:contains("'+new_default_vat_code+'")').val();
+ }
+
}
// Set vat rate if field is an input box
$('#tva_tx').val(tva_tx);
@@ -937,7 +968,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
?>
global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
+ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
?>
/* To process customer price per quantity (PRODUIT_CUSTOMER_PRICES_BY_QTY works only if combo product is not an ajax after x key pressed) */
var pbq = parseInt($('option:selected', this).attr('data-pbq')); // When select is done from HTML select
@@ -996,7 +1027,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete
var stringforvatrateselection = tva_tx;
- if (typeof default_vat_code != 'undefined' && default_vat_code != null) {
+ if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') {
stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')';
}
@@ -1058,7 +1089,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete
var stringforvatrateselection = tva_tx;
- if (typeof default_vat_code != 'undefined' && default_vat_code != null) {
+ if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') {
stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')';
}
@@ -1113,7 +1144,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
});
- /* Function to set fields from choice */
+ /* Function to set fields visibility after selecting a free product */
function setforfree() {
console.log("objectline_create.tpl::setforfree. We show most fields");
jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product
@@ -1148,7 +1179,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
jQuery("#multicurrency_price_ttc").val('').hide();
jQuery("#title_up_ttc, #title_up_ttc_currency").hide();
- jQuery("#fourn_ref, #tva_tx, #title_vat").hide();
+ /* jQuery("#tva_tx, #title_vat").hide(); */
/* jQuery("#title_fourn_ref").hide(); */
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide();
jQuery("#buying_price").show();
diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php
index 5520215d89a..dbc8b407fa5 100644
--- a/htdocs/core/tpl/objectline_edit.tpl.php
+++ b/htdocs/core/tpl/objectline_edit.tpl.php
@@ -120,7 +120,7 @@ $coldisplay++;
print '';
} else {
if ($senderissupplier) {
- print $form->select_produits_fournisseurs(!empty($line->fk_product) ? $line->fk_product : 0, 'productid');
+ $form->select_produits_fournisseurs(!empty($line->fk_product) ? $line->fk_product : 0, 'productid');
} else {
print $form->select_produits(!empty($line->fk_product) ? $line->fk_product : 0, 'productid');
}
diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php
index 7fe63613ea1..4640d710705 100644
--- a/htdocs/core/tpl/objectline_title.tpl.php
+++ b/htdocs/core/tpl/objectline_title.tpl.php
@@ -71,7 +71,7 @@ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FA
if (in_array($object->element, array('propal', 'commande', 'facture', 'supplier_proposal', 'order_supplier', 'invoice_supplier')) && $object->status == $object::STATUS_DRAFT) {
global $mysoc;
- if (empty($disableedit)) {
+ if (empty($disableedit) && GETPOST('mode', 'aZ09') != 'vatforalllines') {
print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').'';
}
//print '';
@@ -111,7 +111,7 @@ print $langs->trans('ReductionShort');
if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) {
global $mysoc;
- if (empty($disableedit)) {
+ if (empty($disableedit) && GETPOST('mode', 'aZ09') != 'remiseforalllines') {
print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').'';
}
//print '';
diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php
index 14197b6d052..be24a555a3c 100644
--- a/htdocs/core/tpl/objectline_view.tpl.php
+++ b/htdocs/core/tpl/objectline_view.tpl.php
@@ -255,11 +255,48 @@ if (isModEnabled('accounting') && $line->fk_accounting_account > 0) {
}
print '
';
+// Vendor price ref
if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines
print '
';
$coldisplay++;
if (!$situationinvoicelinewithparent && empty($disableremove)) { // For situation invoice, deletion is not possible if there is a parent company.
@@ -452,6 +464,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin
}
print '
';
} elseif (!empty($object->mail) && empty($object->array_options['options_datapolicy_send']) && $parameters['currentcontext'] == 'membercard') {
diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php
index a4c98eba8a7..a0375210271 100644
--- a/htdocs/dav/dav.class.php
+++ b/htdocs/dav/dav.class.php
@@ -143,12 +143,14 @@ class CdavLib
$location = trim($location.', '.$obj->soc_country_label);
}
+ /*
$address = explode("\n", $obj->address, 2);
foreach ($address as $kAddr => $vAddr) {
$address[$kAddr] = trim(str_replace(array("\r", "\t"), ' ', str_replace("\n", ' | ', trim($vAddr))));
}
$address[] = '';
$address[] = '';
+ */
if ($obj->percent == -1 && trim($obj->datep) != '') {
$type = 'VEVENT';
@@ -249,7 +251,7 @@ class CdavLib
*/
public function getFullCalendarObjects($calendarId, $bCalendarData)
{
- $calid = ($calendarId * 1);
+ $calid = (int) $calendarId;
$calevents = array();
if (!$this->user->rights->agenda->myactions->read) {
diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php
index 7abe3f2bacf..af23fde5fff 100644
--- a/htdocs/dav/fileserver.php
+++ b/htdocs/dav/fileserver.php
@@ -92,8 +92,7 @@ $tmpDir = $conf->dav->multidir_output[$entity]; // We need root dir, not a dir t
// Authentication callback function
$authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $password) {
- global $user;
- global $conf;
+ global $user, $conf;
global $dolibarr_main_authentication, $dolibarr_auto_user;
if (empty($user->login)) {
@@ -101,7 +100,7 @@ $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $p
return false;
}
if ($user->socid > 0) {
- dol_syslog("Failed to authenticate to DAV, use is an external user", LOG_WARNING);
+ dol_syslog("Failed to authenticate to DAV, user is an external user", LOG_WARNING);
return false;
}
if ($user->login != $username) {
@@ -132,6 +131,27 @@ $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $p
return false;
}
+ // Check if user status is enabled
+ if ($user->statut != $user::STATUS_ENABLED) {
+ // Status is disabled
+ dol_syslog("The user has been disabled.");
+ return false;
+ }
+
+ // Check if session was unvalidated by a password change
+ if (($user->flagdelsessionsbefore && !empty($_SESSION["dol_logindate"]) && $user->flagdelsessionsbefore > $_SESSION["dol_logindate"])) {
+ // Session is no more valid
+ dol_syslog("The user has a date for session invalidation = ".$user->flagdelsessionsbefore." and a session date = ".$_SESSION["dol_logindate"].". We must invalidate its sessions.");
+ return false;
+ }
+
+ // Check date validity
+ if ($user->isNotIntoValidityDateRange()) {
+ // User validity dates are no more valid
+ dol_syslog("The user login has a validity between [".$user->datestartvalidity." and ".$user->dateendvalidity."], curren date is ".dol_now());
+ return false;
+ }
+
return true;
});
diff --git a/htdocs/debugbar/class/DataCollector/DolConfigCollector.php b/htdocs/debugbar/class/DataCollector/DolConfigCollector.php
index 715d20abcf9..0920b140dbc 100644
--- a/htdocs/debugbar/class/DataCollector/DolConfigCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolConfigCollector.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolConfigCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use \DebugBar\DataCollector\ConfigCollector;
diff --git a/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php b/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php
index 15d433fd050..38d2b971dde 100644
--- a/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolexceptionsCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use \DebugBar\DataCollector\ExceptionsCollector;
diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php
index d21cdd6233f..3d3b3b25a0e 100644
--- a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolLogsCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use DebugBar\DataCollector\MessagesCollector;
use Psr\Log\LogLevel;
@@ -20,6 +41,11 @@ class DolLogsCollector extends MessagesCollector
*/
protected $maxnboflines;
+ /**
+ * @var int number of lines
+ */
+ protected $nboflines;
+
/**
* Constructor
*
@@ -33,7 +59,7 @@ class DolLogsCollector extends MessagesCollector
parent::__construct($name);
$this->nboflines = 0;
- $this->maxnboflines = empty($conf->global->DEBUGBAR_LOGS_LINES_NUMBER) ? 250 : $conf->global->DEBUGBAR_LOGS_LINES_NUMBER; // High number slows seriously output
+ $this->maxnboflines = getDolGlobalInt('DEBUGBAR_LOGS_LINES_NUMBER', 250); // High number slows seriously output
$this->path = $path ?: $this->getLogsFile();
}
diff --git a/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php b/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php
index b52ac8ff8c4..3372e89c2b6 100644
--- a/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php
@@ -1,17 +1,37 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolMemoryCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use \DebugBar\DataCollector\MemoryCollector;
/**
* DolMemoryCollector class
*/
-
class DolMemoryCollector extends MemoryCollector
{
/**
* Return value of indicator
*
- * @return void
+ * @return array
*/
public function collect()
{
@@ -28,7 +48,7 @@ class DolMemoryCollector extends MemoryCollector
/**
* Return widget settings
*
- * @return void
+ * @return array
*/
public function getWidgets()
{
diff --git a/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php b/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php
index 1fcf60c8ba6..733009e77c6 100644
--- a/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolMessagesCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use \DebugBar\DataCollector\MessagesCollector;
diff --git a/htdocs/debugbar/class/DataCollector/DolPhpCollector.php b/htdocs/debugbar/class/DataCollector/DolPhpCollector.php
index 3d6536bd258..bca2b2a7071 100644
--- a/htdocs/debugbar/class/DataCollector/DolPhpCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolPhpCollector.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolPhpCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
diff --git a/htdocs/debugbar/class/DataCollector/DolQueryCollector.php b/htdocs/debugbar/class/DataCollector/DolQueryCollector.php
index ca5aa284dd2..8cc55e34df9 100644
--- a/htdocs/debugbar/class/DataCollector/DolQueryCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolQueryCollector.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolQueryCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\DataCollector;
diff --git a/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php
index 938643802d5..4ddcac9af7c 100644
--- a/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use \DebugBar\DataCollector\RequestDataCollector;
diff --git a/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php b/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php
index ed5e979d539..d16622d329f 100644
--- a/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use \DebugBar\DataCollector\TimeDataCollector;
diff --git a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php
index 3193fe26176..11cedbe2b93 100644
--- a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/DolibarrCollector.php
+ * \brief Class for debugbar collection
+ * \ingroup debugbar
+ */
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\DataCollector;
diff --git a/htdocs/debugbar/class/DebugBar.php b/htdocs/debugbar/class/DebugBar.php
index b2ec0f17bf0..6181ad7cd60 100644
--- a/htdocs/debugbar/class/DebugBar.php
+++ b/htdocs/debugbar/class/DebugBar.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DebugBar.php
+ * \brief Class for debugbar
+ * \ingroup debugbar
+ */
dol_include_once('/debugbar/class/autoloader.php');
@@ -55,9 +76,10 @@ class DolibarrDebugBar extends DebugBar
public function getRenderer()
{
$renderer = parent::getJavascriptRenderer(DOL_URL_ROOT.'/includes/maximebf/debugbar/src/DebugBar/Resources');
- //$renderer->disableVendor('jquery');
- $renderer->disableVendor('fontawesome');
- $renderer->disableVendor('highlightjs');
+ $renderer->disableVendor('jquery'); // We already have jquery loaded globally by the main.inc.php
+ $renderer->disableVendor('fontawesome'); // We already have fontawesome loaded globally by the main.inc.php
+ $renderer->disableVendor('highlightjs'); // We don't need this
+ $renderer->setEnableJqueryNoConflict(false); // We don't need no conflict
return $renderer;
}
}
diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php
index a5f76f71aa7..8e28b0c59bd 100644
--- a/htdocs/debugbar/class/TraceableDB.php
+++ b/htdocs/debugbar/class/TraceableDB.php
@@ -1,4 +1,25 @@
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/debugbar/class/DataCollector/TraceableDB.php
+ * \brief Class for debugbar DB
+ * \ingroup debugbar
+ */
require_once DOL_DOCUMENT_ROOT.'/core/db/DoliDB.class.php';
@@ -649,7 +670,7 @@ class TraceableDB extends DoliDB
*/
public function free($resultset = null)
{
- return $this->db->free($resultset);
+ $this->db->free($resultset);
}
/**
diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php
index b98b75015ab..fe2aff8e4c3 100644
--- a/htdocs/delivery/card.php
+++ b/htdocs/delivery/card.php
@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (isModEnabled("product") || isModEnabled("service")) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
}
-if (!empty($conf->expedition_bon->enabled)) {
+if (isModEnabled('expedition_bon')) {
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
}
if (isModEnabled('stock')) {
@@ -338,7 +338,7 @@ if ($action == 'create') {
if ($action != 'classify') {
$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, '');
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
if (!empty($objectsrc->fk_project)) {
$proj = new Project($db);
diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php
index 73fc15e6911..3b560ce1026 100644
--- a/htdocs/delivery/class/delivery.class.php
+++ b/htdocs/delivery/class/delivery.class.php
@@ -1085,18 +1085,18 @@ class Delivery extends CommonObject
/**
* Function used to replace a thirdparty id with another one.
*
- * @param DoliDB $db Database handler
- * @param int $origin_id Old thirdparty id
- * @param int $dest_id New thirdparty id
- * @return bool
+ * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
*/
- public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
{
$tables = array(
'delivery'
);
- return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
}
/**
diff --git a/htdocs/document.php b/htdocs/document.php
index 4f6652fafda..eccf49de0be 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -286,9 +286,10 @@ $hookmanager->initHooks(array('document'));
$parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'original_file' => $original_file,
'entity' => $entity, 'refname' => $refname, 'fullpath_original_file' => $fullpath_original_file,
'filename' => $filename, 'fullpath_original_file_osencoded' => $fullpath_original_file_osencoded);
-$reshook = $hookmanager->executeHooks('downloadDocument', $parameters); // Note that $action and $object may have been
+$object = new stdClass();
+$reshook = $hookmanager->executeHooks('downloadDocument', $parameters, $object, $action); // Note that $action and $object may have been
if ($reshook < 0) {
- $errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').join($separator, $hookmanager->errors) : '');
+ $errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').join(', ', $hookmanager->errors) : '');
dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : ".$errors);
print "ErrorDownloadDocumentHooks: ".$errors;
exit;
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index 459c892a1d9..a077c703fda 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -52,7 +52,7 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
-
+$socid = GETPOST('socid', 'int');
$amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT');
$donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
@@ -63,6 +63,13 @@ if ($id > 0 || $ref) {
$object->fetch($id, $ref);
}
+if (!empty($socid) && $socid > 0) {
+ $soc = new Societe($db);
+ if ($socid > 0) {
+ $soc->fetch($socid);
+ }
+}
+
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
@@ -729,7 +736,7 @@ if (!empty($id) && $action != 'edit') {
$morehtmlref .= '';
$morehtmlref .= '';
} else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
}
} else {
if (!empty($object->fk_project)) {
diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php
index b52e0974b9a..716e3728b57 100644
--- a/htdocs/don/class/don.class.php
+++ b/htdocs/don/class/don.class.php
@@ -206,7 +206,7 @@ class Don extends CommonObject
*/
public function initAsSpecimen()
{
- global $conf, $user, $langs;
+ global $conf;
$now = dol_now();
@@ -224,10 +224,10 @@ class Don extends CommonObject
$num_socs = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_socs) {
- $i++;
-
$row = $this->db->fetch_row($resql);
$socids[$i] = $row[0];
+
+ $i++;
}
}
@@ -237,7 +237,7 @@ class Don extends CommonObject
$this->specimen = 1;
$this->lastname = 'Doe';
$this->firstname = 'John';
- $this->socid = 1;
+ $this->socid = empty($socids[0]) ? 0 : $socids[0];
$this->date = $now;
$this->date_valid = $now;
$this->amount = 100.90;
@@ -772,7 +772,7 @@ class Don extends CommonObject
*/
public function setPaid($id, $modepayment = 0)
{
- $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2, paid = 1";
if ($modepayment) {
$sql .= ", fk_payment = ".((int) $modepayment);
}
@@ -782,6 +782,7 @@ class Don extends CommonObject
if ($resql) {
if ($this->db->affected_rows($resql)) {
$this->statut = 2;
+ $this->paid = 1;
return 1;
} else {
return 0;
@@ -1101,18 +1102,18 @@ class Don extends CommonObject
/**
* Function used to replace a thirdparty id with another one.
*
- * @param DoliDB $db Database handler
- * @param int $origin_id Old third-party id
- * @param int $dest_id New third-party id
- * @return bool
+ * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
*/
- public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
{
$tables = array(
'don'
);
- return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
}
/**
@@ -1141,4 +1142,40 @@ class Don extends CommonObject
return (float) $this->amount - $sum_amount;
}
}
+
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
+ * @param array $arraydata Array of data
+ * @return string HTML Code for Kanban thumb.
+ */
+ public function getKanbanView($option = '', $arraydata = null)
+ {
+ global $langs;
+
+ $return = '
'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0;
-if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
+if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
if (preg_match('/\$object/', $val)) {
$needToFetchEachLine++; // There is at least one compute field that use $object
@@ -819,8 +868,11 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a
// Loop on record
// --------------------------------------------------------------------
$i = 0;
+$savnbfield = $totalarray['nbfield'];
$totalarray = array();
-while ($i < ($limit ? min($num, $limit) : $num)) {
+$totalarray['nbfield'] = 0;
+$imaxinloop = ($limit ? min($num, $limit) : $num);
+while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
break; // Should not happen
@@ -829,76 +881,110 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
// Store properties in $object
$object->setVarsFromFetchObj($obj);
- // Show here line of result
- print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($object->id, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
print '
';
if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
+ $totalarray['nbfield']++;
}
- if (!isset($totalarray['val'])) {
- $totalarray['val'] = array();
+ if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
+ }
+ if (!isset($totalarray['val'])) {
+ $totalarray['val'] = array();
+ }
+ if (!isset($totalarray['val']['t.'.$key])) {
+ $totalarray['val']['t.'.$key] = 0;
+ }
+ $totalarray['val']['t.'.$key] += $object->$key;
}
- if (!isset($totalarray['val']['t.'.$key])) {
- $totalarray['val']['t.'.$key] = 0;
- }
- $totalarray['val']['t.'.$key] += $object->$key;
}
}
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- // Action column
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) {
- $selected = 1;
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Action column
+ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($object->id, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
}
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
-$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
+$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '
';
}
- // Get list of products already sent for same source object into $alreadysent
- $alreadysent = array();
- if ($origin && $origin_id > 0) {
- $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end";
- $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot";
- $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
- //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received";
- $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch';
- $sql .= ', p.description as product_desc';
- $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
- $sql .= ", ".MAIN_DB_PREFIX."expedition as e";
- $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj";
- //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
- $sql .= " WHERE e.entity IN (".getEntity('expedition').")";
- $sql .= " AND obj.fk_".$origin." = ".((int) $origin_id);
- $sql .= " AND obj.rowid = ed.fk_origin_line";
- $sql .= " AND ed.fk_expedition = e.rowid";
- //if ($filter) $sql.= $filter;
- $sql .= " ORDER BY obj.fk_product";
+ if (isModEnabled('productbatch')) {
+ print '
'.$langs->trans("Batch").'
';
+ }
+ }
+ print '
'.$langs->trans("CalculatedWeight").'
';
+ print '
'.$langs->trans("CalculatedVolume").'
';
+ //print '
'.$langs->trans("Size").'
';
+ if ($object->statut == 0) {
+ print '
';
+ print '
';
+ }
+ print "
\n";
+ print '';
- dol_syslog("expedition/card.php get list of shipment lines", LOG_DEBUG);
- $resql = $db->query($sql);
- if ($resql) {
- $num = $db->num_rows($resql);
- $i = 0;
+ $outputlangs = $langs;
- while ($i < $num) {
- $obj = $db->fetch_object($resql);
- if ($obj) {
- // $obj->rowid is rowid in $origin."det" table
- $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
- 'shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped,
- 'product_tosell'=>$obj->product_tosell, 'product_tobuy'=>$obj->product_tobuy, 'product_tobatch'=>$obj->product_tobatch,
- 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery));
- }
- $i++;
+ if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
+ $object->fetch_thirdparty();
+ $newlang = '';
+ if (empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if (empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+ }
+
+ // Get list of products already sent for same source object into $alreadysent
+ $alreadysent = array();
+ if ($origin && $origin_id > 0) {
+ $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end";
+ $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot";
+ $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
+ //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received";
+ $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch';
+ $sql .= ', p.description as product_desc';
+ $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
+ $sql .= ", ".MAIN_DB_PREFIX."expedition as e";
+ $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj";
+ //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
+ $sql .= " WHERE e.entity IN (".getEntity('expedition').")";
+ $sql .= " AND obj.fk_".$origin." = ".((int) $origin_id);
+ $sql .= " AND obj.rowid = ed.fk_origin_line";
+ $sql .= " AND ed.fk_expedition = e.rowid";
+ //if ($filter) $sql.= $filter;
+ $sql .= " ORDER BY obj.fk_product";
+
+ dol_syslog("expedition/card.php get list of shipment lines", LOG_DEBUG);
+ $resql = $db->query($sql);
+ if ($resql) {
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ while ($i < $num) {
+ $obj = $db->fetch_object($resql);
+ if ($obj) {
+ // $obj->rowid is rowid in $origin."det" table
+ $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
+ 'shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped,
+ 'product_tosell'=>$obj->product_tosell, 'product_tobuy'=>$obj->product_tobuy, 'product_tobatch'=>$obj->product_tobatch,
+ 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery));
}
+ $i++;
}
- //var_dump($alreadysent);
+ }
+ //var_dump($alreadysent);
+ }
+
+ print '';
+
+ // Loop on each product to send/sent
+ for ($i = 0; $i < $num_prod; $i++) {
+ $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs);
+ $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
+ if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
- print '';
+ if (empty($reshook)) {
+ print ''; // id of order line
+ print '
';
- if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
- print '';
- $line = new ExpeditionLigne($db);
- foreach ($lines[$i]->detail_batch as $detail_batch) {
- print '
';
- // Qty to ship or shipped
- print '
';
- // Batch number managment
- if ($lines[$i]->entrepot_id == 0) {
- // only show lot numbers from src warehouse when shipping from multiple warehouses
- $line->fetch($detail_batch->fk_expeditiondet);
- }
- $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id;
- print '
';
+ if ($lines[$i]->entrepot_id == 0) {
+ // only show lot numbers from src warehouse when shipping from multiple warehouses
+ $line->fetch($detail_batch->fk_expeditiondet);
+ }
+ $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id;
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Action column
+ if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
- print '';
- }
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Ref
+ if (!empty($arrayfields['e.ref']['checked'])) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Output Kanban
+ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ if ($massactionbutton || $massaction) {
+ $selected = 0;
+
+ print $expensereportstatic->getKanbanView('');
}
- print '';
}
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ } else {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
- print '';
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
- }
- print '';
+ //mode kanban
+ if ($mode == 'kanban') {
+ if ($i == 0) {
+ print '
';
+ print '
';
}
- print '
';
- }
- if (!empty($arrayfields['f.ref']['checked'])) {
- print "
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
print '
';
}
+ if (!empty($arrayfields['f.ref']['checked'])) {
+ print "
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
print '
';
}
if (!$i) {
$totalarray['nbfield']++;
}
- }
- if (!empty($arrayfields['f.description']['checked'])) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
- }
- print '';
- }
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
- }
- print '';
+ if ($mode == 'kanban') {
+ if ($i == 0) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
}
- }
- // Town
- if (!empty($arrayfields['s.town']['checked'])) {
- print '
';
- print $obj->town;
- print '
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Zip
- if (!empty($arrayfields['s.zip']['checked'])) {
- print '
';
- print $obj->zip;
- print '
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // State
- if (!empty($arrayfields['state.nom']['checked'])) {
- print "
".$obj->state_name."
\n";
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Country
- if (!empty($arrayfields['country.code_iso']['checked'])) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) {
- $selected = 1;
+ // Project
+ if (!empty($arrayfields['cf.fk_projet']['checked'])) {
+ $projectstatic->id = $obj->project_id;
+ $projectstatic->ref = $obj->project_ref;
+ $projectstatic->title = $obj->project_title;
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->facid, $arrayofselected)) {
- $selected = 1;
+ if ($mode == 'kanban') {
+ if ($i == 0) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->facid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
}
- print '';
+ print '
'; // TODO Use a denormalized field
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
-
- // Pending amount
- if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
- print '
'; // TODO Use a denormalized field
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
-
-
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
-
- // Date creation
- if (!empty($arrayfields['f.datec']['checked'])) {
- print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->facid, $arrayofselected)) {
- $selected = 1;
+ print "
'; // TODO Use a denormalized field
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+
+ // Pending amount
+ if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
+ print '
'; // TODO Use a denormalized field
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+
+
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
+ // Date creation
+ if (!empty($arrayfields['f.datec']['checked'])) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->facid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates
+ $totalduration += $nbopenedday;
+
+ if ($mode == 'kanban') {
+ if ($i == 0) {
+ print '
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Date validation
- if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval
- print '
';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
-
- // Date creation
- if (!empty($arrayfields['cp.date_create']['checked'])) {
- print '
'.dol_print_date($date, 'dayhour').'
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- if (!empty($arrayfields['cp.tms']['checked'])) {
- print '
'.dol_print_date($date_modif, 'dayhour').'
';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- if (!empty($arrayfields['cp.statut']['checked'])) {
- print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
+ }
+ if (!empty($arrayfields['cp.ref']['checked'])) {
+ print '
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+ // Date validation
+ if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval
+ print '
';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
+ // Date creation
+ if (!empty($arrayfields['cp.date_create']['checked'])) {
+ print '
'.dol_print_date($date, 'dayhour').'
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+ if (!empty($arrayfields['cp.tms']['checked'])) {
+ print '
'.dol_print_date($date_modif, 'dayhour').'
';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+ if (!empty($arrayfields['cp.statut']['checked'])) {
+ print '
';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) {
+ $selected = 1;
+ }
+ print '';
+ }
+ print '
';
+ }
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+
+ print ''."\n";
+ }
$i++;
}
// Add a line for total if there is a total to show
if (!empty($arrayfields['duration']['checked'])) {
print '
';
+ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ print '
';
+ }
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
if ($key == 'duration') {
@@ -964,7 +1012,9 @@ if ($resql) {
}
}
// status
- print '
';
+ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
+ print '
';
+ return $return;
+ }
}
diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php
index f9bbde51912..50d2fac8821 100644
--- a/htdocs/hrm/class/evaluationdet.class.php
+++ b/htdocs/hrm/class/evaluationdet.class.php
@@ -373,7 +373,7 @@ class Evaluationline extends CommonObject
$sql .= $this->getFieldList('t');
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
- $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
+ $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
} else {
$sql .= ' WHERE 1 = 1';
}
@@ -561,7 +561,8 @@ class Evaluationline extends CommonObject
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'evaluationline/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->error = $this->db->lasterror();
+ $error++;
+ $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
@@ -891,8 +892,8 @@ class Evaluationline extends CommonObject
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_evaluationdet = '.$this->id));
if (is_numeric($result)) {
- $this->error = $this->error;
- $this->errors = $this->errors;
+ $this->error = $objectline->error;
+ $this->errors = $objectline->errors;
return $result;
} else {
$this->lines = $result;
diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php
index 117878c10c9..b0a1d263b65 100644
--- a/htdocs/hrm/class/job.class.php
+++ b/htdocs/hrm/class/job.class.php
@@ -374,7 +374,7 @@ class Job extends CommonObject
$sql .= $this->getFieldList('t');
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
- $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
+ $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
} else {
$sql .= ' WHERE 1 = 1';
}
@@ -600,30 +600,27 @@ class Job extends CommonObject
}
/**
- * Get last job for user
+ * Get the last occupied position for a user
*
- * @param int $fk_user id of user we need to get last job
- * @return mixed|string|null
+ * @param int $fk_user Id of user we need to get last job
+ * @return Position|string Last occupied position
*/
public function getLastJobForUser($fk_user)
{
- global $db;
-
- $j = new Job($db);
- $Tab = $j->getForUser($fk_user);
+ $Tab = $this->getForUser($fk_user);
if (empty($Tab)) return '';
- $job = array_shift($Tab);
+ $lastpos = array_shift($Tab);
- return $job;
+ return $lastpos;
}
/**
- * Get jobs for user
+ * Get array of occupied positions for a user
*
- * @param int $userid id of user we need to get job list
- * @return array of jobs
+ * @param int $userid Id of user we need to get job list
+ * @return Position[] Array of occupied positions
*/
public function getForUser($userid)
{
@@ -925,8 +922,8 @@ class Job extends CommonObject
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_job = '.$this->id));
if (is_numeric($result)) {
- $this->error = $this->error;
- $this->errors = $this->errors;
+ $this->error = $objectline->error;
+ $this->errors = $objectline->errors;
return $result;
} else {
$this->lines = $result;
@@ -1057,6 +1054,39 @@ class Job extends CommonObject
return $error;
}
+
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
+ * @param array $arraydata Array of data
+ * @return string HTML Code for Kanban thumb.
+ */
+ public function getKanbanView($option = '', $arraydata = null)
+ {
+ global $selected, $langs;
+
+ $return = '