';
// Ref customer
- $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1);
- $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', null, null, '', 1);
+ $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer');
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (
'.$langs->trans("OtherProposals").' )';
@@ -1847,7 +1856,7 @@ if ($action == 'create')
{
$langs->load("projects");
$morehtmlref.='
'.$langs->trans('Project') . ' ';
- if ($user->rights->propal->creer)
+ if ($usercancreate)
{
if ($action != 'classify')
$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
@@ -1915,11 +1924,11 @@ if ($action == 'create')
print '
';
print '
';
- if (! empty($object->brouillon) && $action == 'editdate') {
+ if (! empty($object->brouillon) && $action == 'editdate' && $usercancreate) {
print ' ';
- if (! empty($object->brouillon) && $action == 'editecheance') {
+ if (! empty($object->brouillon) && $action == 'editecheance' && $usercancreate) {
print ' ';
- if ($action == 'editconditions') {
+ if (! empty($object->brouillon) && $action == 'editconditions' && $usercancreate) {
$form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id');
} else {
$form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none');
@@ -1984,9 +1993,9 @@ if ($action == 'create')
// Delivery date
$langs->load('deliveries');
print ' ';
- print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $user->rights->propal->creer, 'datepicker');
+ print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $usercancreate, 'datepicker');
print ' ';
- print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $user->rights->propal->creer, 'datepicker');
+ print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $usercancreate, 'datepicker');
print ' ';
print '';
@@ -1997,11 +2006,11 @@ if ($action == 'create')
if (! empty($conf->commande->enabled))
print ' (' . $langs->trans('AfterOrder') . ')';
print '';
- if ($action != 'editavailability' && ! empty($object->brouillon))
+ if ($action != 'editavailability' && ! empty($object->brouillon) && $usercancreate)
print '
id . '">' . img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1) . ' ';
print '';
print '
';
- if ($action == 'editavailability') {
+ if (! empty($object->brouillon) && $action == 'editavailability' && $usercancreate) {
$form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1);
} else {
$form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1);
@@ -2016,11 +2025,11 @@ if ($action == 'create')
print '';
print ' ';
- if ($action == 'editshippingmethod') {
+ if ($action == 'editshippingmethod' && $usercancreate) {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
@@ -2034,11 +2043,11 @@ if ($action == 'create')
print '';
print ' ';
- if ($action == 'editdemandreason') {
+ if (! empty($object->brouillon) && $action == 'editdemandreason' && $usercancreate) {
$form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1);
} else {
$form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none');
@@ -2052,11 +2061,11 @@ if ($action == 'create')
print '';
print ' ';
- if ($action == 'editmode') {
+ if (! empty($object->brouillon) && $action == 'editmode' && $usercancreate) {
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
@@ -2072,11 +2081,11 @@ if ($action == 'create')
print '';
print ' ';
- if ($action == 'editmulticurrencycode') {
+ if (! empty($object->brouillon) && $action == 'editmulticurrencycode' && $usercancreate) {
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code');
} else {
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
@@ -2089,11 +2098,11 @@ if ($action == 'create')
print '';
print fieldLabel('CurrencyRate','multicurrency_tx');
print ' ';
- if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency)
+ if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate)
print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ' ';
print '
';
print ' ';
- if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
+ if (! empty($object->brouillon) && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) {
if($action == 'actualizemulticurrencyrate') {
list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
}
@@ -2128,7 +2137,7 @@ if ($action == 'create')
print '';
print ' ';
@@ -2164,7 +2173,7 @@ if ($action == 'create')
print '';
print $langs->trans('IncotermLabel');
print ' ';
- if ($user->rights->propal->creer) print ''.img_edit().' ';
+ if ($usercancreate) print ''.img_edit().' ';
else print ' ';
print '
';
print ' ';
@@ -2293,7 +2302,7 @@ if ($action == 'create')
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
// Form to add new line
- if ($object->statut == Propal::STATUS_DRAFT && $user->rights->propal->creer && $action != 'selectlines')
+ if ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines')
{
if ($action != 'editline')
{
@@ -2328,8 +2337,7 @@ if ($action == 'create')
// Validate
if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0)
{
- if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
+ if ($usercanvalidate)
{
print '
';
}
@@ -2342,19 +2350,19 @@ if ($action == 'create')
print '
';
}*/
// Edit
- if ($object->statut == Propal::STATUS_VALIDATED && $user->rights->propal->creer) {
+ if ($object->statut == Propal::STATUS_VALIDATED && $usercancreate) {
print '
';
}
// ReOpen
- if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $user->rights->propal->cloturer) {
+ if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $usercanclose) {
print '
';
}
// Send
if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED) {
- if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) {
+ if ($usercansend) {
print '
';
} else
print '
';
@@ -2362,14 +2370,14 @@ if ($action == 'create')
// Create an order
if (! empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) {
- if ($user->rights->commande->creer) {
+ if ($usercancreateorder) {
print '
';
}
}
// Create an intervention
if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) {
- if ($user->rights->ficheinter->creer) {
+ if ($usercancreateintervention) {
$langs->load("interventions");
print '
';
}
@@ -2379,7 +2387,7 @@ if ($action == 'create')
if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) {
$langs->load("contracts");
- if ($user->rights->contrat->creer) {
+ if ($usercancreatecontract) {
print '
';
}
}
@@ -2387,7 +2395,7 @@ if ($action == 'create')
// Create an invoice and classify billed
if ($object->statut == Propal::STATUS_SIGNED)
{
- if (! empty($conf->facture->enabled) && $user->rights->facture->creer)
+ if (! empty($conf->facture->enabled) && $usercancreateinvoice)
{
print '
';
}
@@ -2400,18 +2408,18 @@ if ($action == 'create')
}
// Set accepted/refused
- if ($object->statut == Propal::STATUS_VALIDATED && $user->rights->propal->cloturer) {
+ if ($object->statut == Propal::STATUS_VALIDATED && $usercanclose) {
print '
';
}
// Clone
- if ($user->rights->propal->creer) {
+ if ($usercancreate) {
print '
';
}
// Delete
- if ($user->rights->propal->supprimer) {
+ if ($usercandelete) {
print '
';
}
@@ -2434,8 +2442,8 @@ if ($action == 'create')
$filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
- $genallowed = $user->rights->propal->lire;
- $delallowed = $user->rights->propal->creer;
+ $genallowed = $usercanread;
+ $delallowed = $usercancreate;
print $formfile->showdocuments('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object);
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 703ed95a1b2..562032de9fa 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1328,15 +1328,19 @@ class Propal extends CommonObject
$sql.= ", dr.code as demand_reason_code, dr.label as demand_reason";
$sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc";
$sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement";
- $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p";
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid';
+ $sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_propalst as c ON p.fk_statut = c.id';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity IN ('.getEntity('c_paiement').')';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity IN ('.getEntity('c_payment_term').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';
$sql.= " WHERE p.fk_statut = c.id";
- $sql.= " AND p.entity IN (".getEntity('propal').")";
- if ($ref) $sql.= " AND p.ref='".$ref."'";
+
+ if ($ref) {
+ $sql.= " AND p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid
+ $sql.= " AND p.ref='".$ref."'";
+ }
else $sql.= " AND p.rowid=".$rowid;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@@ -3347,12 +3351,19 @@ class Propal extends CommonObject
global $conf,$langs;
$langs->load("propal");
- if (! empty($conf->global->PROPALE_ADDON))
+ $constant = 'PROPALE_ADDON_'.$this->entity;
+
+ if (! empty($conf->global->$constant)) {
+ $classname = $conf->global->$constant; // for multicompany proposal sharing
+ } else {
+ $classname = $conf->global->PROPALE_ADDON;
+ }
+
+ if (! empty($classname))
{
$mybool=false;
- $file = $conf->global->PROPALE_ADDON.".php";
- $classname = $conf->global->PROPALE_ADDON;
+ $file = $classname.".php";
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index b0cea3318cb..0fe49cf9f12 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1858,13 +1858,14 @@ if ($action == 'create' && $user->rights->commande->creer)
$langs->load("stocks");
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value'
- // => 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"),
- // 'value' => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockDecrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1)));
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockDecrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse','int')?GETPOST('idwarehouse','int'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
+ );
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220);
@@ -1890,13 +1891,14 @@ if ($action == 'create' && $user->rights->commande->creer)
$langs->load("stocks");
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value'
- // => 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"),
- // 'value' => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1)));
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
+ );
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220);
@@ -1931,13 +1933,14 @@ if ($action == 'create' && $user->rights->commande->creer)
$langs->load("stocks");
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value'
- // => 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"),
- // 'value' => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1)));
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
+ );
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1);
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index a9970a95a51..17e4387c4de 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -1591,8 +1591,10 @@ class Commande extends CommonOrder
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
- $sql.= " WHERE c.entity IN (".getEntity('commande').")";
- if ($id) $sql.= " AND c.rowid=".$id;
+
+ if ($id) $sql.= " WHERE c.rowid=".$id;
+ else $sql.= " WHERE c.entity IN (".getEntity('commande').")"; // Dont't use entity if you use rowid
+
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'";
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index a63847421eb..2b86ad2f18a 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -509,7 +509,7 @@ if ($resql)
{
print $form->selectyesno('valdate_invoices', 0, 1);
}
- if (! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '
'.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").' ';
+ if (! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '
'.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").' ';
else print '
'.$langs->trans("OptionToSetOrderBilledNotEnabled").' ';
print '';
print '';
diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php
index 2c676e399de..4e44774e0c4 100644
--- a/htdocs/compta/facture/admin/facture_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php
@@ -80,7 +80,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '
";
}
@@ -93,7 +93,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print "
";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
index 18aa3c99442..54d3da8e18a 100644
--- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
@@ -81,7 +81,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '
";
}
@@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print "
";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php
index 2b90ae7fe05..c2490da4f42 100644
--- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php
@@ -81,7 +81,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '
";
}
@@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print "
";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
index 97f8b78b195..28c70ea9024 100644
--- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
@@ -81,7 +81,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '
";
}
@@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print "
";
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 68a24a20933..457f03c6afc 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -3200,7 +3200,7 @@ if ($action == 'create')
print '
';
print '
';
- switch ($classname) {
+ switch (get_class($objectsrc)) {
case 'Propal':
$newclassname = 'CommercialProposal';
break;
@@ -3217,7 +3217,7 @@ if ($action == 'create')
$newclassname = 'Intervention';
break;
default:
- $newclassname = $classname;
+ $newclassname = get_class($objectsrc);
}
print '
' . $langs->trans($newclassname) . ' ' . $objectsrc->getNomUrl(1);
@@ -3376,13 +3376,14 @@ else if ($id > 0 || ! empty($ref))
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
$label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
- // 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
- // => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction"))));
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction"), 0, $forcecombo))
+ );
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', $formquestion, "yes", 1);
} else {
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1);
@@ -4632,7 +4633,7 @@ else if ($id > 0 || ! empty($ref))
if ($objectidnext) {
print '' . $langs->trans('DoPayment') . '
';
} else {
- //if ($resteapayer == 0) {
+ //if ($resteapayer == 0) { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done)
// print '' . $langs->trans('DoPayment') . '
';
//} else {
print '';
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index b7d86cf630a..c6e43206c78 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1274,8 +1274,10 @@ class Facture extends CommonInvoice
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid';
- $sql.= ' WHERE f.entity IN ('.getEntity('facture').')';
- if ($rowid) $sql.= " AND f.rowid=".$rowid;
+
+ if ($rowid) $sql.= " WHERE f.rowid=".$rowid;
+ else $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; // Dont't use entity if you use rowid
+
if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'";
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 245b25be3b6..a6b0ec84317 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -1575,7 +1575,8 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR ='';
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
- $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).' '.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
+ // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).' '.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
+ $XML_DEBITOR .=' '.(($conf->global->END_TO_END != "" ) ? $conf->global->END_TO_END : ('AS-'.dol_trunc($row_facnumber,20)).'-'.$Rowing).' '.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.round($row_somme, 2).' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
@@ -1607,7 +1608,8 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
// $XML_DEBITOR .=' '.($row_facnumber.'/'.$Rowing.'/'.$Rum).' '.$CrLf;
- $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).' '.$CrLf; // 140 max
+ // $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).' '.$CrLf; // 140 max
+ $XML_DEBITOR .=' '.(($conf->global->USTRD != "" ) ? $conf->global->USTRD : dol_trunc($row_facnumber, 135) ).' '.$CrLf; // 140 max
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
return $XML_DEBITOR;
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index d837a6c6421..30b7c5158ba 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -32,6 +32,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
@@ -76,6 +77,7 @@ $search_type=GETPOST('search_type','alpha');
$search_zip=GETPOST('search_zip','alpha');
$search_town=GETPOST('search_town','alpha');
$search_import_key=GETPOST("search_import_key","alpha");
+$search_country=GETPOST("search_country",'intcomma');
if ($search_status=='') $search_status=1; // always display activ customer first
@@ -148,6 +150,7 @@ $arrayfields=array(
'p.poste'=>array('label'=>"PostOrFunction", 'checked'=>1),
'p.town'=>array('label'=>"Town", 'checked'=>0),
'p.zip'=>array('label'=>"Zip", 'checked'=>0),
+ 'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
'p.phone'=>array('label'=>"Phone", 'checked'=>1),
'p.phone_perso'=>array('label'=>"PhonePerso", 'checked'=>0),
'p.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1),
@@ -203,6 +206,9 @@ if (empty($reshook))
$search_lastname="";
$search_firstname="";
$search_societe="";
+ $search_town="";
+ $search_zip="";
+ $search_country="";
$search_poste="";
$search_phone="";
$search_phone_perso="";
@@ -298,6 +304,7 @@ if ($search_id > 0) $sql.= natural_search("p.rowid",$search_id,1
if ($search_lastname) $sql.= natural_search('p.lastname', $search_lastname);
if ($search_firstname) $sql.= natural_search('p.firstname', $search_firstname);
if ($search_societe) $sql.= natural_search('s.nom', $search_societe);
+if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')';
if (strlen($search_poste)) $sql.= natural_search('p.poste', $search_poste);
if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $search_phone_perso);
if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone);
@@ -396,6 +403,7 @@ if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_
if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe);
if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip);
if ($search_town != '') $param.='&search_town='.urlencode($search_town);
+if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
if ($search_job != '') $param.='&search_job='.urlencode($search_job);
if ($search_phone_pro != '') $param.='&search_phone_pro='.urlencode($search_phone_pro);
if ($search_phone_perso != '') $param.='&search_phone_perso='.urlencode($search_phone_perso);
@@ -518,6 +526,12 @@ if (! empty($arrayfields['p.firstname']['checked']))
print ' ';
print ' ';
}
+if (! empty($arrayfields['p.poste']['checked']))
+{
+ print '';
+ print ' ';
+ print ' ';
+}
if (! empty($arrayfields['p.zip']['checked']))
{
print '';
@@ -530,10 +544,25 @@ if (! empty($arrayfields['p.town']['checked']))
print ' ';
print ' ';
}
-if (! empty($arrayfields['p.poste']['checked']))
+// State
+/*if (! empty($arrayfields['state.nom']['checked']))
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }
+ // Region
+ if (! empty($arrayfields['region.nom']['checked']))
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }*/
+// Country
+if (! empty($arrayfields['country.code_iso']['checked']))
{
- print '';
- print ' ';
+ print ' ';
+ print $form->select_country($search_country,'search_country','',0,'maxwidth100');
print ' ';
}
if (! empty($arrayfields['p.phone']['checked']))
@@ -630,9 +659,12 @@ print '';
if (! empty($arrayfields['p.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"],"p.rowid","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['p.lastname']['checked'])) print_liste_field_titre($arrayfields['p.lastname']['label'],$_SERVER["PHP_SELF"],"p.lastname", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.firstname']['checked'])) print_liste_field_titre($arrayfields['p.firstname']['label'],$_SERVER["PHP_SELF"],"p.firstname", $begin, $param, '', $sortfield,$sortorder);
+if (! empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'],$_SERVER["PHP_SELF"],"p.poste", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.zip']['checked'])) print_liste_field_titre($arrayfields['p.zip']['label'],$_SERVER["PHP_SELF"],"p.zip", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.town']['checked'])) print_liste_field_titre($arrayfields['p.town']['label'],$_SERVER["PHP_SELF"],"p.town", $begin, $param, '', $sortfield,$sortorder);
-if (! empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'],$_SERVER["PHP_SELF"],"p.poste", $begin, $param, '', $sortfield,$sortorder);
+//if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
+//if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
+if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"co.code_iso","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'],$_SERVER["PHP_SELF"],"p.phone", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'],$_SERVER["PHP_SELF"],"p.phone_perso", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'],$_SERVER["PHP_SELF"],"p.phone_mobile", $begin, $param, '', $sortfield,$sortorder);
@@ -697,6 +729,12 @@ while ($i < min($num,$limit))
print ''.$obj->firstname.' ';
if (! $i) $totalarray['nbfield']++;
}
+ // Job position
+ if (! empty($arrayfields['p.poste']['checked']))
+ {
+ print ''.dol_trunc($obj->poste,20).' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
// Zip
if (! empty($arrayfields['p.zip']['checked']))
{
@@ -709,10 +747,25 @@ while ($i < min($num,$limit))
print ''.$obj->town.' ';
if (! $i) $totalarray['nbfield']++;
}
- // Function
- if (! empty($arrayfields['p.poste']['checked']))
+ // State
+ /*if (! empty($arrayfields['state.nom']['checked']))
{
- print ''.dol_trunc($obj->poste,20).' ';
+ print "".$obj->state_name." \n";
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Region
+ if (! empty($arrayfields['region.nom']['checked']))
+ {
+ print "".$obj->region_name." \n";
+ if (! $i) $totalarray['nbfield']++;
+ }*/
+ // Country
+ if (! empty($arrayfields['country.code_iso']['checked']))
+ {
+ print '';
+ $tmparray=getCountry($obj->fk_pays,'all');
+ print $tmparray['label'];
+ print ' ';
if (! $i) $totalarray['nbfield']++;
}
// Phone
diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php
index b9b0d51c162..d19c91e0bf2 100644
--- a/htdocs/contrat/admin/contract_extrafields.php
+++ b/htdocs/contrat/admin/contract_extrafields.php
@@ -81,7 +81,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print '
';
+ print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
diff --git a/htdocs/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php
index 42a8ed589d7..af2585eaf3a 100644
--- a/htdocs/contrat/admin/contractdet_extrafields.php
+++ b/htdocs/contrat/admin/contractdet_extrafields.php
@@ -81,7 +81,7 @@ dol_fiche_end();
if ($action != 'create' && $action != 'edit')
{
print '";
}
@@ -94,8 +94,8 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create')
{
- print " ";
- print load_fiche_titre($langs->trans('NewAttribute'));
+ print '
';
+ print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 58161aef6f5..f5382a91550 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -628,6 +628,7 @@ class CMailFile
if (! $res)
{
+ $langs->load("errors");
$this->error="Failed to send mail with php mail";
$linuxlike=1;
if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php
index 6851c124743..d9c496add4f 100644
--- a/htdocs/core/class/canvas.class.php
+++ b/htdocs/core/class/canvas.class.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2010-2018 Regis Houssin
* Copyright (C) 2011 Laurent Destailleur
*
* This program is free software; you can redistribute it and/or modify
@@ -145,7 +145,7 @@ class Canvas
{
if (empty($this->template_dir)) return 0;
- if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1;
+ if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1;
else return 0;
}
@@ -161,7 +161,7 @@ class Canvas
global $db, $conf, $langs, $user, $canvas;
global $form, $formfile;
- include $this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template
+ include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template
}
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index 9ce569edb35..9bab103d2e4 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -173,7 +173,7 @@ abstract class CommonInvoice extends CommonObject
}
/**
- * Return amount (with tax) of all credit notes and deposits invoices used by invoice
+ * Return amount (with tax) of all credit notes invoices + excess received used by invoice
*
* @param int $multicurrency Return multicurrency_amount instead of amount
* @return int <0 if KO, Sum of credit notes and deposits amount otherwise
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index a165704c058..771f9fc4456 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1500,7 +1500,7 @@ abstract class CommonObject
*/
function load_previous_next_ref($filter, $fieldid, $nodbprefix=0)
{
- global $user;
+ global $conf, $user;
if (! $this->table_element)
{
@@ -1520,6 +1520,9 @@ abstract class CommonObject
$sql = "SELECT MAX(te.".$fieldid.")";
$sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te";
+ if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
+ }
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
@@ -1534,7 +1537,18 @@ abstract class CommonObject
}
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element).')';
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
+ if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
+ $sql.= " AND te.entity IS NOT NULL"; // Show all users
+ } else {
+ $sql.= " AND ug.fk_user = te.rowid";
+ $sql.= " AND ug.entity IN (".getEntity($this->element).")";
+ }
+ } else {
+ $sql.= ' AND te.entity IN ('.getEntity($this->element).')';
+ }
+ }
if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid;
if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)';
if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid;
@@ -1552,6 +1566,9 @@ abstract class CommonObject
$sql = "SELECT MIN(te.".$fieldid.")";
$sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te";
+ if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
+ }
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
@@ -1566,7 +1583,18 @@ abstract class CommonObject
}
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element).')';
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
+ if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
+ $sql.= " AND te.entity IS NOT NULL"; // Show all users
+ } else {
+ $sql.= " AND ug.fk_user = te.rowid";
+ $sql.= " AND ug.entity IN (".getEntity($this->element).")";
+ }
+ } else {
+ $sql.= ' AND te.entity IN ('.getEntity($this->element).')';
+ }
+ }
if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid;
if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)';
if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid;
@@ -3838,7 +3866,7 @@ abstract class CommonObject
{
global $conf,$langs,$user,$object,$hookmanager;
global $form,$bc,$bcdd;
- global $object_rights, $disableedit, $disablemove; // TODO We should not use global var for this !
+ global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this !
$object_rights = $this->getRights();
@@ -5082,10 +5110,10 @@ abstract class CommonObject
* @param string $moreparam To add more parameters on html input tag
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names)
- * @param string|int $showsize Value for css to define size. May also be a numeric.
+ * @param string|int $morecss Value for css to define style/length of field. May also be a numeric.
* @return string
*/
- function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0)
+ function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss=0)
{
global $conf,$langs,$form;
@@ -5094,39 +5122,55 @@ abstract class CommonObject
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$form=new Form($this->db);
}
+
+ $val=$this->fields[$key];
+
+ $out='';
+ $type='';
+ $param['options']=array();
+ $size =$this->fields[$key]['size'];
+ // Because we work on extrafields
+ if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){
+ $param['options']=array($reg[1].':'.$reg[2]=>'N');
+ $type ='link';
+ }else if(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)){
+ $param['options']=array($reg[1].':'.$reg[2]=>'N');
+ $type ='link';
+ }else if(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){
+
+ $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N');
+ $type ='sellist';
+ }else if(preg_match('/varchar\((\d+)\)/', $val['type'],$reg)){
+
+ $param['options']=array();
+ $type ='varchar';
+ $size=$reg[1];
+ }else if(preg_match('/varchar/', $val['type'])){
+
+ $param['options']=array();
+ $type ='varchar';
+ }else if(is_array($this->fields[$key]['arrayofkeyval'])){
+
+ $param['options']=$this->fields[$key]['arrayofkeyval'];
+ $type ='select';
+ }else {
+ $param['options']=array();
+ $type =$this->fields[$key]['type'];
+ }
+
+ $label=$this->fields[$key]['label'];
+ //$elementtype=$this->fields[$key]['elementtype']; // Seems not used
+ $default=$this->fields[$key]['default'];
+ $computed=$this->fields[$key]['computed'];
+ $unique=$this->fields[$key]['unique'];
+ $required=$this->fields[$key]['required'];
+
+ $langfile=$this->fields[$key]['langfile'];
+ $list=$this->fields[$key]['list'];
+ $hidden=abs($this->fields[$key]['visible'])!=1?1:0;
$objectid = $this->id;
- $label= $val['label'];
- $type = $val['type'];
- $size = $val['css'];
-
- // Convert var to be able to share same code than showInputField of extrafields
- if (preg_match('/varchar\((\d+)\)/', $type, $reg))
- {
- $type = 'varchar'; // convert varchar(xx) int varchar
- $size = $reg[1];
- }
- elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) into varchar
- elseif (preg_match('/double/', $type)) $type = 'double'; // convert double(xx) into double
- if (is_array($val['arrayofkeyval'])) $type='select';
- if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link';
-
- $default=$val['default'];
- $computed=$val['computed'];
- $unique=$val['unique'];
- $required=$val['required'];
- $param=$val['param'];
- if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval'];
- if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg))
- {
- $type='link';
- $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
- }
- $langfile=$val['langfile'];
- $list=$val['list'];
- $hidden=(abs($val['visible'])!=1 ? 1 : 0);
- $help=$val['help'];
if ($computed)
{
@@ -5134,54 +5178,50 @@ abstract class CommonObject
else return '';
}
+
// Use in priority showsize from parameters, then $val['css'] then autodefine
- if (empty($showsize) && ! empty($val['css']))
+ if (empty($morecss) && ! empty($val['css']))
{
$showsize = $val['css'];
}
- if (empty($showsize))
+ if (empty($morecss))
{
if ($type == 'date')
{
- //$showsize=10;
- $showsize = 'minwidth100imp';
+ $morecss = 'minwidth100imp';
}
elseif ($type == 'datetime')
{
- //$showsize=19;
- $showsize = 'minwidth200imp';
+ $morecss = 'minwidth200imp';
}
- elseif (in_array($type,array('int','double','price')))
+ elseif (in_array($type,array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type))
{
- //$showsize=10;
- $showsize = 'maxwidth75';
- }
- elseif ($type == 'url')
+ $morecss = 'maxwidth75';
+ }elseif ($type == 'url')
{
- $showsize='minwidth400';
+ $morecss='minwidth400';
}
elseif ($type == 'boolean')
{
- $showsize='';
+ $morecss='';
}
else
{
if (round($size) < 12)
{
- $showsize = 'minwidth100';
+ $morecss = 'minwidth100';
}
else if (round($size) <= 48)
{
- $showsize = 'minwidth200';
+ $morecss = 'minwidth200';
}
else
{
- //$showsize=48;
- $showsize = 'minwidth400';
+ $morecss = 'minwidth400';
}
}
}
- //var_dump($showsize.' '.$size);
+
if (in_array($type,array('date','datetime')))
{
$tmp=explode(',',$size);
@@ -5193,33 +5233,47 @@ abstract class CommonObject
if (!$required && $value == '') $value = '-1';
// TODO Must also support $moreparam
- $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1);
+ $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0, 1);
}
elseif (in_array($type,array('int','integer')))
{
$tmp=explode(',',$size);
$newsize=$tmp[0];
- $out=' ';
+ $out=' ';
}
elseif (preg_match('/varchar/', $type))
{
- $out=' ';
+ $out=' ';
}
elseif (in_array($type, array('mail', 'phone', 'url')))
{
- $out=' ';
+ $out=' ';
}
elseif ($type == 'text')
{
- require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,0,ROWS_5,'90%');
- $out=$doleditor->Create(1);
+ if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+ $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,false,ROWS_5,'90%');
+ $out=$doleditor->Create(1);
+ }
+ else
+ {
+ $out=' ';
+ }
}
elseif ($type == 'html')
{
- require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%');
- $out=$doleditor->Create(1);
+ if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+ $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%');
+ $out=$doleditor->Create(1);
+ }
+ else
+ {
+ $out=' ';
+ }
}
elseif ($type == 'boolean')
{
@@ -5229,21 +5283,21 @@ abstract class CommonObject
} else {
$checked=' value="1" ';
}
- $out=' ';
+ $out=' ';
}
elseif ($type == 'price')
{
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value=price($value);
}
- $out=' '.$langs->getCurrencySymbol($conf->currency);
+ $out=' '.$langs->getCurrencySymbol($conf->currency);
}
- elseif ($type == 'double')
+ elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type))
{
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value=price($value);
}
- $out=' ';
+ $out=' ';
}
elseif ($type == 'select')
{
@@ -5254,8 +5308,8 @@ abstract class CommonObject
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
}
- $out.='';
- if ((! isset($val['default'])) || ($val['notnull'] != 1)) $out.=' ';
+ $out.='';
+ if((! isset($this->fields[$key]['default'])) ||($this->fields[$key]['notnull']!=1))$out.=' ';
foreach ($param['options'] as $key => $val)
{
if ((string) $key == '') continue;
@@ -5276,11 +5330,13 @@ abstract class CommonObject
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
}
- $out.='';
+ $out.='';
if (is_array($param['options']))
{
$param_list=array_keys($param['options']);
$InfoFieldList = explode(":", $param_list[0]);
+ $parentName='';
+ $parentField='';
// 0 : tableName
// 1 : label field name
// 2 : key fields name (if differ of rowid)
@@ -5365,8 +5421,9 @@ abstract class CommonObject
$obj = $this->db->fetch_object($resql);
// Several field into label (eq table:code|libelle:rowid)
+ $notrans = false;
$fields_label = explode('|',$InfoFieldList[1]);
- if(is_array($fields_label))
+ if (is_array($fields_label))
{
$notrans = true;
foreach ($fields_label as $field_toshow)
@@ -5380,7 +5437,7 @@ abstract class CommonObject
}
$labeltoshow=dol_trunc($labeltoshow,45);
- if ($value==$obj->rowid)
+ if ($value == $obj->rowid)
{
foreach ($fields_label as $field_toshow)
{
@@ -5395,7 +5452,7 @@ abstract class CommonObject
}
else
{
- if(!$notrans)
+ if (! $notrans)
{
$translabel=$langs->trans($obj->{$InfoFieldList[1]});
if ($translabel!=$obj->{$InfoFieldList[1]}) {
@@ -5411,7 +5468,7 @@ abstract class CommonObject
$out.=''.$labeltoshow.' ';
}
- if (!empty($InfoFieldList[3]))
+ if (!empty($InfoFieldList[3]) && $parentField)
{
$parent = $parentName.':'.$obj->{$parentField};
}
@@ -5442,7 +5499,7 @@ abstract class CommonObject
$out='';
foreach ($param['options'] as $keyopt => $val)
{
- $out.=' db->fetch_object($resql);
+ $notrans = false;
// Several field into label (eq table:code|libelle:rowid)
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
@@ -5574,7 +5634,7 @@ abstract class CommonObject
$data[$obj->rowid]=$labeltoshow;
}
- if (! empty($InfoFieldList[3])) {
+ if (! empty($InfoFieldList[3]) && $parentField) {
$parent = $parentName . ':' . $obj->{$parentField};
}
@@ -5591,18 +5651,17 @@ abstract class CommonObject
print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters. ';
}
}
- $out .= ' ';
}
elseif ($type == 'link')
{
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
- $showempty=(($val['notnull'] == 1 && $val['default'] != '')?0:1);
+ $showempty=(($required && $default != '')?0:1);
$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty);
}
elseif ($type == 'password')
{
// If prefix is 'search_', field is used as a filter, we use a common text field.
- $out=' ';
+ $out=' ';
}
elseif ($type == 'array')
{
@@ -5648,8 +5707,7 @@ abstract class CommonObject
*/
return $out;
}
-
-
+
/**
* Return HTML string to show a field into a page
* Code very similar with showOutputField of extra fields
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 264d3e9c236..3b33b1f16f1 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -39,6 +39,8 @@ class Conf
var $db;
//! To store properties found into database
var $global;
+ //! To store browser info
+ var $browser;
//! To store if javascript/ajax is enabked
public $use_javascript_ajax;
@@ -506,7 +508,7 @@ class Conf
if (! isset($this->global->MAIN_SHOW_LOGO)) $this->global->MAIN_SHOW_LOGO=1;
// Default max file size for upload
- $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024);
+ $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
// By default, we propagate contacts
if (! isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN='*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php
index 5cb7d3e6882..9fc1921aa60 100644
--- a/htdocs/core/class/discount.class.php
+++ b/htdocs/core/class/discount.class.php
@@ -509,11 +509,11 @@ class DiscountAbsolute
}
/**
- * Return amount (with tax) of all credit notes and deposits invoices used by invoice as a payment
+ * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment
*
* @param CommonInvoice $invoice Object invoice
* @param int $multicurrency Return multicurrency_amount instead of amount
- * @return int <0 if KO, Sum of credit notes and deposits amount otherwise
+ * @return int <0 if KO, Sum of credit notes and excess received amount otherwise
*/
function getSumCreditNotesUsed($invoice, $multicurrency=0)
{
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 839528ddc20..174e01bf74c 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -156,14 +156,14 @@ class ExtraFields
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param string $list Visibilty ('0'=never visible, '1'=visible on list+forms, '2'=list only, '3'=form only or 'eval string')
- * @param int $notused Deprecated.
+ * @param string $help Text with help tooltip
* @param string $computed Computed value
* @param string $entity Entity of extrafields (for multicompany modules)
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
* @return int <=0 if KO, >0 if OK
*/
- function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $computed='', $entity='', $langfile='', $enabled='1')
+ function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $computed='', $entity='', $langfile='', $enabled='1')
{
if (empty($attrname)) return -1;
if (empty($label)) return -1;
@@ -174,13 +174,13 @@ class ExtraFields
// Create field into database except for separator type which is not stored in database
if ($type != 'separate')
{
- $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed);
+ $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed, $help);
}
$err1=$this->errno;
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate')
{
// Add declaration of field into table
- $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $notused, $default_value, $computed, $entity, $langfile, $enabled);
+ $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled);
$err2=$this->errno;
if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS'))
{
@@ -300,7 +300,7 @@ class ExtraFields
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param string $list Visibily
- * @param int $notused Deprecated.
+ * @param string $help Help on tooltip
* @param string $default Default value (in database. use the default_value feature for default value on screen).
* @param string $computed Computed value
* @param string $entity Entity of extrafields
@@ -308,7 +308,7 @@ class ExtraFields
* @param string $enabled Condition to have the field enabled or not
* @return int <=0 if KO, >0 if OK
*/
- private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1')
+ private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $default='', $computed='',$entity='', $langfile='', $enabled='1')
{
global $conf,$user;
@@ -357,7 +357,8 @@ class ExtraFields
$sql.= " fk_user_author,";
$sql.= " fk_user_modif,";
$sql.= " datec,";
- $sql.= " enabled";
+ $sql.= " enabled,";
+ $sql.= " help";
$sql.= " )";
$sql.= " VALUES('".$attrname."',";
$sql.= " '".$this->db->escape($label)."',";
@@ -378,7 +379,8 @@ class ExtraFields
$sql .= " " . $user->id . ",";
$sql .= " " . $user->id . ",";
$sql .= "'" . $this->db->idate(dol_now()) . "',";
- $sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1");
+ $sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1").",";
+ $sql.= " ".($help?"'".$this->db->escape($help)."'":"null");
$sql.=')';
dol_syslog(get_class($this)."::create_label", LOG_DEBUG);
@@ -508,7 +510,7 @@ class ExtraFields
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param string $list Visibility
- * @param int $notused Deprecated.
+ * @param string $help Help on tooltip
* @param string $default Default value (in database. use the default_value feature for default value on screen).
* @param string $computed Computed value
* @param string $entity Entity of extrafields
@@ -516,7 +518,7 @@ class ExtraFields
* @param string $enabled Condition to have the field enabled or not
* @return int >0 if OK, <=0 if KO
*/
- function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $notused=0, $default='', $computed='', $entity='', $langfile='', $enabled='1')
+ function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $help='', $default='', $computed='', $entity='', $langfile='', $enabled='1')
{
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
@@ -566,7 +568,7 @@ class ExtraFields
{
if ($label)
{
- $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$notused,$default,$computed,$entity,$langfile,$enabled);
+ $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$help,$default,$computed,$entity,$langfile,$enabled);
}
if ($result > 0)
{
@@ -617,7 +619,7 @@ class ExtraFields
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param string $list Visiblity
- * @param int $notused Deprecated.
+ * @param string $help Help on tooltip.
* @param string $default Default value (in database. use the default_value feature for default value on screen).
* @param string $computed Computed value
* @param string $entity Entity of extrafields
@@ -625,7 +627,7 @@ class ExtraFields
* @param string $enabled Condition to have the field enabled or not
* @return int <=0 if KO, >0 if OK
*/
- private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1')
+ private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$help='',$default='',$computed='',$entity='',$langfile='',$enabled='1')
{
global $conf, $user;
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled);
@@ -684,7 +686,8 @@ class ExtraFields
$sql.= " fk_user_author,";
$sql.= " fk_user_modif,";
$sql.= " datec,";
- $sql.= " enabled";
+ $sql.= " enabled,";
+ $sql.= " help";
$sql.= ") VALUES (";
$sql.= "'".$attrname."',";
$sql.= " ".($entity===''?$conf->entity:$entity).",";
@@ -705,7 +708,8 @@ class ExtraFields
$sql .= " " . $user->id . ",";
$sql .= " " . $user->id . ",";
$sql .= "'" . $this->db->idate(dol_now()) . "',";
- $sql .= "'" . $this->db->escape($enabled). "'";
+ $sql .= "'" . $this->db->escape($enabled). "',";
+ $sql.= " ".($help?"'".$this->db->escape($help)."'":"null");
$sql.= ")";
$resql2=$this->db->query($sql);
@@ -769,7 +773,7 @@ class ExtraFields
// We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management.
dol_syslog("fetch_name_optionals_label elementtype=".$elementtype);
- $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled";
+ $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled,help";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
$sql.= " WHERE entity IN (0,".$conf->entity.")";
if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element
@@ -824,6 +828,7 @@ class ExtraFields
$this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity;
$this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]);
$this->attributes[$tab->elementtype]['enabled'][$tab->name]=$tab->enabled;
+ $this->attributes[$tab->elementtype]['help'][$tab->name]=$tab->help;
$this->attributes[$tab->elementtype]['loaded']=1;
}
@@ -881,6 +886,7 @@ class ExtraFields
$perms=dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1);
$langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key];
$list=dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1);
+ $help=$this->attributes[$extrafieldsobjectkey]['help'][$key];
$hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
}
else // Old usage
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index cd33f1d8d02..439e31caae1 100644
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -186,7 +186,8 @@ class HookManager
'sendMail',
'sendMailAfter',
'showLinkToObjectBlock',
- 'setContentSecurityPolicy'
+ 'setContentSecurityPolicy',
+ 'setHtmlTitle'
)
)) $hooktype='addreplace';
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 9a9d3279e03..88377edfad9 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -291,7 +291,7 @@ class Form
$out='';
// Check parameters
- if ($inputType == 'textarea') $value = dol_nl2br($value);
+ if (preg_match('/^text/',$inputType)) $value = dol_nl2br($value);
else if (preg_match('/^numeric/',$inputType)) $value = price($value);
else if ($inputType == 'day' || $inputType == 'datepicker') $value = dol_print_date($value, 'day');
@@ -1001,9 +1001,10 @@ class Form
* @param string $selected_input_value Value of preselected input text (for use with ajax)
* @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after)
* @param array $ajaxoptions Options for ajax_autocompleter
+ * @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter)
* @return string HTML string with select box for thirdparty.
*/
- function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='', $selected_input_value='', $hidelabel=1, $ajaxoptions=array())
+ function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='', $selected_input_value='', $hidelabel=1, $ajaxoptions=array(), $multiple=false)
{
global $conf,$user,$langs;
@@ -1040,7 +1041,7 @@ class Form
else
{
// Immediate load of all database
- $out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam);
+ $out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple);
}
return $out;
@@ -1062,16 +1063,20 @@ class Form
* @param int $limit Limit number of answers
* @param string $morecss Add more css styles to the SELECT component
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
+ * @param bool $multiple add [] in the name of element and add 'multiple' attribut
* @return string HTML string with
*/
- function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty='', $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='')
+ function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty='', $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='', $multiple=false)
{
global $conf,$user,$langs;
$out='';
$num=0;
$outarray=array();
-
+
+ if ($selected === '') $selected = array();
+ else if (!is_array($selected)) $selected = array($selected);
+
// Clean $filter that may contains sql conditions so sql code
if (function_exists('test_sql_and_script_inject')) $filter = test_sql_and_script_inject($filter, 3);
@@ -1120,7 +1125,7 @@ class Form
}
// Construct $out and $outarray
- $out.= ''."\n";
+ $out.= ''."\n";
$textifempty='';
// Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
@@ -1169,7 +1174,7 @@ class Form
if (empty($outputmode))
{
- if ($selected > 0 && $selected == $obj->rowid)
+ if (in_array($obj->rowid,$selected))
{
$out.= ''.$label.' ';
}
@@ -1320,15 +1325,19 @@ class Form
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $htmlid Html id to use instead of htmlname
+ * @param bool $multiple add [] in the name of element and add 'multiple' attribut
* @return int <0 if KO, Nb of contact in list if OK
*/
- function selectcontacts($socid, $selected='', $htmlname='contactid', $showempty=0, $exclude='', $limitto='', $showfunction=0, $moreclass='', $options_only=false, $showsoc=0, $forcecombo=0, $events=array(), $moreparam='', $htmlid='')
+ function selectcontacts($socid, $selected='', $htmlname='contactid', $showempty=0, $exclude='', $limitto='', $showfunction=0, $moreclass='', $options_only=false, $showsoc=0, $forcecombo=0, $events=array(), $moreparam='', $htmlid='', $multiple=false)
{
global $conf,$langs;
$langs->load('companies');
if (empty($htmlid)) $htmlid = $htmlname;
+
+ if ($selected === '') $selected = array();
+ else if (!is_array($selected)) $selected = array($selected);
$out='';
// On recherche les societes
@@ -1353,9 +1362,9 @@ class Form
$out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
}
- if ($htmlname != 'none' || $options_only) $out.= '';
- if ($showempty == 1) $out.= ' ';
- if ($showempty == 2) $out.= ''.$langs->trans("Internal").' ';
+ if ($htmlname != 'none' || $options_only) $out.= '';
+ if ($showempty == 1 && !$multiple) $out.= ' ';
+ if ($showempty == 2) $out.= ''.$langs->trans("Internal").' ';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
@@ -1363,7 +1372,6 @@ class Form
include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$contactstatic=new Contact($this->db);
- if (!is_array($selected)) $selected = array($selected);
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
@@ -1413,7 +1421,7 @@ class Form
}
else
{
- $out.= ''.$langs->trans($socid?"NoContactDefinedForThirdParty":"NoContactDefined").' ';
+ $out.= ''.$langs->trans($socid?"NoContactDefinedForThirdParty":"NoContactDefined").' ';
}
if ($htmlname != 'none' || $options_only)
{
@@ -1469,16 +1477,20 @@ class Form
* @param string $morecss More css
* @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on).
* @param int $outputmode 0=HTML select string, 1=Array
+ * @param bool $multiple add [] in the name of element and add 'multiple' attribut
* @return string HTML select string
* @see select_dolgroups
*/
- function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity='0', $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0, $outputmode=0)
+ function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity='0', $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0, $outputmode=0, $multiple=false)
{
global $conf,$user,$langs;
-
+
// If no preselected user defined, we take current user
if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id;
+ if ($selected === '') $selected = array();
+ else if (!is_array($selected)) $selected = array($selected);
+
$excludeUsers=null;
$includeUsers=null;
@@ -1551,12 +1563,12 @@ class Form
$out .= ajax_combobox($htmlname);
// do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined
- $out.= '';
- if ($show_empty) $out.= ' '."\n";
- if ($show_every) $out.= '-- '.$langs->trans("Everybody").' -- '."\n";
+ $out.= '';
+ if ($show_empty && !$multiple) $out.= ' '."\n";
+ if ($show_every) $out.= '-- '.$langs->trans("Everybody").' -- '."\n";
$userstatic=new User($this->db);
-
+
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
@@ -1568,7 +1580,7 @@ class Form
$disableline='';
if (is_array($enableonly) && count($enableonly) && ! in_array($obj->rowid,$enableonly)) $disableline=($enableonlytext?$enableonlytext:'1');
- if ((is_object($selected) && $selected->id == $obj->rowid) || (! is_object($selected) && $selected == $obj->rowid))
+ if ((is_object($selected) && $selected->id == $obj->rowid) || (! is_object($selected) && in_array($obj->rowid,$selected) ))
{
$out.= 'initHooks(array('commonobject'));
$parameters=array(
+ 'morehtmlright' => $morehtmlright,
'compatibleImportElementsList' =>& $compatibleImportElementsList,
);
$reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@@ -6185,7 +6198,7 @@ class Form
// Can complete the possiblelink array
$hookmanager->initHooks(array('commonobject'));
- $parameters=array();
+ $parameters=array('listofidcompanytoscan' => $listofidcompanytoscan);
$reshook=$hookmanager->executeHooks('showLinkToObjectBlock',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
@@ -6233,7 +6246,7 @@ class Form
print ' ';
while ($i < $num)
{
- $objp = $this->db->fetch_object($resqlorderlist);
+ $objp = $this->db->fetch_object($resqllist);
$var = ! $var;
print '
';
@@ -6727,10 +6740,11 @@ class Form
* @param string $include Array list of groups id to include
* @param int $enableonly Array list of groups id to be enabled. All other must be disabled
* @param string $force_entity '0' or Ids of environment to force
+ * @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter)
* @return string
* @see select_dolusers
*/
- function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity='0')
+ function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity='0', $multiple=false)
{
global $conf,$user,$langs;
@@ -6739,6 +6753,8 @@ class Form
// Permettre l'inclusion de groupes
if (is_array($include)) $includeGroups = implode("','",$include);
+ if (!is_array($selected)) $selected = array($selected);
+
$out='';
// On recherche les groupes
@@ -6770,13 +6786,13 @@ class Form
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname);
- $out.= '';
+ $out.= '';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
- if ($show_empty) $out.= ' '."\n";
+ if ($show_empty && !$multiple) $out.= ' '."\n";
while ($i < $num)
{
@@ -6786,7 +6802,7 @@ class Form
$out.= 'id == $obj->rowid) || (! is_object($selected) && $selected == $obj->rowid))
+ if ((is_object($selected[0]) && $selected[0]->id == $obj->rowid) || (! is_object($selected[0]) && in_array($obj->rowid,$selected) ))
{
$out.= ' selected';
}
@@ -6804,7 +6820,7 @@ class Form
}
else
{
- if ($show_empty) $out.= ' '."\n";
+ if ($show_empty) $out.= ' '."\n";
$out.= ''.$langs->trans("NoUserGroupDefined").' ';
}
$out.= ' ';
diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php
index f4902e4912e..a3a3696e5f4 100644
--- a/htdocs/core/class/html.formcontract.class.php
+++ b/htdocs/core/class/html.formcontract.class.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2012-2018 Charlene BENKE
*
* 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
@@ -57,15 +57,25 @@ class FormContract
global $db,$user,$conf,$langs;
$hideunselectables = false;
- if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
+ if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true;
// Search all contacts
$sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut';
$sql.= ' FROM '.MAIN_DB_PREFIX .'contrat as c';
$sql.= " WHERE c.entity = ".$conf->entity;
//if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")";
+ if ($socid > 0)
+ {
+ // CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
+ if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY))
+ $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)";
+ else if ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all')
+ {
+ $sql.= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") ";
+ $sql.= " OR c.fk_soc IS NULL)";
+ }
+ }
if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)";
- if ($socid > 0) $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)";
$sql.= " ORDER BY c.ref ";
dol_syslog(get_class($this)."::select_contract", LOG_DEBUG);
@@ -98,12 +108,12 @@ class FormContract
else
{
$disabled=0;
- if (! $obj->statut > 0)
+ if ( $obj->statut == 0)
{
$disabled=1;
$labeltoshow.=' ('.$langs->trans("Draft").')';
}
- if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
+ if ( empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
{
$disabled=1;
$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 098b75a81b6..69fe03ecaa1 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -193,7 +193,7 @@ class FormOther
print '';
//print ' ';
}
- $selectOptionValue = $obj->code.' : '.price($obj->price).' '.$langs->trans("HT").' ('.$obj->organization.')';
+ $selectOptionValue = $obj->code.' - '.$obj->label.' : '.price($obj->price).' '.$langs->trans("HT").' ('.$obj->organization.')';
print $selectOptionValue;
print ' ';
$i++;
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index a572d546ca7..f437920caf9 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -1,6 +1,7 @@
* Copyright (C) 2015 Marcos García
+ * Copyright (C) 2018 Charlene Benke
*
* 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
@@ -139,10 +140,10 @@ class FormProjets
if (empty($htmlid)) $htmlid = $htmlname;
$out='';
- $outarray=array();
+ $outarray=array();
$hideunselectables = false;
- if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
+ if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true;
$projectsListId = false;
if (empty($user->rights->projet->all->lire))
@@ -317,7 +318,7 @@ class FormProjets
$out='';
$hideunselectables = false;
- if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
+ if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true;
if (empty($projectsListId))
{
diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php
index c123356f9ab..48880633563 100644
--- a/htdocs/core/class/menubase.class.php
+++ b/htdocs/core/class/menubase.class.php
@@ -124,61 +124,86 @@ class Menubase
else dol_print_error($this->db);
}
- // TODO
// Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql
+ $sql = "SELECT count(*)";
+ $sql.= " FROM ".MAIN_DB_PREFIX."menu";
+ $sql.= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'";
+ $sql.= " AND fk_menu = ".((int) $this->db->escape($this->fk_menu));
+ $sql.= " AND position = ".((int) $this->position);
+ $sql.= " AND url = '".$this->db->escape($this->url)."'";
+ $sql.= " AND entity = ".$conf->entity;
- // Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu(";
- $sql.= "menu_handler,";
- $sql.= "entity,";
- $sql.= "module,";
- $sql.= "type,";
- $sql.= "mainmenu,";
- $sql.= "leftmenu,";
- $sql.= "fk_menu,";
- $sql.= "fk_mainmenu,";
- $sql.= "fk_leftmenu,";
- $sql.= "position,";
- $sql.= "url,";
- $sql.= "target,";
- $sql.= "titre,";
- $sql.= "langs,";
- $sql.= "perms,";
- $sql.= "enabled,";
- $sql.= "usertype";
- $sql.= ") VALUES (";
- $sql.= " '".$this->db->escape($this->menu_handler)."',";
- $sql.= " '".$this->db->escape($conf->entity)."',";
- $sql.= " '".$this->db->escape($this->module)."',";
- $sql.= " '".$this->db->escape($this->type)."',";
- $sql.= " ".($this->mainmenu?"'".$this->db->escape($this->mainmenu)."'":"''").","; // Can't be null
- $sql.= " ".($this->leftmenu?"'".$this->db->escape($this->leftmenu)."'":"null").",";
- $sql.= " '".$this->db->escape($this->fk_menu)."',";
- $sql.= " ".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").",";
- $sql.= " ".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").",";
- $sql.= " '".(int) $this->position."',";
- $sql.= " '".$this->db->escape($this->url)."',";
- $sql.= " '".$this->db->escape($this->target)."',";
- $sql.= " '".$this->db->escape($this->titre)."',";
- $sql.= " '".$this->db->escape($this->langs)."',";
- $sql.= " '".$this->db->escape($this->perms)."',";
- $sql.= " '".$this->db->escape($this->enabled)."',";
- $sql.= " '".$this->db->escape($this->user)."'";
- $sql.= ")";
-
- dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
+ $result=$this->db->query($sql);
+ if ($result)
{
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."menu");
- dol_syslog(get_class($this)."::create record added has rowid=".$this->id, LOG_DEBUG);
+ $row = $this->db->fetch_row($result);
- return $this->id;
+ if ($row[0] == 0) // If not found
+ {
+ // Insert request
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu(";
+ $sql.= "menu_handler,";
+ $sql.= "entity,";
+ $sql.= "module,";
+ $sql.= "type,";
+ $sql.= "mainmenu,";
+ $sql.= "leftmenu,";
+ $sql.= "fk_menu,";
+ $sql.= "fk_mainmenu,";
+ $sql.= "fk_leftmenu,";
+ $sql.= "position,";
+ $sql.= "url,";
+ $sql.= "target,";
+ $sql.= "titre,";
+ $sql.= "langs,";
+ $sql.= "perms,";
+ $sql.= "enabled,";
+ $sql.= "usertype";
+ $sql.= ") VALUES (";
+ $sql.= " '".$this->db->escape($this->menu_handler)."',";
+ $sql.= " '".$this->db->escape($conf->entity)."',";
+ $sql.= " '".$this->db->escape($this->module)."',";
+ $sql.= " '".$this->db->escape($this->type)."',";
+ $sql.= " ".($this->mainmenu?"'".$this->db->escape($this->mainmenu)."'":"''").","; // Can't be null
+ $sql.= " ".($this->leftmenu?"'".$this->db->escape($this->leftmenu)."'":"null").",";
+ $sql.= " ".((int) $this->fk_menu).",";
+ $sql.= " ".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").",";
+ $sql.= " ".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").",";
+ $sql.= " ".((int) $this->position).",";
+ $sql.= " '".$this->db->escape($this->url)."',";
+ $sql.= " '".$this->db->escape($this->target)."',";
+ $sql.= " '".$this->db->escape($this->titre)."',";
+ $sql.= " '".$this->db->escape($this->langs)."',";
+ $sql.= " '".$this->db->escape($this->perms)."',";
+ $sql.= " '".$this->db->escape($this->enabled)."',";
+ $sql.= " '".$this->db->escape($this->user)."'";
+ $sql.= ")";
+
+ dol_syslog(get_class($this)."::create", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."menu");
+ dol_syslog(get_class($this)."::create record added has rowid=".$this->id, LOG_DEBUG);
+
+ return $this->id;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ return -1;
+ }
+ }
+ else
+ {
+ dol_syslog(get_class($this)."::create menu entry already exists", LOG_WARNING);
+ $this->error = 'Error Menu entry already exists';
+ return 0;
+ }
}
else
{
- $this->error="Error ".$this->db->lasterror();
- return -1;
+ return -1;
}
}
diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php
index 8507a85292a..fcb14be9c67 100644
--- a/htdocs/core/lib/fichinter.lib.php
+++ b/htdocs/core/lib/fichinter.lib.php
@@ -2,8 +2,9 @@
/* Copyright (C) 2006-2007 Laurent Destailleur
* Copyright (C) 2007 Rodolphe Quiedeville
* Copyright (C) 2012 Regis Houssin
- * Copyright (C) 2016 Gilles Poirier
-
+ * Copyright (C) 2016 Gilles Poirier
+ * Copyright (C) 2018 charlene Benke
+
*
* 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
@@ -162,4 +163,23 @@ function fichinter_admin_prepare_head()
return $head;
}
+function fichinter_rec_prepare_head ($object)
+{
+ global $langs, $conf; //, $user;
+
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("CardFichinter");
+ $head[$h][2] = 'card';
+ $h++;
+
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec');
+
+ complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove');
+
+
+ return $head;
+}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 54bbbc837a1..51e64c22878 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2782,6 +2782,35 @@ function isValidEmail($address, $acceptsupervisorkey=0)
return false;
}
+/**
+ * Return if the domain name has a valid MX record.
+ * WARNING: This need function idn_to_ascii, checkdnsrr and getmxrr
+ *
+ * @param string $domain Domain name (Ex: "yahoo.com", "yhaoo.com", "dolibarr.fr")
+ * @return int -1 if error (function not available), 0=Not valid, 1=Valid
+ */
+function isValidMXRecord($domain)
+{
+ if (function_exists('idn_to_ascii') && function_exists('checkdnsrr'))
+ {
+ if (! checkdnsrr(idn_to_ascii($domain), 'MX'))
+ {
+ return 0;
+ }
+ if (function_exists('getmxrr'))
+ {
+ $mxhosts=array();
+ $weight=array();
+ getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
+ if (count($mxhosts) > 1) return 1;
+ if (count($mxhosts) == 1 && ! empty($mxhosts[0])) return 1;
+
+ return 0;
+ }
+ }
+ return -1;
+}
+
/**
* Return true if phone number syntax is ok
* TODO Decide what to do with this
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index 80ba3039abe..e7eb9eb259d 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -708,9 +708,10 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti
* @param string $mode 'next' for next value or 'last' for last value
* @param bool $bentityon Activate the entity filter. Default is true (for modules not compatible with multicompany)
* @param User $objuser Object user we need data from.
+ * @param int $forceentity Entity id to force
* @return string New value (numeric) or error message
*/
-function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null)
+function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null, $forceentity=null)
{
global $conf,$user;
@@ -987,7 +988,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$sql.= " AND ".$field." NOT LIKE '(PROV%)'";
if ($bentityon) // only if entity enable
$sql.= " AND entity IN (".getEntity($sharetable).")";
-
+ else if (! empty($forceentity))
+ $sql.= " AND entity = ".(int) $forceentity;
if ($where) $sql.=$where;
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
@@ -1035,6 +1037,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$sql.= " AND ".$field." NOT LIKE '%PROV%'";
if ($bentityon) // only if entity enable
$sql.= " AND entity IN (".getEntity($sharetable).")";
+ else if (! empty($forceentity))
+ $sql.= " AND entity = ".(int) $forceentity;
if ($where) $sql.=$where;
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
@@ -1089,6 +1093,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'";
if ($bentityon) // only if entity enable
$maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")";
+ else if (! empty($forceentity))
+ $sql.= " AND entity = ".(int) $forceentity;
if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask
if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask
$maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')";
diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php
index 56d19d0e0f1..b0653968c5f 100644
--- a/htdocs/core/lib/holiday.lib.php
+++ b/htdocs/core/lib/holiday.lib.php
@@ -61,3 +61,32 @@ function holiday_prepare_head($object)
return $head;
}
+
+
+/**
+ * Return array head with list of tabs to view object informations
+ *
+ * @return array head
+ */
+function holiday_admin_prepare_head()
+{
+ global $db, $langs, $conf, $user;
+
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = DOL_URL_ROOT.'/admin/holiday.php';
+ $head[$h][1] = $langs->trans("Setup");
+ $head[$h][2] = 'holiday';
+ $h++;
+
+ // Show more tabs from modules
+ // Entries must be declared in modules descriptor with line
+ // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
+ // $this->tabs = array('entity:-tabname); to remove a tab
+ complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin');
+
+ complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin','remove');
+
+ return $head;
+}
diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php
index 8187c15f684..7e8bf3ae8d7 100644
--- a/htdocs/core/lib/modulebuilder.lib.php
+++ b/htdocs/core/lib/modulebuilder.lib.php
@@ -63,7 +63,9 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
- if (! preg_match('/^(integer|date|timestamp|varchar|double|html|price)/', $addfieldentry['type']))
+
+ if (! preg_match('/^(price|boolean|sellist|integer|date|timestamp|varchar|double|text|html)/', $addfieldentry['type']))
+
{
setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
return -2;
@@ -256,11 +258,13 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
foreach($object->fields as $key => $val)
{
$i++;
-
- $type = $val['type'];
+
+ $type = $val['type'];
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
+
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
- if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
+ else if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
+ else if ($type == 'link' || $type == 'sellist') $type = 'integer';
$texttoinsert.= "\t".$key." ".$type;
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
@@ -269,7 +273,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
if ($val['default'] != '')
{
if (preg_match('/^null$/i', $val['default'])) $texttoinsert.= " DEFAULT NULL";
- else if (preg_match('/varchar/', $val['type'])) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'";
+ else if (preg_match('/varchar/', $type )) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'";
else $texttoinsert.= (($val['default'] > 0)?' DEFAULT '.$val['default']:'');
}
}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 30d6b82bb21..047e7285b0d 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1231,7 +1231,17 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
{
if ($idprod)
{
- if (empty($hidedesc)) $libelleproduitservice.=$desc;
+ if (empty($hidedesc))
+ {
+ if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST))
+ {
+ $libelleproduitservice=$desc."\n".$libelleproduitservice;
+ }
+ else
+ {
+ $libelleproduitservice.=$desc;
+ }
+ }
}
else
{
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index d157cafd5f8..73bb51d464a 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -174,11 +174,10 @@ function dol_verifyHash($chain, $hash, $type='0')
* @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'level1|level2'.
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
- * @param Canvas $objcanvas Object canvas
* @return int Always 1, die process if not allowed
* @see dol_check_secure_access_document
*/
-function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
+function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
{
global $db, $conf;
global $hookmanager;
@@ -470,13 +469,32 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
{
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
- $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
- if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity)
+ if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled))
{
- $sql.= " AND dbt.entity IS NOT NULL";
+ if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
+ {
+ if ($conf->entity == 1 && $user->admin && ! $user->entity)
+ {
+ $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
+ $sql.= " AND dbt.entity IS NOT NULL";
+ }
+ else
+ {
+ $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
+ $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
+ $sql.= " AND (ug.fk_user = dbt.rowid";
+ $sql.= " AND ug.entity IN (".getEntity('user')."))";
+ $sql.= " OR dbt.entity = 0"; // Show always superadmin
+ }
+ }
+ else {
+ $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
+ $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
+ }
}
else
{
+ $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
}
}
@@ -510,12 +528,12 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
else if (in_array($feature,$checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
{
// If external user: Check permission for external users
- if ($user->societe_id > 0)
+ if ($user->socid > 0)
{
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
- $sql.= " AND dbt.fk_soc = ".$user->societe_id;
+ $sql.= " AND dbt.fk_soc = ".$user->socid;
}
// If internal user: Check permission for internal users that are restricted on their objects
else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
@@ -578,13 +596,13 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
else if (! in_array($feature,$nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
{
// If external user: Check permission for external users
- if ($user->societe_id > 0)
+ if ($user->socid > 0)
{
if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
$sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb";
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.rowid IN (".$objectid.")";
- $sql.= " AND dbt.".$dbt_keyfield." = ".$user->societe_id;
+ $sql.= " AND dbt.".$dbt_keyfield." = ".$user->socid;
}
// If internal user: Check permission for internal users that are restricted on their objects
else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index a6f19a68086..7c4437116f3 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -122,6 +122,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
if (! empty($conf->propal->enabled)) $menuqualified++;
if (! empty($conf->commande->enabled)) $menuqualified++;
if (! empty($conf->supplier_order->enabled)) $menuqualified++;
+ if (! empty($conf->supplier_proposal->enabled)) $menuqualified++;
if (! empty($conf->contrat->enabled)) $menuqualified++;
if (! empty($conf->ficheinter->enabled)) $menuqualified++;
$tmpentry=array(
@@ -660,11 +661,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
}
// Suppliers
- if (! empty($conf->societe->enabled) && ! empty($conf->fournisseur->enabled))
+ if (! empty($conf->societe->enabled) && (! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled)))
{
$langs->load("suppliers");
- $newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, $user->rights->fournisseur->lire, '', $mainmenu, 'suppliers');
- $newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f",$langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && $user->rights->fournisseur->lire);
+ $newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire), '', $mainmenu, 'suppliers');
+ $newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f",$langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire));
}
// Contacts
@@ -785,7 +786,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 2200);
$newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201);
$newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202);
-
+ $newmenu->add("/fichinter/card-red.php?leftmenu=ficheinter", $langs->trans("ModelList"), 1, $user->rights->ficheinter->lire, '', '', '', 203);
$newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire);
}
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index a5211b11b5e..562f9eed374 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -953,7 +953,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
$sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";
$sql.= " AND entity IN (0, ".$entity.")";
- dol_syslog(get_class($this)."::_active delect activation constant", LOG_DEBUG);
+ dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) $err++;
@@ -1671,55 +1671,58 @@ class DolibarrModules // Can not be abstract, because we need to insta
// Search if perm already present
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE id = ".$r_id." AND entity = ".$entity;
- $resqlselect=$this->db->query($sql);
- $obj = $this->db->fetch_object($resqlselect);
- if ($obj->nb == 0)
+ $resqlselect=$this->db->query($sql);
+ if ($resqlselect)
{
- if (dol_strlen($r_perms) )
+ $objcount = $this->db->fetch_object($resqlselect);
+ if ($objcount && $objcount->nb == 0)
{
- if (dol_strlen($r_subperms) )
+ if (dol_strlen($r_perms) )
{
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
- $sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)";
- $sql.= " VALUES ";
- $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')";
+ if (dol_strlen($r_subperms) )
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
+ $sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)";
+ $sql.= " VALUES ";
+ $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')";
+ }
+ else
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
+ $sql.= " (id, entity, libelle, module, type, bydefault, perms)";
+ $sql.= " VALUES ";
+ $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')";
+ }
}
else
{
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
- $sql.= " (id, entity, libelle, module, type, bydefault, perms)";
- $sql.= " VALUES ";
- $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
+ $sql .= " (id, entity, libelle, module, type, bydefault)";
+ $sql .= " VALUES ";
+ $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")";
}
- }
- else
- {
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
- $sql .= " (id, entity, libelle, module, type, bydefault)";
- $sql .= " VALUES ";
- $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")";
- }
- $resqlinsert=$this->db->query($sql,1);
+ $resqlinsert=$this->db->query($sql,1);
- if (! $resqlinsert)
- {
- if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS")
+ if (! $resqlinsert)
{
- $this->error=$this->db->lasterror();
- $err++;
- break;
- }
- else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO);
+ if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS")
+ {
+ $this->error=$this->db->lasterror();
+ $err++;
+ break;
+ }
+ else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO);
+ }
+
+ $this->db->free($resqlinsert);
}
- $this->db->free($resqlinsert);
+ $this->db->free($resqlselect);
}
- $this->db->free($resqlselect);
-
// If we want to init permissions on admin users
if ($reinitadminperms)
{
@@ -1737,23 +1740,33 @@ class DolibarrModules // Can not be abstract, because we need to insta
{
$obj2=$this->db->fetch_object($resqlseladmin);
dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid);
+
$tmpuser=new User($this->db);
- $tmpuser->fetch($obj2->rowid);
- if (!empty($tmpuser->id)) {
+ $result = $tmpuser->fetch($obj2->rowid);
+ if ($result > 0) {
$tmpuser->addrights($r_id, '', '', 0, 1);
}
+ else
+ {
+ dol_syslog(get_class($this)."::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);
+ }
$i++;
}
- if (! empty($user->admin)) // Reload permission for current user if defined
- {
- // We reload permissions
- $user->clearrights();
- $user->getrights();
- }
}
- else dol_print_error($this->db);
+ else
+ {
+ dol_print_error($this->db);
+ }
}
}
+
+ if ($reinitadminperms && ! empty($user->admin)) // Reload permission for current user if defined
+ {
+ // We reload permissions
+ $user->clearrights();
+ $user->getrights();
+ }
+
}
$this->db->free($resql);
}
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 6c8fcf2f07e..a16e783d465 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -795,7 +795,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('','', $default_font_size - 4);
- // Loop on each deposits and credit notes included
+ // Loop on each discount available (deposits and credit notes and excess of payment included)
$sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
$sql.= " re.description, re.fk_facture_source,";
$sql.= " f.type, f.datef";
@@ -812,9 +812,10 @@ class pdf_crabe extends ModelePDFFactures
$y+=3;
$obj = $this->db->fetch_object($resql);
- if ($obj->type == 2) $text=$outputlangs->trans("CreditNote");
- elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit");
- else $text=$outputlangs->trans("UnknownType");
+ if ($obj->type == 2) $text=$outputlangs->transnoentities("CreditNote");
+ elseif ($obj->type == 3) $text=$outputlangs->transnoentities("Deposit");
+ elseif ($obj->type == 0) $text=$outputlangs->transnoentities("ExcessReceived");
+ else $text=$outputlangs->transnoentities("UnknownType");
$invoice->fetch($obj->fk_facture_source);
@@ -1304,7 +1305,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,0);
- $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
$depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
//print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
@@ -1322,9 +1323,10 @@ class pdf_crabe extends ModelePDFFactures
// Credit note
if ($creditnoteamount)
{
+ $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes");
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $labeltouse, 0, 'L', 0);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
}
diff --git a/htdocs/core/modules/holiday/index.html b/htdocs/core/modules/holiday/index.html
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/htdocs/core/modules/holiday/index.html
@@ -0,0 +1 @@
+
diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php
new file mode 100644
index 00000000000..a00c3825f47
--- /dev/null
+++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php
@@ -0,0 +1,132 @@
+
+ * Copyright (C) 2018 Charlene Benke
+ *
+ * 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 .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/holiday/mod_holiday_immaculate.php
+ * \ingroup contract
+ * \brief File of class to manage contract numbering rules Magre
+ */
+
+require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php';
+
+/**
+ * Class to manage contract numbering rules Magre
+ */
+class mod_holiday_immaculate extends ModelNumRefHolidays
+{
+ var $version='dolibarr';
+ var $error = '';
+ var $nom = 'Immaculate';
+ var $code_auto=1;
+
+ /**
+ * Return default description of numbering model
+ *
+ * @return string text description
+ */
+ function info()
+ {
+ global $conf,$langs;
+
+ $langs->load("bills");
+
+ $form = new Form($this->db);
+
+ $texte = $langs->trans('GenericNumRefModelDesc')." \n";
+ $texte.= '';
+
+ return $texte;
+ }
+
+ /**
+ * Return numbering example
+ *
+ * @return string Example
+ */
+ function getExample()
+ {
+ global $conf,$langs,$user;
+
+ $old_login=$user->login;
+ $user->login='UUUUUUU';
+ $numExample = $this->getNextValue($user, '');
+ $user->login=$old_login;
+
+ if (! $numExample)
+ {
+ $numExample = $langs->trans('NotConfigured');
+ }
+ return $numExample;
+ }
+
+ /**
+ * Return next value
+ *
+ * @param Societe $user user object
+ * @param Object $holiday holiday object
+ * @return string Value if OK, 0 if KO
+ */
+ function getNextValue($user, $holiday)
+ {
+ global $db,$conf;
+
+ require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
+
+ $mask=$conf->global->HOLIDAY_IMMACULATE_MASK;
+
+ if (! $mask)
+ {
+ $this->error='NotConfigured';
+ return 0;
+ }
+
+ $numFinal=get_next_value($db,$mask,'holiday','ref','', $user, $holiday->date_create);
+
+ return $numFinal;
+ }
+
+ /**
+ * Return next value
+ *
+ * @param User $fuser User object
+ * @param Object $objforref Holiday object
+ * @return string Value if OK, 0 if KO
+ */
+ function holiday_get_num($fuser, $objforref)
+ {
+ return $this->getNextValue($fuser, $objforref);
+ }
+}
diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php
new file mode 100644
index 00000000000..3b77230f77f
--- /dev/null
+++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php
@@ -0,0 +1,148 @@
+
+ * Copyright (C) 2018 Charlene Benke
+ *
+ * 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 .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/holiday/mod_holiday_madonna.php
+ * \ingroup contract
+ * \brief File of class to manage contract numbering rules Serpis
+ */
+require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php';
+
+/**
+ * Class to manage contract numbering rules madonna
+ */
+class mod_holiday_madonna extends ModelNumRefHolidays
+{
+ var $version='dolibarr';
+ var $prefix='HL';
+ var $error='';
+ var $nom='Madonna';
+ var $code_auto=1;
+
+
+ /**
+ * Return default description of numbering model
+ *
+ * @return string text description
+ */
+ function info()
+ {
+ global $langs;
+ return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
+ }
+
+
+ /**
+ * Return numbering example
+ *
+ * @return string Example
+ */
+ function getExample()
+ {
+ return $this->prefix."0501-0001";
+ }
+
+
+ /**
+ * Test if existing numbers make problems with numbering
+ *
+ * @return boolean false if conflit, true if ok
+ */
+ function canBeActivated()
+ {
+ global $conf,$langs,$db;
+
+ $coyymm=''; $max='';
+
+ $posindice=8;
+ $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
+ $sql.= " FROM ".MAIN_DB_PREFIX."holiday";
+ $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
+ $sql.= " AND entity = ".$conf->entity;
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $row = $db->fetch_row($resql);
+ if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
+ }
+ if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
+ {
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorNumRefModel', $max);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return next value
+ *
+ * @param Societe $objsoc third party object
+ * @param Object $contract contract object
+ * @return string Value if OK, 0 if KO
+ */
+ function getNextValue($objsoc,$contract)
+ {
+ global $db,$conf;
+
+ $posindice=8;
+ $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
+ $sql.= " FROM ".MAIN_DB_PREFIX."holiday";
+ $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
+ $sql.= " AND entity = ".$conf->entity;
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj) $max = intval($obj->max);
+ else $max=0;
+ }
+ else
+ {
+ dol_syslog("mod_holiday_madonna::getNextValue", LOG_DEBUG);
+ return -1;
+ }
+
+ $date=$contract->date_contrat;
+ $yymm = strftime("%y%m",$date);
+
+ if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
+ else $num = sprintf("%04s",$max+1);
+
+ dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num);
+ return $this->prefix.$yymm."-".$num;
+ }
+
+
+ /**
+ * Return next value
+ *
+ * @param User $fuser User object
+ * @param Object $objforref Holiday object
+ * @return string Value if OK, 0 if KO
+ */
+ function holiday_get_num($fuser,$objforref)
+ {
+ return $this->getNextValue($fuser,$objforref);
+ }
+
+}
diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php
new file mode 100644
index 00000000000..7e7865c87e8
--- /dev/null
+++ b/htdocs/core/modules/holiday/modules_holiday.php
@@ -0,0 +1,146 @@
+
+ * Copyright (C) 2004-2007 Laurent Destailleur
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2006 Andre Cianfarani
+ * Copyright (C) 2011 Juanjo Menent
+ * Copyright (C) 2013 Philippe Grand
+ * Copyright (C) 2014 Marcos García
+ * Copyright (C) 2018 Charlene Benke
+ *
+ * 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 .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/holiday/modules_holiday.php
+ * \ingroup contract
+ * \brief File with parent class for generating holiday to PDF and File of class to manage contract numbering
+ */
+
+ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
+
+
+/**
+ * Parent class to manage intervention document templates
+ */
+abstract class ModelePDFHoliday extends CommonDocGenerator
+{
+ var $error='';
+
+
+ /**
+ * Return list of active generation modules
+ *
+ * @param DoliDB $db Database handler
+ * @param integer $maxfilenamelength Max length of value to show
+ * @return array List of templates
+ */
+ static function liste_modeles($db,$maxfilenamelength=0)
+ {
+ global $conf;
+
+ $type='contract';
+ $liste=array();
+
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ $liste=getListOfModels($db,$type,$maxfilenamelength);
+
+ return $liste;
+ }
+}
+
+
+/**
+ * Parent class for all contract numbering modules
+ */
+class ModelNumRefHolidays
+{
+ var $error='';
+
+ /**
+ * Return if a module can be used or not
+ *
+ * @return boolean true if module can be used
+ */
+ function isEnabled()
+ {
+ return true;
+ }
+
+ /**
+ * Return default description of numbering model
+ *
+ * @return string text description
+ */
+ function info()
+ {
+ global $langs;
+ $langs->load("holidays");
+ return $langs->trans("NoDescription");
+ }
+
+ /**
+ * Return numbering example
+ *
+ * @return string Example
+ */
+ function getExample()
+ {
+ global $langs;
+ $langs->load("holidays");
+ return $langs->trans("NoExample");
+ }
+
+ /**
+ * Test if existing numbers make problems with numbering
+ *
+ * @return boolean false if conflict, true if ok
+ */
+ function canBeActivated()
+ {
+ return true;
+ }
+
+ /**
+ * Return next value
+ *
+ * @param Societe $objsoc third party object
+ * @param Object $contract contract object
+ * @return string Value
+ */
+ function getNextValue($objsoc, $contract)
+ {
+ global $langs;
+ return $langs->trans("NotAvailable");
+ }
+
+ /**
+ * Return numbering version module
+ *
+ * @return string Value
+ */
+ function getVersion()
+ {
+ global $langs;
+ $langs->load("admin");
+
+ if ($this->version == 'development') return $langs->trans("VersionDevelopment");
+ if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
+ if ($this->version == 'dolibarr') return DOL_VERSION;
+ if ($this->version) return $this->version;
+ return $langs->trans("NotAvailable");
+ }
+}
diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php
index be078b92a8e..ffaba49e36e 100644
--- a/htdocs/core/modules/modHoliday.class.php
+++ b/htdocs/core/modules/modHoliday.class.php
@@ -4,6 +4,7 @@
* Copyright (C) 2005-2010 Regis Houssin
* Copyright (C) 2011 Dimitri Mouillard
* Copyright (C) 2013 Juanjo Menent
+ * Copyright (C) 2018 Charlene Benke
*
* 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
@@ -69,9 +70,13 @@ class modHoliday extends DolibarrModules
// Data directories to create when module is enabled.
// Example: this->dirs = array("/mymodule/temp");
- $this->dirs = array();
+ $this->dirs = array("/holiday/temp");
$r=0;
+ // Config pages
+ $this->config_page_url = array("holiday.php");
+
+
// Config pages. Put here list of php page names stored in admmin directory used to setup module.
// $this->config_page_url = array("holiday.php?leftmenu=setup@holiday");
@@ -87,7 +92,29 @@ class modHoliday extends DolibarrModules
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
// 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0)
$this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
-
+ $r=0;
+
+ $this->const[$r][0] = "HOLIDAY_ADDON";
+ $this->const[$r][1] = "chaine";
+ $this->const[$r][2] = "mod_holiday_madonna";
+ $this->const[$r][3] = 'Nom du gestionnaire de numerotation des congés';
+ $this->const[$r][4] = 0;
+ $r++;
+
+ $this->const[$r][0] = "HOLIDAY_ADDON_PDF";
+ $this->const[$r][1] = "chaine";
+ $this->const[$r][2] = "celebrate";
+ $this->const[$r][3] = 'Name of PDF model of holiday';
+ $this->const[$r][4] = 0;
+ $r++;
+
+ $this->const[$r][0] = "HOLIDAY_ADDON_PDF_ODT_PATH";
+ $this->const[$r][1] = "chaine";
+ $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/holiday";
+ $this->const[$r][3] = "";
+ $this->const[$r][4] = 0;
+ $r++;
+
// Array to add new pages in new tabs
$this->tabs[] = array('data'=>'user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); // To add a new tab identified by code tabname1
diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php
index b6ba08a84a5..875820c9b6b 100644
--- a/htdocs/core/modules/modModuleBuilder.class.php
+++ b/htdocs/core/modules/modModuleBuilder.class.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2018 Nicolas ZABOURI
*
* 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
@@ -59,7 +60,7 @@ class modModuleBuilder extends DolibarrModules
// Config pages
//-------------
- $this->config_page_url = array();
+ $this->config_page_url = array('setup@modulebuilder');
// Dependancies
//-------------
diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php
index 34584ea3ffa..fa7553fd6df 100644
--- a/htdocs/core/modules/modSupplierProposal.class.php
+++ b/htdocs/core/modules/modSupplierProposal.class.php
@@ -32,7 +32,7 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
- * Class to describe and enable module AskPriceSupllier
+ * Class to describe and enable module SupplierProposal
*/
class modSupplierProposal extends DolibarrModules
{
@@ -246,7 +246,7 @@ class modSupplierProposal extends DolibarrModules
public function remove($options = '')
{
$sql = array(
- "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'"
+ "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" // To delete/clean deprecated entries
);
return $this->_remove($sql, $options);
diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php
index 13bbf9f3d84..0e1700da500 100644
--- a/htdocs/core/modules/propale/mod_propale_marbre.php
+++ b/htdocs/core/modules/propale/mod_propale_marbre.php
@@ -108,12 +108,15 @@ class mod_propale_marbre extends ModeleNumRefPropales
{
global $db,$conf;
+ // Use object entity ID
+ $entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity);
+
// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
- $sql.= " AND entity = ".$conf->entity;
+ $sql.= " AND entity = ".$entity;
$resql=$db->query($sql);
if ($resql)
diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php
index ec0b0b241e2..54d894c20b5 100644
--- a/htdocs/core/modules/propale/mod_propale_saphir.php
+++ b/htdocs/core/modules/propale/mod_propale_saphir.php
@@ -115,8 +115,14 @@ class mod_propale_saphir extends ModeleNumRefPropales
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
+ $constant = 'PROPALE_SAPHIR_MASK_'.$propal->entity;
+
// On defini critere recherche compteur
- $mask=$conf->global->PROPALE_SAPHIR_MASK;
+ if (! empty($conf->global->$constant)) {
+ $mask = $conf->global->$constant; // for multicompany proposal sharing
+ } else {
+ $mask = $conf->global->PROPALE_SAPHIR_MASK;
+ }
if (! $mask)
{
@@ -124,9 +130,12 @@ class mod_propale_saphir extends ModeleNumRefPropales
return 0;
}
+ // Use object entity ID
+ $entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity);
+
$date = $propal->date;
- $numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date);
+ $numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date,'next',false,null,$entity);
return $numFinal;
}
diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php
index e1104ef84f6..a25abbdde6a 100644
--- a/htdocs/core/tpl/advtarget.tpl.php
+++ b/htdocs/core/tpl/advtarget.tpl.php
@@ -60,7 +60,7 @@ print '