Merge branch '15.0' of https://github.com/Dolibarr/dolibarr into FIX_year_interval_select_date

This commit is contained in:
kevin 2022-08-17 17:21:45 +02:00
commit 9ad4c114de
13 changed files with 122 additions and 39 deletions

View File

@ -1169,14 +1169,16 @@ if ($id) {
$sql .= natural_search("code_iso", $search_code);
} elseif ($search_code != '' && $id == 28) {
$sql .= natural_search("h.code", $search_code);
} elseif ($search_code != '' && $id == 32) {
} elseif ($search_code != '' && ($id == 7 || $id == 32)) {
$sql .= natural_search("a.code", $search_code);
} elseif ($search_code != '' && $id == 3) {
$sql .= natural_search("r.code_region", $search_code);
} elseif ($search_code != '' && $id == 7) {
$sql .= natural_search("a.code", $search_code);
} elseif ($search_code != '' && $id == 10) {
} elseif ($search_code != '' && ($id == 8 || $id == 10)) {
$sql .= natural_search("t.code", $search_code);
} elseif ($search_code != '' && $id == 1) {
$sql .= natural_search("f.code", $search_code);
} elseif ($search_code != '' && $id == 2) {
$sql .= natural_search("d.code_departement", $search_code);
} elseif ($search_code != '' && $id != 9) {
$sql .= natural_search("code", $search_code);
}

View File

@ -190,7 +190,6 @@ if ($mode == 'setup' && $user->admin) {
$tokenobj = null;
// Token
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
// Dolibarr storage
$storage = new DoliStorage($db, $conf);
try {

View File

@ -3721,7 +3721,7 @@ class Propal extends CommonObject
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @param null|array $moreparams Array to provide more information
* @param null|array $moreparams Array to provide more information
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)

View File

@ -250,6 +250,7 @@ if ($date_endyear) {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
if ($modecompta == 'BOOKKEEPING') {
print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 ');
} else {
@ -261,6 +262,8 @@ if ($modecompta == 'BOOKKEEPING') {
} else {
if ($modecompta == 'CREANCES-DETTES') {
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], 'amount_ht', '', $param, 'class="right"', $sortfield, $sortorder);
} else {
print_liste_field_titre(''); // Make 4 columns in total whatever $modecompta is
}
print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], 'amount_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
}
@ -1525,18 +1528,24 @@ print '</tr>';
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Income").'</td>';
if ($modecompta == 'CREANCES-DETTES') {
print '<td class="liste_total right">'.price(price2num($total_ht_income, 'MT')).'</td>';
} else {
print '<td></td>';
}
print '<td class="liste_total right">'.price(price2num($total_ttc_income, 'MT')).'</td>';
print '</tr>';
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Outcome").'</td>';
if ($modecompta == 'CREANCES-DETTES') {
print '<td class="liste_total right">'.price(price2num(-$total_ht_outcome, 'MT')).'</td>';
} else {
print '<td></td>';
}
print '<td class="liste_total right">'.price(price2num(-$total_ttc_outcome, 'MT')).'</td>';
print '</tr>';
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
if ($modecompta == 'CREANCES-DETTES') {
print '<td class="liste_total right">'.price(price2num($total_ht, 'MT')).'</td>';
} else {
print '<td></td>';
}
print '<td class="liste_total right">'.price(price2num($total_ttc, 'MT')).'</td>';
print '</tr>';

View File

@ -53,6 +53,7 @@ if (is_numeric($entity)) {
define("DOLENTITY", $entity);
}
include '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$action = GETPOST('action', 'aZ09');
@ -69,7 +70,7 @@ $type = $mode;
// Check securitykey
$securekeyseed = '';
if ($type == 'proposal') {
$securekeyseed = $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN;
$securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN');
}
if (!dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) {
@ -122,28 +123,71 @@ if ($action == "importSignature") {
}
if (!$error) {
$newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
// Defined modele of doc
$last_main_doc_file = $object->last_main_doc;
$directdownloadlink = $object->getLastMainDocLink('proposal'); // url to download the $object->last_main_doc
$pdf = pdf_getInstance();
$pdf->Open();
$pdf->AddPage();
$pagecount = $pdf->setSourceFile($upload_dir.$ref.".pdf"); // original PDF
if (preg_match('/\.pdf/i', $last_main_doc_file)) {
// TODO Use the $last_main_doc_file to defined the $newpdffilename and $sourcefile
$newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
$sourcefile = $upload_dir.$ref.".pdf";
for ($i=1;$i<($pagecount+1);$i++) {
if ($i>1) $pdf->AddPage();
$tppl=$pdf->importPage($i);
$pdf->useTemplate($tppl);
if (dol_is_file($sourcefile)) {
// We build the new PDF
$pdf = pdf_getInstance();
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($langs));
if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
$pdf->SetCompression(false);
}
//$pdf->Open();
$pagecount = $pdf->setSourceFile($sourcefile); // original PDF
$s = array(); // Array with size of each page. Exemple array(w'=>210, 'h'=>297);
for ($i=1; $i<($pagecount+1); $i++) {
try {
$tppl = $pdf->importPage($i);
$s = $pdf->getTemplatesize($tppl);
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
$pdf->useTemplate($tppl);
} catch (Exception $e) {
dol_syslog("Error when manipulating some PDF by onlineSign: ".$e->getMessage(), LOG_ERR);
$response = $e->getMessage();
$error++;
}
}
// A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
// TODO Get position of box from PDF template
$xforimgstart = (empty($s['w']) ? 120 : round($s['w'] / 2) + 15);
$yforimgstart = (empty($s['h']) ? 240 : $s['h'] - 60);
$wforimg = $s['w'] - 20 - $xforimgstart;
$pdf->Image($upload_dir.$filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4)); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset.
//$pdf->Close();
$pdf->Output($newpdffilename, "F");
// Index the new file and update the last_main_doc property of object.
$object->indexFile($newpdffilename, 1);
}
} elseif (preg_match('/\.odt/i', $last_main_doc_file)) {
// Adding signature on .ODT not yet supported
// TODO
} else {
// Document format not supported to insert online signature.
// We should just create an image file with the signature.
}
}
$pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset.
$pdf->Close();
$pdf->Output($newpdffilename, "F");
if (!$error) {
$db->begin();
// Index the new file and update the last_main_doc property of object.
$object->indexFile($newpdffilename, 1);
$online_sign_ip = getUserRemoteIP();
$online_sign_name = ''; // TODO Ask name on form to sign

View File

@ -941,7 +941,8 @@ abstract class CommonObject
// Add entry into index
if ($initsharekey) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
// TODO We can't, we dont' have full path of file, only last_main_doc adn ->element, so we must rebuild full path first
// TODO We can't, we dont' have full path of file, only last_main_doc and ->element, so we must first rebuild full path $destfull
/*
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;

View File

@ -1013,7 +1013,9 @@ class Conf
}
if (empty($handler_file_found)) {
throw new Exception('Missing log handler file '.$handler.'.php');
// If log handler has been removed of is badly setup, we must be able to continue code.
//throw new Exception('Missing log handler file '.$handler.'.php');
continue;
}
require_once $handler_file_found;

View File

@ -91,7 +91,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
if ($mode == 1) {
$out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)";
} else {
$out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.$object->entity, '0');
$out .= '&securekey='.dol_hash($securekeyseed.$type.$ref, '0');
}
/*
if ($mode == 1) {

View File

@ -863,7 +863,7 @@ class ImportXlsx extends ModeleImports
if (empty($keyfield)) {
$keyfield = 'rowid';
}
$sqlSelect .= "WHERE " . $keyfield . " = " .((int) $lastinsertid);
$sqlSelect .= " WHERE " . $keyfield . " = " .((int) $lastinsertid);
$resql = $this->db->query($sqlSelect);
if ($resql) {

View File

@ -467,6 +467,24 @@ class KnowledgeRecord extends CommonObject
$this->error .= $this->db->lasterror();
$errorflag = -1;
}
// Delete all child tables
if (!$error) {
$elements = array('categorie_knowledgemanagement');
foreach ($elements as $table) {
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$table;
$sql .= " WHERE fk_knowledgemanagement = ".(int) $this->id;
$result = $this->db->query($sql);
if (!$result) {
$error++;
$this->errors[] = $this->db->lasterror();
}
}
}
}
return $this->deleteCommon($user, $notrigger);
//return $this->deleteCommon($user, $notrigger, 1);
}

View File

@ -16,7 +16,7 @@
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
* Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
*
@ -1796,7 +1796,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
// We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF.
$doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%');
$doleditor = new DolEditor('desc', GETPOSTISSET('desc') ? GETPOST('desc', 'restricthtml') : $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%');
$doleditor->Create();
print "</td></tr>";
@ -1806,7 +1806,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
print '<tr><td>'.$langs->trans("PublicUrl").'</td><td>';
print img_picto('', 'globe', 'class="pictofixedwidth"');
print '<input type="text" name="url" class="quatrevingtpercent" value="'.$object->url.'">';
print '<input type="text" name="url" class="quatrevingtpercent" value="'.(GETPOSTISSET('url') ? GETPOST('url') : $object->url).'">';
print '</td></tr>';
}

View File

@ -39,7 +39,7 @@ if (!defined('NOBROWSERNOTIF')) {
// For MultiCompany module.
// Do not use GETPOST here, function is not defined and define 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.
// Because 2 entities can have the same ref.
$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
if (is_numeric($entity)) {
define("DOLENTITY", $entity);
@ -51,7 +51,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
// Load translation files
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "members", "paybox", "propal"));
@ -125,6 +124,7 @@ $creditor = $mysoc->name;
$type = $source;
if ($source == 'proposal') {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$object = new Propal($db);
$object->fetch(0, $ref, '', $entity);
} else {
@ -139,7 +139,7 @@ if ($source == 'proposal') {
$securekeyseed = $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN;
}
if (!dol_verifyHash($securekeyseed.$type.$ref.$object->entity, $SECUREKEY, '0')) {
if (!dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) {
http_response_code(403);
print 'Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref);
exit(-1);
@ -318,9 +318,19 @@ if ($source == 'proposal') {
// Object
$text = '<b>'.$langs->trans("SignatureProposalRef", $object->ref).'</b>';
print '<tr class="CTableRow2"><td class="CTableRow2 tdtop">'.$langs->trans("Designation");
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
print '</td><td class="CTableRow2">'.$text;
$last_main_doc_file = $object->last_main_doc;
if ($object->status == $object::STATUS_VALIDATED) {
if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
// It seems document has never been generated, or was generated and then deleted.
// So we try to regenerate it with its default template.
$defaulttemplate = ''; // We force the use an empty string instead of $object->model_pdf to be sure to use a "main" default template and not the last one used.
$object->generateDocument($defaulttemplate, $langs);
}
$directdownloadlink = $object->getLastMainDocLink('proposal');
if ($directdownloadlink) {
print '<br><a href="'.$directdownloadlink.'">';
@ -328,13 +338,11 @@ if ($source == 'proposal') {
print $langs->trans("DownloadDocument").'</a>';
}
} else {
$last_main_doc_file = $object->last_main_doc;
if ($object->status == $object::STATUS_NOTSIGNED) {
$directdownloadlink = $object->getLastMainDocLink('proposal');
if ($directdownloadlink) {
print '<br><a href="'.$directdownloadlink.'">';
print img_mime($object->last_main_doc, '');
print img_mime($last_main_doc_file, '');
print $langs->trans("DownloadDocument").'</a>';
}
} elseif ($object->status == $object::STATUS_SIGNED || $object->status == $object::STATUS_BILLED) {
@ -359,8 +367,6 @@ if ($source == 'proposal') {
print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
print '<input type="hidden" name="ref" value="'.$object->ref.'">';
print '</td></tr>'."\n";
// TODO Add link to download PDF (similar code than for invoice)
}

View File

@ -364,6 +364,7 @@ if ($ispaymentok) {
}
if (empty($user->rights->facture)) {
$user->rights->facture = new stdClass();
$user->rights->facture->invoice_advance = new stdClass();
}
if (empty($user->rights->adherent)) {
$user->rights->adherent = new stdClass();
@ -371,6 +372,7 @@ if ($ispaymentok) {
}
$user->rights->societe->creer = 1;
$user->rights->facture->creer = 1;
$user->rights->facture->invoice_advance->validate = 1;
$user->rights->adherent->cotisation->creer = 1;
if (array_key_exists('MEM', $tmptag) && $tmptag['MEM'] > 0) {