Merge remote-tracking branch 'Dolibarr/13.0' into 13

This commit is contained in:
Francis Appels 2021-01-21 21:21:35 +01:00
commit d4a9db0d49
13 changed files with 90 additions and 53 deletions

View File

@ -76,7 +76,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'create';
} else {
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid='.((int) $conf->global->CHARTOFACCOUNTS);
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
$result = $db->query($sql);

View File

@ -16,7 +16,6 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
@ -307,7 +306,7 @@ if ($action != 'export_csv')
$accountingaccountstatic->fetch(null, $line->numero_compte, true);
if (!empty($accountingaccountstatic->account_number)) {
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 0, '', 0, -1, 0, 'accountcard');
} else {
$accounting_account = length_accountg($line->numero_compte);
}
@ -322,10 +321,19 @@ if ($action != 'export_csv')
$root_account_description = $tmparrayforrootaccount['label'];
$root_account_number = $tmparrayforrootaccount['account_number'];
//var_dump($tmparrayforrootaccount);
//var_dump($accounting_account);
//var_dump($accountingaccountstatic);
if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) {
$link = '<a class="editfielda reposition" href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=update&token=' . newToken() . '&id=' . $accountingaccountstatic->id . '">' . img_edit() . '</a>';
} elseif (empty($tmparrayforrootaccount['label'])) {
} elseif ($accounting_account == 'NotDefined') {
$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
} elseif (empty($tmparrayforrootaccount['label'])) {
// $tmparrayforrootaccount['label'] not defined = the account has not parent with a parent.
// This is useless, we should not create a new account when an account has no parent, we must edit it to fix its parent.
// BUG 1: Accounts on level root or level 1 must not have a parent 2 level higher, so shoule not show a link to create another account.
// BUG 2: Adding a link to create a new accounting account here is useless because it is not add as parent of the orphelin.
//$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
}
if (!empty($show_subgroup))
@ -363,8 +371,22 @@ if ($action != 'export_csv')
print '<tr class="oddeven">';
print '<td>'.$accounting_account.'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowraponall right">'.price($opening_balance).'</td>';
print '<td class="nowraponall right">'.price($line->debit).'</td>';
print '<td class="nowraponall right">'.price($line->credit).'</td>';
$urlzoom = '';
if ($line->numero_compte) {
$urlzoom = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($line->numero_compte).'&search_accountancy_code_end='.urlencode($line->numero_compte);
if (GETPOSTISSET('date_startmonth')) {
$urlzoom .= '&search_date_startmonth='.GETPOST('date_startmonth', 'int').'&search_date_startday='.GETPOST('date_startday', 'int').'&search_date_startyear='.GETPOST('date_startyear', 'int');
}
if (GETPOSTISSET('date_endmonth')) {
$urlzoom .= '&search_date_endmonth='.GETPOST('date_endmonth', 'int').'&search_date_endday='.GETPOST('date_endday', 'int').'&search_date_endyear='.GETPOST('date_endyear', 'int');
}
}
// Debit
print '<td class="nowraponall right"><a href="'.$urlzoom.'">'.price($line->debit).'</a></td>';
// Credit
print '<td class="nowraponall right"><a href="'.$urlzoom.'">'.price($line->credit).'</a></td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowraponall right">'.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
} else {

View File

@ -63,9 +63,11 @@ $accountingjournal->fetch(null, $journal_code);
$journal_label = $accountingjournal->label;
$subledger_account = GETPOST('subledger_account', 'alphanohtml');
if ($subledger_account == - 1) {
if ($subledger_account == -1) {
$subledger_account = null;
}
$subledger_label = GETPOST('subledger_label', 'alphanohtml');
$label_operation = GETPOST('label_operation', 'alphanohtml');
$debit = price2num(GETPOST('debit', 'alpha'));
$credit = price2num(GETPOST('credit', 'alpha'));
@ -108,6 +110,7 @@ if ($action == "confirm_update") {
} else {
$object->numero_compte = $accountingaccount_number;
$object->subledger_account = $subledger_account;
$object->subledger_label = $subledger_label;
$object->label_compte = $accountingaccount_label;
$object->label_operation = $label_operation;
$object->debit = $debit;
@ -160,6 +163,7 @@ if ($action == "confirm_update") {
$object->numero_compte = $accountingaccount_number;
$object->subledger_account = $subledger_account;
$object->subledger_label = $subledger_label;
$object->label_compte = $accountingaccount_label;
$object->label_operation = $label_operation;
$object->debit = $debit;
@ -578,7 +582,7 @@ if ($action == 'create')
print '<br>';
$result = $object->fetchAllPerMvt($piece_num, $mode);
$result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
@ -630,9 +634,10 @@ if ($action == 'create')
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1);
} else {
print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">';
print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">';
}
// TODO Add also the label
// Add also input for subledger label
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="'.(GETPOSTISSET("subledger_label") ? GETPOST("subledger_label", "alpha") : $line->subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">';
print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation).'"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value="'.(GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)).'"></td>';
@ -644,20 +649,24 @@ if ($action == 'create')
} else {
$accountingaccount->fetch(null, $line->numero_compte, true);
print '<td>'.$accountingaccount->getNomUrl(0, 1, 1, '', 0).'</td>';
print '<td>'.length_accounta($line->subledger_account).'</td>';
print '<td>'.length_accounta($line->subledger_account);
if ($line->subledger_label) {
print ' - <span class="opacitymedium">'.$line->subledger_label.'</span>';
}
print '</td>';
print '<td>'.$line->label_operation.'</td>';
print '<td class="nowrap right">'.price($line->debit).'</td>';
print '<td class="nowrap right">'.price($line->credit).'</td>';
print '<td class="center">';
print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$line->id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">';
print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$line->id.'&piece_num='.urlencode($line->piece_num).'&mode='.urlencode($mode).'&token='.urlencode(newToken()).'">';
print img_edit('', 0, 'class="marginrightonly"');
print '</a> &nbsp;';
$actiontodelete = 'delete';
if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete = 'confirm_delete';
print '<a href="'.$_SERVER["PHP_SELF"].'?action='.$actiontodelete.'&id='.$line->id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action='.$actiontodelete.'&id='.$line->id.'&piece_num='.urlencode($line->piece_num).'&mode='.urlencode($mode).'&token='.urlencode(newToken()).'">';
print img_delete();
print '</a>';
@ -688,9 +697,9 @@ if ($action == 'create')
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print $formaccounting->select_auxaccount('', 'subledger_account', 1);
} else {
print '<input type="text" class="maxwidth150" name="subledger_account" value="">';
print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">';
}
// TODO Add also the label
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">';
print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.$label_operation.'"/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';

View File

@ -1914,25 +1914,24 @@ class BookKeeping extends CommonObject
/**
* Return id and description of a root accounting account.
* This function takes the parent of parent to get the root account !
* FIXME: This function takes the parent of parent to get the root account !
*
* @param string $account Accounting account
* @return string Root account
* @return array Array with root account information (max 2 upper level)
*/
public function getRootAccount($account = null)
{
global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT root.rowid, root.account_number, root.label as label";
$sql = "SELECT root.rowid, root.account_number, root.label as label,";
$sql .= " parent.rowid as parent_rowid, parent.account_number as parent_account_number, parent.label as parent_label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = ".((int) $pcgver);
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid AND parent.active = 1";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid AND root.active = 1";
$sql .= " WHERE aa.account_number = '".$this->db->escape($account)."'";
$sql .= " AND parent.active = 1";
$sql .= " AND root.active = 1";
$sql .= " AND aa.entity IN (".getEntity('accountancy').")";
dol_syslog(get_class($this)."::select_account sql=".$sql, LOG_DEBUG);
@ -1943,7 +1942,8 @@ class BookKeeping extends CommonObject
$obj = $this->db->fetch_object($resql);
}
return array('id'=>$obj->rowid, 'account_number'=>$obj->account_number, 'label'=>$obj->label);
$result = array('id'=>$obj->rowid, 'account_number'=>$obj->account_number, 'label'=>$obj->label);
return $result;
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(__METHOD__." ".$this->error, LOG_ERR);

View File

@ -51,6 +51,7 @@ $type = 'action';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
$reg = array();
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
{
$code = $reg[1];

View File

@ -21,7 +21,7 @@
* \brief Code for actions on setting notes of object page
*/
// $error must have been initialized to 0
// $action must be defined
// $arrayofparameters must be set for action 'update'
// $nomessageinupdate can be set to 1
@ -31,7 +31,6 @@ if ($action == 'update' && is_array($arrayofparameters))
{
$db->begin();
$ok = true;
foreach ($arrayofparameters as $key => $val)
{
// Modify constant only if key was posted (avoid resetting key to the null value)
@ -40,7 +39,7 @@ if ($action == 'update' && is_array($arrayofparameters))
$result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result < 0)
{
$ok = false;
$error++;
break;
}
}
@ -93,7 +92,11 @@ if ($action == 'setModuleOptions')
if (!$tmpdir) {
unset($listofdir[$key]); continue;
}
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
if (!is_dir($tmpdir)) {
if (empty($nomessageinsetmoduleoptions)) {
setEventMessages($langs->trans("ErrorDirNotFound", $tmpdir), null, 'warnings');
}
}
else {
$upload_dir = $tmpdir;
}

View File

@ -340,13 +340,12 @@ class pdf_strato extends ModelePDFContract
$datere = $langs->trans("Unknown");
}
$txtpredefinedservice = '';
$txtpredefinedservice = $objectligne->product_label;
if ($objectligne->product_label)
{
$txtpredefinedservice .= ' - ';
$txtpredefinedservice .= $objectligne->product_label;
}
$txtpredefinedservice = $objectligne->product_ref;
if ($objectligne->product_label)
{
$txtpredefinedservice .= ' - ';
$txtpredefinedservice .= $objectligne->product_label;
}
$desc = dol_htmlentitiesbr($objectligne->desc, 1); // Desc (not empty for free lines)
$txt = '';

View File

@ -8,11 +8,11 @@ MenuBOM=Bills of material
LatestBOMModified=Latest %s Bills of materials modified
LatestMOModified=Latest %s Manufacturing Orders modified
Bom=Bills of Material
BillOfMaterials=Bill of Material
BillOfMaterials=Bill of Materials
BOMsSetup=Setup of module BOM
ListOfBOMs=List of bills of material - BOM
ListOfManufacturingOrders=List of Manufacturing Orders
NewBOM=New bill of material
NewBOM=New bill of materials
ProductBOMHelp=Product to create with this BOM.<br>Note: Products with the property 'Nature of product' = 'Raw material' are not visible into this list.
BOMsNumberingModules=BOM numbering templates
BOMsModelModule=BOM document templates
@ -22,7 +22,7 @@ FreeLegalTextOnBOMs=Free text on document of BOM
WatermarkOnDraftBOMs=Watermark on draft BOM
FreeLegalTextOnMOs=Free text on document of MO
WatermarkOnDraftMOs=Watermark on draft MO
ConfirmCloneBillOfMaterials=Are you sure you want to clone the bill of material %s ?
ConfirmCloneBillOfMaterials=Are you sure you want to clone the bill of materials %s ?
ConfirmCloneMo=Are you sure you want to clone the Manufacturing Order %s ?
ManufacturingEfficiency=Manufacturing efficiency
ConsumptionEfficiency=Consumption efficiency
@ -30,8 +30,8 @@ ValueOfMeansLoss=Value of 0.95 means an average of 5%% of loss during the produc
ValueOfMeansLossForProductProduced=Value of 0.95 means an average of 5%% of loss of produced product
DeleteBillOfMaterials=Delete Bill Of Materials
DeleteMo=Delete Manufacturing Order
ConfirmDeleteBillOfMaterials=Are you sure you want to delete this Bill Of Material?
ConfirmDeleteMo=Are you sure you want to delete this Bill Of Material?
ConfirmDeleteBillOfMaterials=Are you sure you want to delete this Bill Of Materials?
ConfirmDeleteMo=Are you sure you want to delete this Bill Of Materials?
MenuMRP=Manufacturing Orders
NewMO=New Manufacturing Order
QtyToProduce=Qty to produce

View File

@ -106,7 +106,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
if (!$sortfield) { reset($object->fields); $sortfield="t.".key($object->fields); } // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null.
if (!$sortorder) $sortorder = "ASC";
// Initialize array of search criterias

View File

@ -105,7 +105,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType,
$landingPage = 'Billing';
}
dol_syslog("expresscheckout redirect with callSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
dol_syslog("print_paypal_redirect expresscheckout redirect with callSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
$resArray = callSetExpressCheckout(
$paymentAmount,
$currencyCodeType,
@ -127,6 +127,8 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType,
$desc
);
dol_syslog("print_paypal_redirect resArray=".var_export($resArray, true), LOG_DEBUG);
$ack = strtoupper($resArray["ACK"]);
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING")
{
@ -134,6 +136,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType,
// Redirect to paypal.com here
$payPalURL = $API_Url.$token;
dol_syslog("Redirect to ".$payPalURL, LOG_INFO);
header("Location: ".$payPalURL);
exit;
} else {
@ -282,7 +285,7 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType,
$_SESSION["FinalPaymentAmt"] = $paymentAmount;
$_SESSION["currencyCodeType"] = $currencyCodeType;
$_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole'
$_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip
$_SESSION['ipaddress'] = getUserRemoteIP(); // Payer ip
//'---------------------------------------------------------------------------------------------------------------
//' Make the API call to PayPal
@ -433,7 +436,7 @@ function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCar
$nvpstr = $nvpstr . "&CITY=" . urlencode($city);
$nvpstr = $nvpstr . "&STATE=" . urlencode($state);
$nvpstr = $nvpstr . "&COUNTRYCODE=" . urlencode($countryCode);
$nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR'];
$nvpstr = $nvpstr . "&IPADDRESS=" . getUserRemotIP();
$nvpstr = $nvpstr . "&INVNUM=" . urlencode($tag);
$resArray=hash_call("DoDirectPayment", $nvpstr);

View File

@ -31,7 +31,7 @@ if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined
if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1');
// For MultiCompany module.
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
// Do not use GETPOST here, function is not defined and this test must be done before including main.inc.php
// TODO This should be useless. Because entity must be retrieve from object ref and not from url.
$entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1));
if (is_numeric($entity)) define("DOLENTITY", $entity);

View File

@ -409,7 +409,7 @@ if ($ispaymentok)
$postactionmessages[] = $errmsg;
$ispostactionok = -1;
} else {
$postactionmessages[] = 'Subscription created';
$postactionmessages[] = 'Subscription created (id='.$crowid.')';
$ispostactionok = 1;
}
}

View File

@ -586,16 +586,16 @@ if (empty($reshook)) {
if (!$error) {
$result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
if ($result > 0) {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
$action = 'view';
} else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
if ($result < 0) { $error++; }
}
if ($error) $action = 'edit_extras';
if ($error) {
setEventMessages($object->error, $object->errors, 'errors');
$action = 'edit_extras';
} else {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
$action = 'view';
}
}
if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $user->rights->ticket->write) {