Debug v16

This commit is contained in:
Laurent Destailleur 2022-05-19 13:08:00 +02:00
parent 672a646fa9
commit 4b996f79a9
15 changed files with 172 additions and 159 deletions

View File

@ -43,17 +43,6 @@ if ($in_bookkeeping == '') {
$in_bookkeeping = 'notyet';
}
// Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if ($user->socid > 0) {
accessforbidden();
}
if (empty($user->rights->accounting->mouvements->lire)) {
accessforbidden();
}
// Get information of journal
$object = new AccountingJournal($db);
$result = $object->fetch($id_journal);
@ -65,7 +54,7 @@ if ($result > 0) {
accessforbidden($langs->trans('ErrorRecordNotFound'));
}
$hookmanager->initHooks(array('globaljournal', $object->nature_text . 'journal'));
$hookmanager->initHooks(array('globaljournal', $object->nature.'journal'));
$parameters = array();
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
@ -93,6 +82,18 @@ if (!is_array($journal_data)) {
setEventMessages($object->error, $object->errors, 'errors');
}
// Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if ($user->socid > 0) {
accessforbidden();
}
if (empty($user->rights->accounting->mouvements->lire)) {
accessforbidden();
}
/*
* Actions
*/

View File

@ -961,7 +961,7 @@ if ($action == 'create') {
if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) {
print "\n\n<div class=\"tabsAction\">\n";
if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id)) {
if (($object->statut == 1) && ($user->rights->mailing->valider || $object->user_validation == $user->id)) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=settodraft&token='.newToken().'&id='.$object->id.'">'.$langs->trans("SetToDraft").'</a>';
}
@ -1066,7 +1066,7 @@ if ($action == 'create') {
print dol_get_fiche_end();
print dol_set_focus('#sendto');
dol_set_focus('#sendto');
}

View File

@ -86,6 +86,11 @@ class Mailing extends CommonObject
*/
public $email_from;
/**
* @var string email to
*/
public $sendto;
/**
* @var string email reply to
*/
@ -175,6 +180,11 @@ class Mailing extends CommonObject
*/
public $statuts = array();
/**
* @var array substitutionarray
*/
public $substitutionarray;
/**
* Constructor

View File

@ -181,6 +181,12 @@ class Contact extends CommonObject
*/
public $email;
/**
* URL
* @var string
*/
public $url;
/**
* Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings
* @var int
@ -315,6 +321,7 @@ class Contact extends CommonObject
*/
public $stcomm_picto;
/**
* Constructor
*

View File

@ -93,12 +93,17 @@ abstract class CommonInvoice extends CommonObject
const STATUS_ABANDONED = 3;
public $totalpaid; // duplicate with sumpayed
public $totaldeposits; // duplicate with sumdeposit
public $totalcreditnotes; // duplicate with sumcreditnote
public $sumpayed;
public $sumpayed_multicurrency;
public $sumdeposit;
public $sumdeposit_multicurrency;
public $sumcreditnote;
public $sumcreditnote_multicurrency;
public $remaintopay;
/**

View File

@ -115,6 +115,11 @@ abstract class CommonObject
*/
public $array_languages = null; // Value is array() when load already tried
/**
* @var array To sotre result of ->liste_contact()
*/
public $contacts_ids;
/**
* @var mixed Array of linked objects, set and used when calling ->create() to be able to create links during the creation of object
*/

View File

@ -917,44 +917,46 @@ class dolReceiptPrinter extends Printer
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_array($resql);
if (empty($obj)) {
$error++;
$this->errors[] = 'PrinterDontExist';
}
if (!$error) {
$parameter = (isset($obj['parameter']) ? $obj['parameter'] : '');
try {
$type = $obj['fk_type'];
switch ($type) {
case 1:
$this->connector = new DummyPrintConnector();
break;
case 2:
$this->connector = new FilePrintConnector($parameter);
break;
case 3:
$parameters = explode(':', $parameter);
$this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]);
break;
case 4: // LPT1, smb://...
$this->connector = new WindowsPrintConnector(dol_sanitizePathName($parameter));
break;
case 5:
$this->connector = new CupsPrintConnector($parameter);
break;
default:
$this->connector = 'CONNECTOR_UNKNOWN';
break;
}
$this->printer = new Printer($this->connector, $this->profile);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
$error++;
}
}
} else {
$error++;
$this->errors[] = $this->db->lasterror;
}
if (empty($obj)) {
$error++;
$this->errors[] = 'PrinterDontExist';
}
if (!$error) {
$parameter = $obj['parameter'];
try {
switch ($obj['fk_type']) {
case 1:
$this->connector = new DummyPrintConnector();
break;
case 2:
$this->connector = new FilePrintConnector($parameter);
break;
case 3:
$parameters = explode(':', $parameter);
$this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]);
break;
case 4: // LPT1, smb://...
$this->connector = new WindowsPrintConnector(dol_sanitizePathName($parameter));
break;
case 5:
$this->connector = new CupsPrintConnector($parameter);
break;
default:
$this->connector = 'CONNECTOR_UNKNOWN';
break;
}
$this->printer = new Printer($this->connector, $this->profile);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
$error++;
}
}
return $error;
}
}

View File

@ -527,102 +527,100 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t
if ($mode == 'target' || preg_match('/targetwithdetails/', $mode)) {
if ($usecontact) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
if (is_object($targetcontact)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
if (!empty($targetcontact->address)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact));
} else {
$companytouseforaddress = $targetcompany;
if (!empty($targetcontact->address)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact));
} else {
$companytouseforaddress = $targetcompany;
// Contact on a thirdparty that is a different thirdparty than the thirdparty of object
if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
$targetcontact->fetch_thirdparty();
$companytouseforaddress = $targetcontact->thirdparty;
// Contact on a thirdparty that is a different thirdparty than the thirdparty of object
if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
$targetcontact->fetch_thirdparty();
$companytouseforaddress = $targetcontact->thirdparty;
}
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress));
}
// Country
if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code));
} elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
}
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress));
}
// Country
if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code));
} elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
}
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) {
// Phone
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) {
// Phone
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
}
if (!empty($targetcontact->phone_pro)) {
$stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
}
if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
$stringaddress .= " / ";
}
if (!empty($targetcontact->phone_mobile)) {
$stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
}
}
if (!empty($targetcontact->phone_pro)) {
$stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
// Fax
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
if ($targetcontact->fax) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
}
}
if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
$stringaddress .= " / ";
// EMail
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
if ($targetcontact->email) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
}
}
if (!empty($targetcontact->phone_mobile)) {
$stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
}
}
// Fax
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
if ($targetcontact->fax) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
}
}
// EMail
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
if ($targetcontact->email) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
}
}
// Web
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
if ($targetcontact->url) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
// Web
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
if ($targetcontact->url) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
}
}
}
}
} else {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany));
// Country
if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
}
if (is_object($targetcompany)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany));
// Country
if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
}
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) {
// Phone
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) {
// Phone
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
if (!empty($targetcompany->phone)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
}
if (!empty($targetcompany->phone)) {
$stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
}
}
if (!empty($targetcompany->phone)) {
$stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
// Fax
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
if ($targetcompany->fax) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
}
}
if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) {
$stringaddress .= " / ";
// EMail
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
if ($targetcompany->email) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
}
}
if (!empty($targetcompany->phone_mobile)) {
$stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
}
}
// Fax
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
if ($targetcompany->fax) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
}
}
// EMail
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
if ($targetcompany->email) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
}
}
// Web
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
if ($targetcompany->url) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
// Web
if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
if ($targetcompany->url) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
}
}
}
}

View File

@ -138,6 +138,14 @@ class pdf_beluga extends ModelePDFProjects
*/
public $emetteur;
public $posxref;
public $posxdate;
public $posxsociete;
public $posxamountht;
public $posxamountttc;
public $posstatut;
/**
* Constructor
*
@ -479,7 +487,7 @@ class pdf_beluga extends ModelePDFProjects
}
//var_dump("$key, $tablename, $datefieldname, $dates, $datee");
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, $projectField);
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, '', '', $projectField);
$num = count($elementarray);
if ($num >= 0) {
@ -492,7 +500,7 @@ class pdf_beluga extends ModelePDFProjects
$pdf->SetXY($this->posxref, $curY);
$pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L');
$selectList = $formproject->select_element($tablename, $project->thirdparty->id, '', -2, $projectField);
$selectList = $formproject->select_element($tablename, $object->thirdparty->id, '', -2, $projectField);
$nexY = $pdf->GetY() + 1;
$curY = $nexY;
$pdf->SetXY($this->posxref, $curY);
@ -790,8 +798,6 @@ class pdf_beluga extends ModelePDFProjects
*/
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
{
global $conf, $mysoc;
$heightoftitleline = 10;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@ -806,24 +812,6 @@ class pdf_beluga extends ModelePDFProjects
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size);
$pdf->SetXY($this->posxref, $tab_top + 1);
$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
$pdf->SetXY($this->posxlabel, $tab_top + 1);
$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
$pdf->SetXY($this->posxworkload, $tab_top + 1);
$pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
$pdf->SetXY($this->posxprogress, $tab_top + 1);
$pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R');
$pdf->SetXY($this->posxdatestart, $tab_top + 1);
$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, '', 0, 'C');
$pdf->SetXY($this->posxdateend, $tab_top + 1);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

View File

@ -240,7 +240,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
unset($linked_contacts);
}
if ($sendto) {
$this->composeAndSendCustomerMessage($sendto, $subject_customer, $body_customer, $see_ticket_customer, $object, $langs, $conf);
$this->composeAndSendCustomerMessage($sendto, $subject_customer, $body_customer, $see_ticket_customer, $object, $langs);
}
}
$ok = 1;

View File

@ -1029,10 +1029,8 @@ if ($step == 4 && $datatoimport) {
print '<div id="left" class="connectedSortable">'."\n";
// List of source fields
$var = true;
$lefti = 1;
foreach ($fieldssource as $key => $val) {
$var = !$var;
show_elem($fieldssource, $key, $val, $var); // key is field number in source file
$listofkeys[$key] = 1;
$fieldsplaced[$key] = 1;
@ -2210,7 +2208,7 @@ $db->close();
* @param array $fieldssource List of source fields
* @param int $pos Pos
* @param string $key Key
* @param boolean $var Line style (odd or not)
* @param boolean $var Line style (odd or not). No more used.
* @param int $nostyle Hide style
* @return void
*/

View File

@ -1422,11 +1422,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf)
if ($select_resql) {
$select_num = $db->num_rows($select_resql);
$i = 0;
$var = true;
// Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn
while (($i < $select_num) && (!$error)) {
$var = !$var;
$select_obj = $db->fetch_object($select_resql);
// Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons.

View File

@ -1367,7 +1367,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
if ($dirins && $action == 'initdic' && $module && $dicname) {
if (!$error) {
$newdicname = $dicname;
if (!preg_match('/^c_/, $newdicname')) {
if (!preg_match('/^c_/', $newdicname)) {
$newdicname = 'c_'.$dicname;
}

View File

@ -1268,6 +1268,7 @@ if ($action == 'create' || $action == 'presend') {
$companystatic = new Societe($db);
$contactstatic = new Contact($db);
$userstatic = new User($db);
$var = false;
foreach (array('internal', 'external') as $source) {
$tmpobject = $object;
$tab = $tmpobject->listeContact(-1, $source);

View File

@ -257,7 +257,7 @@ $formfile = new FormFile($db);
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewGroup"), '', 'object_group');
print dol_set_focus('#nom');
dol_set_focus('#nom');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';