diff --git a/ChangeLog b/ChangeLog
index de1482ea183..ddda40a0e31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,7 +14,7 @@ Following changes may create regressions for some external modules, but were nec
* Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook.
* Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale.
* The method static ActionComm::getActions($db, ...) is no more static. Use $actioncomm->getActions(...) instead (without $db param).
-
+* The 'action=delete&file=...' has been replaced with 'action=deletefile&file=...' to avoid confusion with deletion of object lines.
***** ChangeLog for 14.0.2 compared to 14.0.1 *****
diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php
index 1e7c38b2607..7f09e111a23 100644
--- a/htdocs/accountancy/customer/lines.php
+++ b/htdocs/accountancy/customer/lines.php
@@ -191,7 +191,14 @@ print '';
+ }
+ } elseif ($val['type'] == 'product') {
+ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
+ $form->select_produits($selected, $constname, '', 0);
+ }
+ } else {
+ print ' ';
+ }
+ print '';
+ }
+ }
+ print '';
+
+ print '
';
+ print ' ';
+ print '
';
+
+ print '';
+ print ' ';
+} else {
+ if (!empty($arrayofparameters)) {
+ print '';
+ print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
+
+ foreach ($arrayofparameters as $constname => $val) {
+ if ($val['enabled']==1) {
+ $setupnotempty++;
+ print '';
+ $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
+ print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
+ print ' ';
+
+ if ($val['type'] == 'textarea') {
+ print dol_nl2br($conf->global->{$constname});
+ } elseif ($val['type']== 'html') {
+ print $conf->global->{$constname};
+ } elseif ($val['type'] == 'yesno') {
+ print ajax_constantonoff($constname);
+ } elseif (preg_match('/emailtemplate:/', $val['type'])) {
+ include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+
+ $tmp = explode(':', $val['type']);
+
+ $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
+ if ($template<0) {
+ setEventMessages(null, $formmail->errors, 'errors');
+ }
+ print $langs->trans($template->label);
+ } elseif (preg_match('/category:/', $val['type'])) {
+ $c = new Categorie($db);
+ $result = $c->fetch($conf->global->{$constname});
+ if ($result < 0) {
+ setEventMessages(null, $c->errors, 'errors');
+ }
+ $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
+ $toprint = array();
+ foreach ($ways as $way) {
+ $toprint[] = 'color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . ' ';
+ }
+ print '' . implode(' ', $toprint) . ' ';
+ } elseif (preg_match('/thirdparty_type/', $val['type'])) {
+ if ($conf->global->{$constname}==2) {
+ print $langs->trans("Prospect");
+ } elseif ($conf->global->{$constname}==3) {
+ print $langs->trans("ProspectCustomer");
+ } elseif ($conf->global->{$constname}==1) {
+ print $langs->trans("Customer");
+ } elseif ($conf->global->{$constname}==0) {
+ print $langs->trans("NorProspectNorCustomer");
+ }
+ } elseif ($val['type'] == 'product') {
+ $product = new Product($db);
+ $resprod = $product->fetch($conf->global->{$constname});
+ if ($resprod > 0) {
+ print $product->ref;
+ } elseif ($resprod < 0) {
+ setEventMessages(null, $object->errors, "errors");
+ }
+ } else {
+ print $conf->global->{$constname};
+ }
+ print ' ';
+ }
+ }
+
+ print '
';
+
+ print '';
+ } else {
+ print ' '.$langs->trans("NothingToSetup");
+ }
+}
+
+
+if (empty($setupnotempty)) {
+ print ' '.$langs->trans("NothingToSetup");
+}
+
+// Page end
+print dol_get_fiche_end();
+
+llxFooter();
+$db->close();
diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php
index 1368fe48488..0a0e0b5973a 100644
--- a/htdocs/admin/security_file.php
+++ b/htdocs/admin/security_file.php
@@ -63,7 +63,7 @@ if ($action == 'updateform') {
if ($res3 && $res4 && $res5 && $res6) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
-} elseif ($action == 'delete') {
+} elseif ($action == 'deletefile') {
// Delete file
$langs->load("other");
$file = $conf->admin->dir_temp.'/'.GETPOST('urlfile', 'alpha');
diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php
index ec363ad112d..77200404a03 100644
--- a/htdocs/admin/tools/dolibarr_export.php
+++ b/htdocs/admin/tools/dolibarr_export.php
@@ -55,7 +55,7 @@ if (!$user->admin) {
* Actions
*/
-if ($action == 'delete') {
+if ($action == 'deletefile') {
if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha'))) {
$file = $conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha'));
$ret = dol_delete_file($file, 1);
diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index 477146fbfd1..e07574bacf5 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -73,8 +73,10 @@ $search_title = GETPOST('search_title', 'alpha');
$search_note = GETPOST('search_note', 'alpha');
$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'), 'tzuserrel');
-$datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'), 'tzuserrel');
-$dateend = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'), 'tzuserrel');
+$datestart_dtstart = dol_mktime(0, 0, 0, GETPOST('datestart_dtstartmonth', 'int'), GETPOST('datestart_dtstartday', 'int'), GETPOST('datestart_dtstartyear', 'int'), 'tzuserrel');
+$datestart_dtend = dol_mktime(23, 59, 59, GETPOST('datestart_dtendmonth', 'int'), GETPOST('datestart_dtendday', 'int'), GETPOST('datestart_dtendyear', 'int'), 'tzuserrel');
+$dateend_dtstart = dol_mktime(0, 0, 0, GETPOST('dateend_dtstartmonth', 'int'), GETPOST('dateend_dtstartday', 'int'), GETPOST('dateend_dtstartyear', 'int'), 'tzuserrel');
+$dateend_dtend = dol_mktime(23, 59, 59, GETPOST('dateend_dtendmonth', 'int'), GETPOST('dateend_dtendday', 'int'), GETPOST('dateend_dtendyear', 'int'), 'tzuserrel');
if ($search_status == '' && !GETPOSTISSET('search_status')) {
$search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
}
@@ -205,8 +207,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_id = '';
$search_title = '';
$search_note = '';
- $datestart = '';
- $dateend = '';
+ $datestart_dtstart = '';
+ $datestart_dtend = '';
+ $dateend_dtstart = '';
+ $dateend_dtend = '';
$search_status = '';
$toselect = '';
$search_array_options = array();
@@ -323,23 +327,41 @@ if ($search_title != '') {
if ($search_note != '') {
$param .= '&search_note='.urlencode($search_note);
}
-if (GETPOST('datestartday', 'int')) {
- $param .= '&datestartday='.GETPOST('datestartday', 'int');
+if (GETPOST('datestartday_dtstart', 'int')) {
+ $param .= '&datestartday_dtstart='.GETPOST('datestartday_dtstart', 'int');
}
-if (GETPOST('datestartmonth', 'int')) {
- $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int');
+if (GETPOST('datestartmonth_dtstart', 'int')) {
+ $param .= '&datestartmonth_dtstart='.GETPOST('datestartmonth_dtstart', 'int');
}
-if (GETPOST('datestartyear', 'int')) {
- $param .= '&datestartyear='.GETPOST('datestartyear', 'int');
+if (GETPOST('datestartyear_dtstart', 'int')) {
+ $param .= '&datestartyear_dtstart='.GETPOST('datestartyear_dtstart', 'int');
}
-if (GETPOST('dateendday', 'int')) {
- $param .= '&dateendday='.GETPOST('dateendday', 'int');
+if (GETPOST('datestartday_dtend', 'int')) {
+ $param .= '&datestartday_dtend='.GETPOST('datestartday_dtend', 'int');
}
-if (GETPOST('dateendmonth', 'int')) {
- $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int');
+if (GETPOST('datestartmonth_dtend', 'int')) {
+ $param .= '&datestartmonth_dtend='.GETPOST('datestartmonth_dtend', 'int');
}
-if (GETPOST('dateendyear', 'int')) {
- $param .= '&dateendyear='.GETPOST('dateendyear', 'int');
+if (GETPOST('datestartyear_dtend', 'int')) {
+ $param .= '&datestartyear_dtend='.GETPOST('datestartyear_dtend', 'int');
+}
+if (GETPOST('dateendday_dtstart', 'int')) {
+ $param .= '&dateendday_dtstart='.GETPOST('dateendday_dtstart', 'int');
+}
+if (GETPOST('dateendmonth_dtstart', 'int')) {
+ $param .= '&dateendmonth_dtstart='.GETPOST('dateendmonth_dtstart', 'int');
+}
+if (GETPOST('dateendyear_dtstart', 'int')) {
+ $param .= '&dateendyear_dtstart='.GETPOST('dateendyear_dtstart', 'int');
+}
+if (GETPOST('dateendday_dtend', 'int')) {
+ $param .= '&dateendday_dtend='.GETPOST('dateendday_dtend', 'int');
+}
+if (GETPOST('dateendmonth_dtend', 'int')) {
+ $param .= '&dateendmonth_dtend='.GETPOST('dateendmonth_dtend', 'int');
+}
+if (GETPOST('dateendyear_dtend', 'int')) {
+ $param .= '&dateendyear_dtend='.GETPOST('dateendyear_dtend', 'int');
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
@@ -502,11 +524,17 @@ if ($filtert > 0 || $usergroup > 0) {
if ($dateselect > 0) {
$sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))";
}
-if ($datestart > 0) {
- $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'";
+if ($datestart_dtstart > 0) {
+ $sql .= " AND a.datep >= '".$db->idate($datestart_dtstart)."'";
}
-if ($dateend > 0) {
- $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'";
+if ($datestart_dtend > 0) {
+ $sql .= " AND a.datep <= '".$db->idate($datestart_dtend)."'";
+}
+if ($dateend_dtstart > 0) {
+ $sql .= " AND a.datep2 >= '".$db->idate($dateend_dtstart)."'";
+}
+if ($dateend_dtend > 0) {
+ $sql .= " AND a.datep2 <= '".$db->idate($dateend_dtend)."'";
}
// Add where from extra fields
@@ -723,12 +751,22 @@ if (!empty($arrayfields['a.note']['checked'])) {
}
if (!empty($arrayfields['a.datep']['checked'])) {
print '';
- print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
+ print '';
+ print $form->selectDate($datestart_dtstart, 'datestart_dtstart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
+ print '
';
+ print '';
+ print $form->selectDate($datestart_dtend, 'datestart_dtend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'), 'tzuserrel');
+ print '
';
print ' ';
}
if (!empty($arrayfields['a.datep2']['checked'])) {
print '';
- print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
+ print '';
+ print $form->selectDate($dateend_dtstart, 'dateend_dtstart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
+ print '
';
+ print '';
+ print $form->selectDate($dateend_dtend, 'dateend_dtend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'), 'tzuserrel');
+ print '
';
print ' ';
}
if (!empty($arrayfields['s.nom']['checked'])) {
diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php
index 9b6238ca0de..b75c93df799 100644
--- a/htdocs/comm/action/rapport/index.php
+++ b/htdocs/comm/action/rapport/index.php
@@ -163,7 +163,7 @@ if ($resql) {
// Button to build doc
print '';
- print 'month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').' ';
+ print 'month).'&year='.((int) $obj->year).'">'.img_picto($langs->trans('BuildDoc'), 'filenew').' ';
print ' ';
$name = "actions-".$obj->month."-".$obj->year.".pdf";
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 764af7a232a..d41749577b6 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -3745,8 +3745,9 @@ if ($action == 'create') {
print ' '."\n";
print ' '."\n";
print ' '."\n";
- print ' ';
- print ' ';
+ // The commented lines below are fields already added as hidden parameters before
+ //print ' ';
+ //print ' ';
switch (get_class($objectsrc)) {
case 'Propal':
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index 7e5a7047060..084d24ebfdb 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -81,6 +81,12 @@ if ($type == 'bank-transfer') {
}
}
+if ($type == 'bank-transfer') {
+ $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
+} else {
+ $usercancreate = $user->rights->facture->creer;
+}
+
/*
* Actions
@@ -93,7 +99,7 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
- if ($action == "new") {
+ if ($action == "new" && $usercancreate) {
if ($object->id > 0) {
$db->begin();
@@ -117,7 +123,7 @@ if (empty($reshook)) {
$action = '';
}
- if ($action == "delete") {
+ if ($action == "delete" && $usercancreate) {
if ($object->id > 0) {
$result = $object->demande_prelevement_delete($user, GETPOST('did', 'int'));
if ($result == 0) {
@@ -126,6 +132,83 @@ if (empty($reshook)) {
}
}
}
+
+ // payments conditions
+ if ($action == 'setconditions' && $usercancreate) {
+ $object->fetch($id);
+ $object->cond_reglement_code = 0; // To clean property
+ $object->cond_reglement_id = 0; // To clean property
+
+ $error = 0;
+
+ $db->begin();
+
+ if (!$error) {
+ $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
+ if ($result < 0) {
+ $error++;
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+
+ if (!$error) {
+ $old_date_echeance = $object->date_echeance;
+ $new_date_echeance = $object->calculate_date_lim_reglement();
+ if ($new_date_echeance > $old_date_echeance) {
+ $object->date_echeance = $new_date_echeance;
+ }
+ if ($object->date_echeance < $object->date) {
+ $object->date_echeance = $object->date;
+ }
+ $result = $object->update($user);
+ if ($result < 0) {
+ $error++;
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+
+ if ($error) {
+ $db->rollback();
+ } else {
+ $db->commit();
+ }
+ } elseif ($action == 'setmode' && $usercancreate) {
+ // payment mode
+ $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
+ } elseif ($action == 'setdatef' && $usercancreate) {
+ $newdate = dol_mktime(0, 0, 0, GETPOST('datefmonth', 'int'), GETPOST('datefday', 'int'), GETPOST('datefyear', 'int'), 'tzserver');
+ if ($newdate > (dol_now('tzuserrel') + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
+ if (empty($conf->global->INVOICE_MAX_FUTURE_DELAY)) {
+ setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings');
+ } else {
+ setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings');
+ }
+ }
+
+ $object->date = $newdate;
+ $date_echence_calc = $object->calculate_date_lim_reglement();
+ if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) {
+ $object->date_echeance = $date_echence_calc;
+ }
+ if ($object->date_echeance && $object->date_echeance < $object->date) {
+ $object->date_echeance = $object->date;
+ }
+
+ $result = $object->update($user);
+ if ($result < 0) {
+ dol_print_error($db, $object->error);
+ }
+ } elseif ($action == 'setdate_lim_reglement' && $usercancreate) {
+ $object->date_echeance = dol_mktime(12, 0, 0, GETPOST('date_lim_reglementmonth', 'int'), GETPOST('date_lim_reglementday', 'int'), GETPOST('date_lim_reglementyear', 'int'));
+ if (!empty($object->date_echeance) && $object->date_echeance < $object->date) {
+ $object->date_echeance = $object->date;
+ setEventMessages($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), null, 'warnings');
+ }
+ $result = $object->update($user);
+ if ($result < 0) {
+ dol_print_error($db, $object->error);
+ }
+ }
}
@@ -206,6 +289,34 @@ if ($object->id > 0) {
$head = facture_prepare_head($object);
}
+ $numopen = 0;
+ $pending = 0;
+ $numclosed = 0;
+
+ // How many Direct debit or Credit transfer open requests ?
+
+ $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
+ $sql .= " , pfd.date_traite as date_traite";
+ $sql .= " , pfd.amount";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+ if ($type == 'bank-transfer') {
+ $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
+ } else {
+ $sql .= " WHERE fk_facture = ".((int) $object->id);
+ }
+ $sql .= " AND pfd.traite = 0";
+ $sql .= " AND pfd.ext_payment_id IS NULL";
+ $sql .= " ORDER BY pfd.date_demande DESC";
+
+ $result_sql = $db->query($sql);
+ if ($result_sql) {
+ $num = $db->num_rows($result_sql);
+ $numopen = $num;
+ } else {
+ dol_print_error($db);
+ }
+
+
print dol_get_fiche_head($head, 'standingorders', $title, -1, ($type == 'bank-transfer' ? 'supplier_invoice' : 'bill'));
// Invoice content
@@ -363,14 +474,14 @@ if ($object->id > 0) {
print $langs->trans('DateInvoice');
print '';
if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) {
- print 'id.'">'.img_edit($langs->trans('SetDate'), 1).' ';
+ print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).' ';
}
print '';
print '';
if ($object->type != $object::TYPE_CREDIT_NOTE) {
if ($action == 'editinvoicedate') {
- $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date, 'invoicedate');
+ print $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date, 'invoicedate', 0, 0, 1, $type);
} else {
print dol_print_date($object->date, 'day');
}
@@ -386,13 +497,13 @@ if ($object->id > 0) {
print $langs->trans('PaymentConditionsShort');
print ' ';
if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) {
- print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).' ';
+ print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetConditions'), 1).' ';
}
print '';
print '';
if ($object->type != $object::TYPE_CREDIT_NOTE) {
if ($action == 'editconditions') {
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
+ $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 0, $type);
} else {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none');
}
@@ -407,7 +518,7 @@ if ($object->id > 0) {
print $langs->trans('DateMaxPayment');
print ' ';
if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) {
- print 'id.'">'.img_edit($langs->trans('SetDate'), 1).' ';
+ print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).' ';
}
print '';
print '';
@@ -418,7 +529,7 @@ if ($object->id > 0) {
}
if ($action == 'editpaymentterm') {
- $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $duedate, 'paymentterm');
+ print $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $duedate, 'paymentterm', 0, 0, 1, $type);
} else {
print dol_print_date($duedate, 'day');
if ($object->hasDelay()) {
@@ -436,12 +547,16 @@ if ($object->id > 0) {
print $langs->trans('PaymentMode');
print ' ';
if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) {
- print 'id.'">'.img_edit($langs->trans('SetMode'), 1).' ';
+ print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetMode'), 1).' ';
}
print '';
print '';
+ $filtertype = 'CRDT';
+ if ($type == 'bank-transfer') {
+ $filtertype = 'DBIT';
+ }
if ($action == 'editmode') {
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id');
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', $filtertype, 1, 0, $type);
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none');
}
@@ -453,7 +568,7 @@ if ($object->id > 0) {
print $langs->trans('BankAccount');
print ' ';
if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) {
- print ' id.'">'.img_edit($langs->trans('SetBankAccount'), 1).' ';
+ print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetBankAccount'), 1).' ';
}
print '';
print '';
@@ -481,7 +596,9 @@ if ($object->id > 0) {
print img_warning('Error on default bank number for IBAN : '.$bac->error_message);
}
} else {
- print img_warning($langs->trans("NoDefaultIBANFound"));
+ if ($numopen || ($type != 'bank-transfer' && $object->mode_reglement_code == 'PRE') || ($type == 'bank-transfer' && $object->mode_reglement_code == 'VIR')) {
+ print img_warning($langs->trans("NoDefaultIBANFound"));
+ }
}
print ' ';
@@ -565,34 +682,6 @@ if ($object->id > 0) {
print dol_get_fiche_end();
- $numopen = 0;
- $pending = 0;
- $numclosed = 0;
-
-
- // How many Direct debit opened requests ?
-
- $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
- $sql .= " , pfd.date_traite as date_traite";
- $sql .= " , pfd.amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
- if ($type == 'bank-transfer') {
- $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
- } else {
- $sql .= " WHERE fk_facture = ".((int) $object->id);
- }
- $sql .= " AND pfd.traite = 0";
- $sql .= " AND pfd.ext_payment_id IS NULL";
- $sql .= " ORDER BY pfd.date_demande DESC";
-
- $result_sql = $db->query($sql);
- if ($result_sql) {
- $num = $db->num_rows($result_sql);
- $numopen = $num;
- } else {
- dol_print_error($db);
- }
-
// For which amount ?
$sql = "SELECT SUM(pfd.amount) as amount";
diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php
index a3da2812067..2a42d4a3d00 100644
--- a/htdocs/core/ajax/ajaxdirpreview.php
+++ b/htdocs/core/ajax/ajaxdirpreview.php
@@ -396,9 +396,9 @@ if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) {
//$param.=($param?'?':'').(preg_replace('/^&/','',$param));
-if ($useajax || $action == 'delete') {
+if ($useajax || $action == 'deletefile') {
$urlfile = '';
- if ($action == 'delete') {
+ if ($action == 'deletefile') {
$urlfile = GETPOST('urlfile', 'alpha');
}
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index 6aefc1f2d74..97090895500 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -86,13 +86,23 @@ class box_contacts extends ModeleBoxes
$sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
- $sql .= ", s.code_client, s.code_compta, s.client";
+ $sql .= ", s.code_client, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
+ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
+ $sql .= ", spe.accountancy_code_customer as code_compta";
+ $sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
+ } else {
+ $sql .= ", s.code_compta";
+ $sql .= ", s.code_compta_fournisseur";
+ }
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", co.label as country, co.code as country_code";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
+ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
+ }
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php
index 3b6e857b058..c78e5b7dec9 100644
--- a/htdocs/core/boxes/box_factures_imp.php
+++ b/htdocs/core/boxes/box_factures_imp.php
@@ -88,7 +88,12 @@ class box_factures_imp extends ModeleBoxes
if ($user->rights->facture->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
- $sql .= ", s.code_client, s.code_compta, s.client";
+ $sql .= ", s.code_client, s.client";
+ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
+ $sql .= ", spe.accountancy_code_customer as code_compta";
+ } else {
+ $sql .= ", s.code_compta";
+ }
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
$sql .= ", f.ref, f.date_lim_reglement as datelimite";
@@ -100,6 +105,9 @@ class box_factures_imp extends ModeleBoxes
$sql .= ", f.paye, f.fk_statut as status, f.rowid as facid";
$sql .= ", sum(pf.amount) as am";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
+ }
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
@@ -115,7 +123,12 @@ class box_factures_imp extends ModeleBoxes
if ($user->socid) {
$sql .= " AND s.rowid = ".((int) $user->socid);
}
- $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,";
+ $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,";
+ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
+ $sql .= " spe.accountancy_code_customer as code_compta,";
+ } else {
+ $sql .= " s.code_compta,";
+ }
$sql .= " f.ref, f.date_lim_reglement,";
$sql .= " f.type, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.fk_statut, f.rowid";
//$sql.= " ORDER BY f.datef DESC, f.ref DESC ";
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 004dc184fa9..cf64e298784 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -3618,7 +3618,7 @@ abstract class CommonObject
public function add_object_linked($origin = null, $origin_id = null, $f_user = null, $notrigger = 0)
{
// phpcs:enable
- global $user;
+ global $user, $hookmanager, $action;
$origin = (!empty($origin) ? $origin : $this->origin);
$origin_id = (!empty($origin_id) ? $origin_id : $this->origin_id);
$f_user = isset($f_user) ? $f_user : $user;
@@ -3636,6 +3636,23 @@ abstract class CommonObject
if ($origin == 'supplierorder') {
$origin = 'order_supplier';
}
+
+ $targettype = $this->element;
+
+ $parameters = array('sourcetype'=>$sourcetype, 'sourceid'=>$sourceid, 'targettype'=>$targettype, 'targetid'=>$targetid);
+ // Hook for explicitly set the targettype if it must be differtent than $this->element
+ $reshook = $hookmanager->executeHooks('setLinkedObjectSourceTargetType', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) {
+ if (!empty($hookmanager->resArray['targettype'])) $targettype = $hookmanager->resArray['targettype'];
+ if (!empty($hookmanager->resArray['sourcetype'])) $sourcetype = $hookmanager->resArray['sourcetype'];
+ }
+
+ // Elements of the core modules which have `$module` property but may to which we don't want to prefix module part to the element name for finding the linked object in llx_element_element.
+ // It's because an entry for this element may be exist in llx_element_element before this modification (version <=14.2) and ave named only with their element name in fk_source or fk_target.
+ $coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization');
+ // Add module part to target type if object has $module property and isn't in core modules.
+ $targettype = ((!empty($this->module) && ! in_array($this->module, $coremodule)) ? $this->module.'_' : '').$this->element;
+
$this->db->begin();
$error = 0;
@@ -3648,7 +3665,7 @@ abstract class CommonObject
$sql .= ((int) $origin_id);
$sql .= ", '" . $this->db->escape($origin) . "'";
$sql .= ", " . ((int) $this->id);
- $sql .= ", '" . $this->db->escape($this->element) . "'";
+ $sql .= ", '" . $this->db->escape($targettype) . "'";
$sql .= ")";
dol_syslog(get_class($this) . "::add_object_linked", LOG_DEBUG);
@@ -3701,7 +3718,7 @@ abstract class CommonObject
*/
public function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1)
{
- global $conf;
+ global $conf, $hookmanager, $action;
$this->linkedObjectsIds = array();
$this->linkedObjects = array();
@@ -3711,6 +3728,16 @@ abstract class CommonObject
$withtargettype = false;
$withsourcetype = false;
+ $parameters = array('sourcetype'=>$sourcetype, 'sourceid'=>$sourceid, 'targettype'=>$targettype, 'targetid'=>$targetid);
+ // Hook for explicitly set the targettype if it must be differtent than $this->element
+ $reshook = $hookmanager->executeHooks('setLinkedObjectSourceTargetType', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) {
+ if (!empty($hookmanager->resArray['sourcetype'])) $sourcetype = $hookmanager->resArray['sourcetype'];
+ if (!empty($hookmanager->resArray['sourceid'])) $sourceid = $hookmanager->resArray['sourceid'];
+ if (!empty($hookmanager->resArray['targettype'])) $targettype = $hookmanager->resArray['targettype'];
+ if (!empty($hookmanager->resArray['targetid'])) $targetid = $hookmanager->resArray['targetid'];
+ }
+
if (!empty($sourceid) && !empty($sourcetype) && empty($targetid)) {
$justsource = true; // the source (id and type) is a search criteria
if (!empty($targettype)) {
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 37155a4566e..c69b794a011 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3884,8 +3884,8 @@ class Form
* @param string $htmlname Nom de la zone select
* @param int $filtertype Not used
* @param int $addempty Add an empty entry
- * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
- * @param string $morecss Add more CSS on select tag
+ * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
+ * @param string $morecss Add more CSS on select tag
* @return void
*/
public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '')
@@ -5108,17 +5108,21 @@ class Form
* @param string $selected Id condition pre-selectionne
* @param string $htmlname Name of select html field
* @param int $addempty Add empty entry
+ * @param string $type Type ('direct-debit' or 'bank-transfer')
* @return void
*/
- public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0)
+ public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0, $type = '')
{
// phpcs:enable
global $langs;
if ($htmlname != "none") {
- print '';
} else {
@@ -5212,10 +5216,11 @@ class Form
* @param int $displayhour Display hour selector
* @param int $displaymin Display minutes selector
* @param int $nooutput 1=No print output, return string
+ * @param string $type 'direct-debit' or 'bank-transfer'
* @return string
* @see selectDate()
*/
- public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0)
+ public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type = '')
{
// phpcs:enable
global $langs;
@@ -5223,9 +5228,12 @@ class Form
$ret = '';
if ($htmlname != "none") {
- $ret .= '