Merge branch 'develop' of https://github.com/dolibarr/dolibarr into develop

This commit is contained in:
Laurent Destailleur 2020-11-30 07:50:26 +01:00
commit 6af9c9f857
161 changed files with 1885 additions and 1685 deletions

View File

@ -13,5 +13,5 @@ jobs:
- name: Exakat
uses: docker://exakat/exakat-ga
with:
ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant'
ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant'
ignore_dirs: '/htdocs/includes,/build,/dev,/doc,/scripts,/test'

View File

@ -6,8 +6,6 @@
os: linux
dist: xenial
#dist: bionic
# Deprecated: The key sudo has no effect anymore.
#sudo: required
language: php
@ -33,49 +31,25 @@ addons:
# We need pgloader for import mysql database into pgsql
- pgloader
php:
- '5.6'
- '7.4'
- nightly
env:
global:
# Set to true for very verbose output
- DEBUG=false
jobs:
# MariaDB overrides MySQL installation so it's not possible to test both yet
#- DB=mariadb
- DB=mysql
- DB=postgresql
# See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP
#- WS=apache
# See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test
#- WS=nginx
jobs:
fast_finish: true
allow_failures:
- php: nightly
# We exclude some combinations not usefull to save Travis CPU
exclude:
- php: '7.0'
env: DB=mysql
- php: '7.1'
env: DB=mysql
- php: '7.2'
env: DB=mysql
- php: '7.3'
env: DB=mysql
- php: '7.0'
env: DB=postgresql
- php: '7.1'
env: DB=postgresql
- php: '7.2'
env: DB=postgresql
- php: '7.3'
env: DB=postgresql
- php: nightly
env: DB=postgresql
include:
- if: type = push
php: '5.6'
env: DB=postgresql
- if: type = pull_request OR type = push
php: '7.4'
env: DB=mysql
- if: type = push AND branch = develop
php: nightly
env: DB=mysql
notifications:
email:
@ -146,7 +120,7 @@ install:
- |
echo "Adding path of binaries tools installed by composer to the PATH"
export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$TRAVIS_BUILD_DIR/vendor/bin:$TRAVIS_BUILD_DIR/htdocs/includes:$PATH"
export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH"
echo $PATH
ls $TRAVIS_BUILD_DIR/vendor
ls $TRAVIS_BUILD_DIR/htdocs/includes/bin
@ -426,7 +400,7 @@ script:
php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log
# Enable modules not enabled into original dump
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log
echo $?
cd -
set +e

View File

@ -125,6 +125,11 @@ $checksumconcat=array();
$outputfile=$outputdir.'/filelist-'.$release.'.xml';
$fp = fopen($outputfile, 'w');
if (empty($fp)) {
print 'Failed to open file '.$outputfile."\n";
exit(-1);
}
fputs($fp, '<?xml version="1.0" encoding="UTF-8" ?>'."\n");
fputs($fp, '<checksum_list version="'.$release.'" date="'.dol_print_date(dol_now(), 'dayhourrfc').'" generator="'.$script_file.'">'."\n");

View File

@ -227,8 +227,8 @@ if ($action != 'export_csv')
$moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0);
$moreforfilter .= ' - ';
$moreforfilter .= $langs->trans('ShowSubtotalByGroup').': ';
$moreforfilter .= '<input type="checkbox" name="show_subgroup" value="show_subgroup"'.($show_subgroup == 'show_subgroup' ? ' checked' : '').'>';
$moreforfilter .= '<label for="show_subgroup">'.$langs->trans('ShowSubtotalByGroup').'</label>: ';
$moreforfilter .= '<input type="checkbox" name="show_subgroup" id="show_subgroup" value="show_subgroup"'.($show_subgroup == 'show_subgroup' ? ' checked' : '').'>';
$moreforfilter .= '</div>';
@ -272,6 +272,8 @@ if ($action != 'export_csv')
$total_credit = 0;
$sous_total_debit = 0;
$sous_total_credit = 0;
$total_opening_balance = 0;
$sous_total_opening_balance = 0;
$displayed_account = "";
$accountingaccountstatic = new AccountingAccount($db);
@ -302,7 +304,13 @@ if ($action != 'export_csv')
$link = '';
$total_debit += $line->debit;
$total_credit += $line->credit;
$root_account_description = $object->get_compte_racine($line->numero_compte);
$opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0;
$total_opening_balance += $opening_balance;
$tmparrayforrootaccount = $object->getRootAccount($line->numero_compte);
$root_account_description = $tmparrayforrootaccount['label'];
$root_account_number = $tmparrayforrootaccount['account_number'];
if (empty($accountingaccountstatic->account_number)) {
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>';
}
@ -311,14 +319,14 @@ if ($action != 'export_csv')
if (!empty($show_subgroup))
{
// Show accounting account
if (empty($displayed_account) || $root_account_description != $displayed_account) {
if (empty($displayed_account) || $root_account_number != $displayed_account) {
// Show subtotal per accounting account
if ($displayed_account != "") {
print '<tr class="liste_total">';
print '<td class="right" colspan="2">'.$langs->trans("SubTotal").':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td class="nowrap right">'.price(price2num($sous_total_credit - $sous_total_debit)).'</td>';
print '<td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_credit - $sous_total_debit)).'</td>';
print "<td></td>\n";
print '</tr>';
}
@ -328,18 +336,18 @@ if ($action != 'export_csv')
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
print '</tr>';
$displayed_account = $root_account_description;
$displayed_account = $root_account_number;
$sous_total_debit = 0;
$sous_total_credit = 0;
$sous_total_opening_balance = 0;
}
}
// $object->get_compte_racine($line->numero_compte);
print '<td>'.$accounting_account.'</td>';
print '<td class="nowraponall right">'.price($opening_balances["'".$line->numero_compte."'"]).'</td>';
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>';
print '<td class="nowraponall right">'.price(price2num($line->debit - $line->credit, 'MT')).'</td>';
print '<td class="nowraponall right">'.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
print '<td class="center">'.$link;
print '</td>';
print "</tr>\n";
@ -347,16 +355,17 @@ if ($action != 'export_csv')
// Records the sub-total
$sous_total_debit += $line->debit;
$sous_total_credit += $line->credit;
$sous_total_opening_balance += $opening_balance;
}
if (!empty($show_subgroup))
{
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')).'</td>';
print "<td></td>\n";
print '</tr>';
}
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_debit - $total_credit)).'</td>';
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')).'</td>';
print "<td></td>\n";
print '</tr>';

View File

@ -630,7 +630,7 @@ else $buttonLabel = $langs->trans("ExportList");
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
// Button re-export
// Button re-export
if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
$newcardbutton = '<a class="valignmiddle" href="' . $_SERVER['PHP_SELF'] . '?action=setreexport&token=' . newToken() . '&value=0' . ($param ? '&' . $param : '') . '">' . img_picto($langs->trans("Activated"), 'switch_on') . '</a> ';
} else {

View File

@ -1898,23 +1898,22 @@ class BookKeeping extends CommonObject
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Description of a root accounting account
* Return id and description of a root accounting account.
* This function takes the parent of parent to get the root account !
*
* @param string $account Accounting account
* @return string Root account
*/
public function get_compte_racine($account = null)
public function getRootAccount($account = null)
{
// phpcs:enable
global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT root.account_number, root.label as label";
$sql = "SELECT root.rowid, root.account_number, root.label as 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 = ".$pcgver;
$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 .= " WHERE aa.account_number = '".$this->db->escape($account)."'";
@ -1930,7 +1929,7 @@ class BookKeeping extends CommonObject
$obj = $this->db->fetch_object($resql);
}
return $obj->label;
return array('id'=>$obj->rowid, 'account_number'=>$obj->account_number, 'label'=>$obj->label);
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(__METHOD__." ".$this->error, LOG_ERR);

View File

@ -1988,11 +1988,11 @@ class Adherent extends CommonObject
* @param int $withpictoimg 0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small)
* @param int $maxlen length max label
* @param string $option Page for link ('card', 'category', 'subscription', ...)
* @param string $mode ''=Show firstname+lastname as label (using default order), 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref
* @param string $mode ''=Show firstname+lastname as label (using default order), 'firstname'=Show only firstname, 'lastname'=Show only lastname, 'login'=Show login, 'ref'=Show ref
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @param int $notooltip 1=Disable tooltip
* @param int $addlinktonotes 1=Add link to notes
* @param int $addlinktonotes 1=Add link to notes
* @return string Chaine avec URL
*/
public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
@ -2072,7 +2072,7 @@ class Adherent extends CommonObject
} elseif ($mode == 'ref') {
$result .= $this->id;
} else {
$result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : -1), $maxlen);
$result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : ($mode == 'lastname' ? 4 : -1)), $maxlen);
}
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= '</span>';
}

View File

@ -250,11 +250,16 @@ class Subscription extends CommonObject
$this->db->begin();
if (!is_numeric($this->amount)) {
$this->error = 'BadValueForParameterAmount';
return -1;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET ";
$sql .= " fk_type = ".$this->fk_type.",";
$sql .= " fk_adherent = ".$this->fk_adherent.",";
$sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').",";
$sql .= " subscription = '".price2num($this->amount)."',";
$sql .= " subscription = ".price2num($this->amount).",";
$sql .= " dateadh='".$this->db->idate($this->dateh)."',";
$sql .= " datef='".$this->db->idate($this->datef)."',";
$sql .= " datec='".$this->db->idate($this->datec)."',";

View File

@ -333,7 +333,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
if (is_object($object->invoice)) {
if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) {
$invoicediroutput = $conf->facture->dir_output;
$fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+');
$file = $fileparams['fullname'];

View File

@ -433,9 +433,7 @@ while ($i < min($num, $limit)) {
// Lastname
if (!empty($arrayfields['d.lastname']['checked'])) {
$adherent->firstname = '';
print '<td>'.$adherent->getNomUrl(-1).'</td>';
$adherent->firstname = $obj->firstname;
print '<td>'.$adherent->getNomUrl(-1, 0, 'card', 'lastname').'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Firstname

View File

@ -232,8 +232,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -168,8 +168,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -297,8 +297,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -406,11 +406,12 @@ print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmlt
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'.($conf->global->MAIN_INFO_SOCIETE_ADDRESS ? $conf->global->MAIN_INFO_SOCIETE_ADDRESS : GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml')).'</textarea></td></tr>'."\n";
// Zip
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<input class="minwidth100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP ? $conf->global->MAIN_INFO_SOCIETE_ZIP : GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha')).'"></td></tr>'."\n";
print '<input class="width100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP ? $conf->global->MAIN_INFO_SOCIETE_ZIP : GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha')).'"></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth100" id="MAIN_INFO_SOCIETE_TOWN" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN ? $conf->global->MAIN_INFO_SOCIETE_TOWN : GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml')).'"></td></tr>'."\n";
print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth200" id="MAIN_INFO_SOCIETE_TOWN" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN ? $conf->global->MAIN_INFO_SOCIETE_TOWN : GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml')).'"></td></tr>'."\n";
// Country
print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';

View File

@ -229,7 +229,11 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
}
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -229,7 +229,8 @@ foreach ($dirmodels as $reldir)
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -234,7 +234,8 @@ foreach ($dirmodels as $reldir)
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -238,8 +238,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -313,8 +313,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -291,8 +291,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -229,7 +229,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -241,8 +241,8 @@ print '<input type="hidden" name="action" value="update">';
clearstatcache();
print '<br>';
print '<table summary="edit" class="noborder centpercent editmode">';
print '<tr class="liste_titre"><th>'.$langs->trans("Language").'</th><th></th>';
print '<table summary="edit" class="noborder centpercent editmode tableforfield">';
print '<tr class="liste_titre"><th>'.img_picto('', 'language').' '.$langs->trans("Language").'</th><th></th>';
print '</tr>';
// Default language

View File

@ -268,6 +268,7 @@ if (empty($reshook)) {
if ($value == 'content') continue;
if ($value == 'content_lines') continue;
// Rename some POST variables into a generic name
if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid];
if ((!isset($_POST[$value]) || $_POST[$value] == '' || $_POST[$value] == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
@ -306,6 +307,7 @@ if (empty($reshook)) {
if ($value == 'lang') $keycode = 'langcode';
if (empty($keycode)) $keycode = $value;
// Clean input variables
if ($value == 'entity') $_POST[$keycode] = $conf->entity;
if ($value == 'fk_user' && !($_POST[$keycode] > 0)) $_POST[$keycode] = '';
if ($value == 'private' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '0';
@ -319,11 +321,11 @@ if (empty($reshook)) {
if (!$user->admin) { // A non admin user can only edit its own template
$sql .= " ".((int) $user->id);
} else {
$sql .= " ".((int) GETPOST($keycode, 'fk_user'));
$sql .= " ".((int) GETPOST($keycode, 'int'));
}
} elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
} elseif (in_array($keycode, array('joinfile', 'private', 'position'))) {
} elseif (in_array($keycode, array('joinfiles', 'private', 'position'))) {
$sql .= (int) GETPOST($keycode, 'int');
} else {
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
@ -362,6 +364,7 @@ if (empty($reshook)) {
if ($field == 'lang') $keycode = 'langcode';
if (empty($keycode)) $keycode = $field;
// Rename some POST variables into a generic name
if ($field == 'fk_user' && !($_POST['fk_user'] > 0)) $_POST['fk_user'] = '';
if ($field == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid];
if ($field == 'joinfiles') $_POST['joinfiles'] = $_POST['joinfiles-'.$rowid];
@ -378,11 +381,11 @@ if (empty($reshook)) {
if (!$user->admin) { // A non admin user can only edit its own template
$sql .= " ".((int) $user->id);
} else {
$sql .= " ".((int) GETPOST($keycode, 'fk_user'));
$sql .= " ".((int) GETPOST($keycode, 'int'));
}
} elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
} elseif (in_array($keycode, array('joinfile', 'private', 'position'))) {
} elseif (in_array($keycode, array('joinfiles', 'private', 'position'))) {
$sql .= (int) GETPOST($keycode, 'int');
} else {
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
@ -393,7 +396,7 @@ if (empty($reshook)) {
$sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
if (!$user->admin) { // A non admin user can only edit its own template
$sql .= " AND fk_user = ".$user->id;
$sql .= " AND fk_user = ".((int) $user->id);
}
//print $sql;exit;
dol_syslog("actionmodify", LOG_DEBUG);
@ -414,7 +417,7 @@ if (empty($reshook)) {
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."=".((int) $rowid);
if (!$user->admin) { // A non admin user can only edit its own template
$sql .= " AND fk_user = ".$user->id;
$sql .= " AND fk_user = ".((int) $user->id);
}
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);

View File

@ -34,13 +34,14 @@ $langs->loadLangs(array("other", "admin"));
$cancel = GETPOST('cancel', 'alphanohtml'); // We click on a Cancel button
$confirm = GETPOST('confirm');
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$dirstandard = array();
$dirsmartphone = array();
$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
foreach ($dirmenus as $dirmenu)
{
foreach ($dirmenus as $dirmenu) {
$dirstandard[] = $dirmenu.'standard';
$dirsmartphone[] = $dirmenu.'smartphone';
}
@ -56,8 +57,12 @@ $menu_handler_smartphone = preg_replace('/_frontoffice.php/i', '', $menu_handler
$menu_handler = $menu_handler_top;
if (GETPOST("handler_origine")) $menu_handler = GETPOST("handler_origine");
if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler");
if (GETPOST("handler_origine")) {
$menu_handler = GETPOST("handler_origine");
}
if (GETPOST("menu_handler")) {
$menu_handler = GETPOST("menu_handler");
}
@ -65,22 +70,16 @@ if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler");
* Actions
*/
if ($action == 'update')
{
if (!$cancel)
{
if ($action == 'update') {
if (!$cancel) {
$leftmenu = ''; $mainmenu = '';
if (GETPOST('menuIdParent', 'alphanohtml') && !is_numeric(GETPOST('menuIdParent', 'alphanohtml')))
{
if (GETPOST('menuIdParent', 'alphanohtml') && !is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) {
$tmp = explode('&', GETPOST('menuIdParent', 'alphanohtml'));
foreach ($tmp as $s)
{
if (preg_match('/fk_mainmenu=/', $s))
{
foreach ($tmp as $s) {
if (preg_match('/fk_mainmenu=/', $s)) {
$mainmenu = preg_replace('/fk_mainmenu=/', '', $s);
}
if (preg_match('/fk_leftmenu=/', $s))
{
if (preg_match('/fk_leftmenu=/', $s)) {
$leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
}
}
@ -88,31 +87,31 @@ if ($action == 'update')
$menu = new Menubase($db);
$result = $menu->fetch(GETPOST('menuId', 'int'));
if ($result > 0)
{
$menu->title = GETPOST('titre', 'alphanohtml');
$menu->leftmenu = GETPOST('leftmenu', 'aZ09');
$menu->url = GETPOST('url', 'alphanohtml');
$menu->langs = GETPOST('langs', 'alphanohtml');
$menu->position = GETPOST('position', 'int');
$menu->enabled = GETPOST('enabled', 'alphanohtml');
$menu->perms = GETPOST('perms', 'alphanohtml');
$menu->target = GETPOST('target', 'alphanohtml');
$menu->user = GETPOST('user', 'alphanohtml');
$menu->mainmenu = GETPOST('propertymainmenu', 'alphanohtml');
if (is_numeric(GETPOST('menuIdParent', 'alphanohtml')))
{
$menu->fk_menu = GETPOST('menuIdParent', 'alphanohtml');
if ($result > 0) {
$menu->title = (string) GETPOST('titre', 'alphanohtml');
$menu->leftmenu = (string) GETPOST('leftmenu', 'aZ09');
$menu->url = (string) GETPOST('url', 'alphanohtml');
$menu->langs = (string) GETPOST('langs', 'alphanohtml');
$menu->position = (int) GETPOST('position', 'int');
$menu->enabled = (string) GETPOST('enabled', 'alphanohtml');
$menu->perms = (string) GETPOST('perms', 'alphanohtml');
$menu->target = (string) GETPOST('target', 'alphanohtml');
$menu->user = (string) GETPOST('user', 'alphanohtml');
$menu->mainmenu = (string) GETPOST('propertymainmenu', 'alphanohtml');
if (is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) {
$menu->fk_menu = (int) GETPOST('menuIdParent', 'alphanohtml');
} else {
if (GETPOST('type', 'alphanohtml') == 'top') $menu->fk_menu = 0;
else $menu->fk_menu = -1;
if (GETPOST('type', 'alphanohtml') == 'top') {
$menu->fk_menu = 0;
} else {
$menu->fk_menu = -1;
}
$menu->fk_mainmenu = $mainmenu;
$menu->fk_leftmenu = $leftmenu;
}
$result = $menu->update($user);
if ($result > 0)
{
if ($result > 0) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} else {
setEventMessages($menu->error, $menu->errors, 'errors');
@ -130,26 +129,21 @@ if ($action == 'update')
}
}
if ($action == 'add')
{
if ($cancel)
{
if ($action == 'add') {
if ($cancel) {
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
exit;
}
$leftmenu = ''; $mainmenu = '';
if (GETPOST('menuId', 'alphanohtml', 3) && !is_numeric(GETPOST('menuId', 'alphanohtml', 3)))
{
$leftmenu = '';
$mainmenu = '';
if (GETPOST('menuId', 'alphanohtml', 3) && !is_numeric(GETPOST('menuId', 'alphanohtml', 3))) {
$tmp = explode('&', GETPOST('menuId', 'alphanohtml', 3));
foreach ($tmp as $s)
{
if (preg_match('/fk_mainmenu=/', $s))
{
foreach ($tmp as $s) {
if (preg_match('/fk_mainmenu=/', $s)) {
$mainmenu = preg_replace('/fk_mainmenu=/', '', $s);
}
if (preg_match('/fk_leftmenu=/', $s))
{
if (preg_match('/fk_leftmenu=/', $s)) {
$leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
}
}
@ -158,70 +152,64 @@ if ($action == 'add')
$langs->load("errors");
$error = 0;
if (!$error && !$_POST['menu_handler'])
{
if (!$error && !$_POST['menu_handler']) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors');
$action = 'create';
$error++;
}
if (!$error && !$_POST['type'])
{
if (!$error && !$_POST['type']) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
$action = 'create';
$error++;
}
if (!$error && !$_POST['url'])
{
if (!$error && !$_POST['url']) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors');
$action = 'create';
$error++;
}
if (!$error && !$_POST['titre'])
{
if (!$error && !$_POST['titre']) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
$action = 'create';
$error++;
}
if (!$error && $_POST['menuId'] && $_POST['type'] == 'top')
{
if (!$error && $_POST['menuId'] && $_POST['type'] == 'top') {
setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors');
$action = 'create';
$error++;
}
if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left')
{
if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left') {
setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors');
$action = 'create';
$error++;
}
if (!$error)
{
if (!$error) {
$menu = new Menubase($db);
$menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09'));
$menu->type = GETPOST('type', 'alphanohtml');
$menu->title = GETPOST('titre', 'alphanohtml');
$menu->url = GETPOST('url', 'alphanohtml');
$menu->langs = GETPOST('langs', 'alphanohtml');
$menu->position = GETPOST('position', 'int');
$menu->enabled = GETPOST('enabled', 'alphanohtml');
$menu->perms = GETPOST('perms', 'alphanohtml');
$menu->target = GETPOST('target', 'alphanohtml');
$menu->user = GETPOST('user', 'alphanohtml');
$menu->mainmenu = GETPOST('propertymainmenu', 'alphanohtml');
if (is_numeric(GETPOST('menuId', 'alphanohtml', 3)))
{
$menu->fk_menu = GETPOST('menuId', 'alphanohtml', 3);
$menu->type = (string) GETPOST('type', 'alphanohtml');
$menu->title = (string) GETPOST('titre', 'alphanohtml');
$menu->url = (string) GETPOST('url', 'alphanohtml');
$menu->langs = (string) GETPOST('langs', 'alphanohtml');
$menu->position = (int) GETPOST('position', 'int');
$menu->enabled = (string) GETPOST('enabled', 'alphanohtml');
$menu->perms = (string) GETPOST('perms', 'alphanohtml');
$menu->target = (string) GETPOST('target', 'alphanohtml');
$menu->user = (string) GETPOST('user', 'alphanohtml');
$menu->mainmenu = (string) GETPOST('propertymainmenu', 'alphanohtml');
if (is_numeric(GETPOST('menuId', 'alphanohtml', 3))) {
$menu->fk_menu = (int) GETPOST('menuId', 'alphanohtml', 3);
} else {
if (GETPOST('type', 'alphanohtml') == 'top') $menu->fk_menu = 0;
else $menu->fk_menu = -1;
if (GETPOST('type', 'alphanohtml') == 'top') {
$menu->fk_menu = 0;
} else {
$menu->fk_menu = -1;
}
$menu->fk_mainmenu = $mainmenu;
$menu->fk_leftmenu = $leftmenu;
}
$result = $menu->create($user);
if ($result > 0)
{
if ($result > 0) {
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09'));
exit;
} else {
@ -232,15 +220,13 @@ if ($action == 'add')
}
// delete
if ($action == 'confirm_delete' && $confirm == 'yes')
{
if ($action == 'confirm_delete' && $confirm == 'yes') {
$db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int');
$result = $db->query($sql);
if ($result == 0)
{
if ($result == 0) {
$db->commit();
llxHeader();
@ -268,8 +254,7 @@ $formadmin = new FormAdmin($db);
llxHeader('', $langs->trans("Menu"));
if ($action == 'create')
{
if ($action == 'create') {
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_topleft()
@ -305,14 +290,11 @@ if ($action == 'create')
// Id
$parent_rowid = GETPOST('menuId', 'int');
if (GETPOST('menuId', 'int'))
{
if (GETPOST('menuId', 'int')) {
$sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int');
$res = $db->query($sql);
if ($res)
{
while ($menu = $db->fetch_array($res))
{
if ($res) {
while ($menu = $db->fetch_array($res)) {
$parent_rowid = $menu['rowid'];
$parent_mainmenu = $menu['mainmenu'];
$parent_leftmenu = $menu['leftmenu'];
@ -340,8 +322,7 @@ if ($action == 'create')
// Type
print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>';
if ($parent_rowid)
{
if ($parent_rowid) {
print $langs->trans('Left');
print '<input type="hidden" name="type" value="left">';
} else {
@ -355,15 +336,14 @@ if ($action == 'create')
// Mainmenu code
print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>';
print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOSTISSET("propertymainmenu") ? GETPOST("propertymainmenu", 'alphanohtml') : '').'"></td>';
print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOSTISSET("propertymainmenu") ? GETPOST("propertymainmenu", 'alphanohtml') : '').'"></td>';
print '<td>';
print $langs->trans("Example").': mytopmenukey';
print '</td></tr>';
// MenuId Parent
print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent').'</td>';
if ($parent_rowid)
{
if ($parent_rowid) {
print '<td>'.$parent_rowid.'<input type="hidden" name="menuId" value="'.$parent_rowid.'"></td>';
} else {
print '<td><input type="text" class="minwidth300" id="menuId" name="menuId" value="'.(GETPOSTISSET("menuId") ? GETPOST("menuId", 'int') : '').'"></td>';
@ -373,16 +353,20 @@ if ($action == 'create')
print '</td></tr>';
// Title
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag(GETPOST("titre", 'alphanohtml')).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td>';
print '<td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag(GETPOST("titre", 'alphanohtml')).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
// URL
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="minwidth500" name="url" value="'.GETPOST("url", 'alphanohtml').'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td>';
print '<td><input type="text" class="minwidth500" name="url" value="'.GETPOST("url", 'alphanohtml').'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
// Langs
print '<tr><td>'.$langs->trans('LangFile').'</td><td><input type="text" class="minwidth300" name="langs" value="'.$parent_langs.'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
print '<tr><td>'.$langs->trans('LangFile').'</td>';
print '<td><input type="text" class="minwidth300" name="langs" value="'.$parent_langs.'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
// Position
print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="width100" name="position" value="'.dol_escape_htmltag(GETPOSTISSET("position") ? GETPOST("position", 'int') : 100).'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
print '<tr><td>'.$langs->trans('Position').'</td>';
print '<td><input type="text" class="width100" name="position" value="'.dol_escape_htmltag(GETPOSTISSET("position") ? GETPOST("position", 'int') : 100).'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
// Target
print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
@ -391,10 +375,12 @@ if ($action == 'create')
print '</select></td></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
// Enabled
print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.(GETPOSTISSET('enabled') ? GETPOST("enabled", 'alphanohtml') : '1').'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>';
print '<tr><td>'.$langs->trans('Enabled').'</td>';
print '<td><input type="text" class="minwidth500" name="enabled" value="'.(GETPOSTISSET('enabled') ? GETPOST("enabled", 'alphanohtml') : '1').'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>';
// Perms
print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.(GETPOSTISSET('perms') ? GETPOST('perms', 'alphanohtml') : '1').'"></td><td>'.$langs->trans('DetailRight').'</td></tr>';
print '<tr><td>'.$langs->trans('Rights').'</td>';
print '<td><input type="text" class="minwidth500" name="perms" value="'.(GETPOSTISSET('perms') ? GETPOST('perms', 'alphanohtml') : '1').'"></td><td>'.$langs->trans('DetailRight').'</td></tr>';
print '</table>';
@ -407,8 +393,7 @@ if ($action == 'create')
print '</div>';
print '</form>';
} elseif ($action == 'edit')
{
} elseif ($action == 'edit') {
print load_fiche_titre($langs->trans("ModifMenu"), '', 'title_setup');
print '<br>';
@ -432,8 +417,11 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans('MenuModule').'</td><td>'.$menu->module.'</td><td>'.$langs->trans('DetailMenuModule').'</td></tr>';
// Handler
if ($menu->menu_handler == 'all') $handler = $langs->trans('AllMenus');
else $handler = $menu->menu_handler;
if ($menu->menu_handler == 'all') {
$handler = $langs->trans('AllMenus');
} else {
$handler = $menu->menu_handler;
}
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td><td>'.$handler.'</td><td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
// User
@ -444,18 +432,18 @@ if ($action == 'create')
print '</select></td><td>'.$langs->trans('DetailUser').'</td></tr>';
// Type
print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>'.$langs->trans(ucfirst($menu->type)).'</td><td>'.$langs->trans('DetailType').'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td>';
print '<td>'.$langs->trans(ucfirst($menu->type)).'</td><td>'.$langs->trans('DetailType').'</td></tr>';
// Mainmenu code
if ($menu->type == 'top')
{
if ($menu->type == 'top') {
print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>';
/*if ($parent_rowid)
{
print '<td>'.$parent_rowid.'<input type="hidden" name="propertyleftmenu" value="'.$parent_rowid.'"></td>';
}
else
{*/
{
print '<td>'.$parent_rowid.'<input type="hidden" name="propertyleftmenu" value="'.$parent_rowid.'"></td>';
}
else
{*/
print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alphanohtml') ?GETPOST("propertymainmenu", 'alphanohtml') : $menu->mainmenu).'"></td>';
//}
print '<td>';
@ -467,8 +455,12 @@ if ($action == 'create')
print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent');
print '</td>';
$valtouse = $menu->fk_menu;
if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu;
if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu;
if ($menu->fk_mainmenu) {
$valtouse = 'fk_mainmenu='.$menu->fk_mainmenu;
}
if ($menu->fk_leftmenu) {
$valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu;
}
print '<td><input type="text" name="menuIdParent" value="'.$valtouse.'" class="minwidth300"></td>';
print '<td>'.$langs->trans('DetailMenuIdParent');
print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
@ -478,16 +470,20 @@ if ($action == 'create')
//print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>';
// Title
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag($menu->title).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td>';
print '<td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag($menu->title).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
// Url
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="quatrevingtpercent" name="url" value="'.$menu->url.'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td>';
print '<td><input type="text" class="quatrevingtpercent" name="url" value="'.$menu->url.'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
// Langs
print '<tr><td>'.$langs->trans('LangFile').'</td><td><input type="text" class="minwidth300" name="langs" value="'.dol_escape_htmltag($menu->langs).'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
print '<tr><td>'.$langs->trans('LangFile').'</td>';
print '<td><input type="text" class="minwidth300" name="langs" value="'.dol_escape_htmltag($menu->langs).'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
// Position
print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="minwidth100" name="position" value="'.$menu->position.'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
print '<tr><td>'.$langs->trans('Position').'</td>';
print '<td><input type="text" class="minwidth100" name="position" value="'.$menu->position.'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
// Target
print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
@ -496,13 +492,19 @@ if ($action == 'create')
print '</select></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
// Enabled
print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.dol_escape_htmltag($menu->enabled).'"></td><td>'.$langs->trans('DetailEnabled');
if (!empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')';
print '<tr><td>'.$langs->trans('Enabled').'</td>';
print '<td><input type="text" class="minwidth500" name="enabled" value="'.dol_escape_htmltag($menu->enabled).'"></td><td>'.$langs->trans('DetailEnabled');
if (!empty($menu->enabled)) {
print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')';
}
print '</td></tr>';
// Perms
print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.dol_escape_htmltag($menu->perms).'"></td><td>'.$langs->trans('DetailRight');
if (!empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')';
print '<tr><td>'.$langs->trans('Rights').'</td>';
print '<td><input type="text" class="minwidth500" name="perms" value="'.dol_escape_htmltag($menu->perms).'"></td><td>'.$langs->trans('DetailRight');
if (!empty($menu->perms)) {
print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')';
}
print '</td></tr>';
print '</table>';

View File

@ -233,8 +233,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -171,8 +171,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -256,8 +256,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -420,7 +420,7 @@ if ($mode == 'template' && $user->admin) {
print '<td></td>';
} else {
print '<td>'.$printer->listprinterstemplates[$line]['name'].'</td>';
print '<td>'.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).'</td>';
print '<td>'.dol_htmlentitiesbr($printer->listprinterstemplates[$line]['template']).'</td>';
// edit icon
print '<td><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=edittemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'">';
print img_picto($langs->trans("Edit"), 'edit');

View File

@ -240,7 +240,8 @@ foreach ($dirmodels as $reldir)
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -256,7 +256,10 @@ foreach ($arrayhandler as $key => $module)
// Show example of numbering module
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -251,7 +251,8 @@ foreach ($dirmodels as $reldir)
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -274,7 +274,8 @@ foreach ($dirmodels as $reldir)
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -256,8 +256,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -251,8 +251,10 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -28,9 +28,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("admin");
$langs->load("install");
$langs->load("errors");
$langs->loadLangs(array("admin", "install", "errors"));
if (!$user->admin)
accessforbidden();
@ -126,7 +124,7 @@ print '</table>';
print '<br>';
$activatedExtensions = array_map('strtolower', getActivatedExtensions());
$activatedExtensions = array();
$loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
print '<table class="noborder centpercent">';
@ -165,7 +163,6 @@ $name = "GD";
print "<tr>";
print "<td>".$name."</td>";
//print getTableColumn($name, $activatedExtensions);
print getTableColumn($name, $loadedExtensions);
print getTableColumnFunction($functions);
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
@ -176,7 +173,6 @@ $name = "Curl";
print "<tr>";
print "<td>".$name."</td>";
//print getTableColumn($name, $activatedExtensions);
print getTableColumn($name, $loadedExtensions);
print getTableColumnFunction($functions);
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
@ -189,7 +185,6 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc
print "<tr>";
print "<td>".$name."</td>";
//print getTableColumn($name, $activatedExtensions);
print getTableColumn($name, $loadedExtensions);
print getTableColumnFunction($functions);
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
@ -201,7 +196,6 @@ $name = "xDebug";
print "<tr>";
print "<td>".$name."</td>";
//print getTableColumn($name, $activatedExtensions);
print getTableColumn($name, $loadedExtensions);
print getTableColumnFunction($functions);
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
@ -240,7 +234,7 @@ foreach ($phparray as $key => $value)
print '</tr>';
} else {
print '<tr class="oddeven">';
print '<td>'.$keyparam.'</td>';
print '<td class="wordbreak">'.$keyparam.'</td>';
$i = 0;
foreach ($keyvalue as $keyparam2 => $keyvalue2)
{
@ -264,85 +258,6 @@ foreach ($phparray as $key => $value)
llxFooter();
$db->close();
/**
* Return all list with all activated, but possible not loaded PHP extensions
*
* @return array
*/
function getActivatedExtensions()
{
$file = trim(getConfigFilePath());
$handle = fopen($file, "r");
$content = fread($handle, filesize($file));
fclose($handle);
$configLines = explode("\r", $content);
// For compatibility with LF (Line Feed)
if (empty($configLines) || count($configLines) < 2) {
$configLines = explode("\n", $content);
}
$extensions = array();
$lastLine = "";
foreach ($configLines as $line)
{
$line = trim($line);
// ignore comment lines
if (substr($line, 0, 1) === ";" || empty($line))
{
continue;
}
// var_dump($line);
// extension
if (substr($line, 0, 9) === "extension" && substr($line, 0, 10) !== "extension_")
{
$value = trim(end(explode("=", $line)));
$extensions[] = $value === "gd2" ? "gd" : $value;
}
// zend_extension
if (substr($line, 0, 14) === "zend_extension")
{
$extensions[] = str_replace("[", "", str_replace("]", "", $lastLine));
}
$lastLine = $line;
}
return array_unique($extensions);
}
/**
* Return the path to the current used php config file
*
* @return string
*/
function getConfigFilePath()
{
$phparray = phpinfo_array();
foreach ($phparray as $value)
{
foreach ($value as $keyparam => $keyvalue)
{
if (strtolower($keyparam) !== "loaded configuration file")
{
continue;
}
return $keyvalue;
}
}
return "";
}
/**
* Return a table column with a indicator (okay or warning), based on the given name and list
@ -411,7 +326,7 @@ function getTableColumnFunction(array $functions)
* Return a result column with a translated result text
*
* @param string $name The name of the PHP extension
* @param array $activated A list with all activated PHP extensions
* @param array $activated A list with all activated PHP extensions. Deprecated.
* @param array $loaded A list with all loaded PHP extensions
* @param array $functions A list with all PHP functions to check
*

View File

@ -240,6 +240,7 @@ foreach ($dirmodels as $reldir) {
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') {
print $langs->trans($tmp);

View File

@ -363,7 +363,7 @@ if ($mode == 'overwrite')
if ($mode == 'searchkey')
{
$langcode = GETPOST('langcode') ?GETPOST('langcode') : $langs->defaultlang;
$langcode = GETPOSTISSET('langcode') ? GETPOST('langcode') : $langs->defaultlang;
$newlang = new Translate('', $conf);
$newlang->setDefaultLang($langcode);
@ -384,8 +384,7 @@ if ($mode == 'searchkey')
if (empty($langcode) || $langcode == '-1') $nbempty++;
if (empty($transkey)) $nbempty++;
if (empty($transvalue)) $nbempty++;
if ($action == 'search' && ($nbempty > 999)) // 999 to disable this
{
if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this
setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings');
} else {
// Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)

View File

@ -639,12 +639,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
}
// Close / Cancel
if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
}
// Re-open
if ($permissiontoadd && $object->status == $object::STATUS_CANCELED)
{
@ -666,6 +660,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&object=bom">'.$langs->trans("ToClone").'</a>';
}
// Close / Cancel
if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
}
/*
if ($user->rights->bom->write)
{

View File

@ -94,20 +94,20 @@ class BOM extends CommonObject
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'autofocusoncreate'=>1),
//'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassembly')),
'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>32, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing')),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'picto'=>'product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp', 'css'=>'maxwidth500'),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'),
//'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLossForProductProduced'),
'duration' => array('type'=>'duration', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'),
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>-1, 'position'=>102),
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'picto'=>'stock', 'enabled'=>1, 'visible'=>-1, 'position'=>102, 'css'=>'maxwidth500'),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-2, 'position'=>161, 'notnull'=>-1,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-2, 'position'=>162, 'notnull'=>-1,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>300, 'notnull'=>1,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,),
'date_valid' => array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-2, 'position'=>502, 'notnull'=>0,),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,),
'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-2, 'position'=>512, 'notnull'=>0,),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserCreation', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,),
'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'position'=>512, 'notnull'=>0,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>1010),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'notnull'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Enabled', 9=>'Disabled')),

View File

@ -145,7 +145,7 @@ print '</tr>';
// Description
print '<tr>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td >';
print '<td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('description', $object->description, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, ROWS_6, '90%');
$doleditor->Create();
@ -154,7 +154,7 @@ print '</td></tr>';
// Color
print '<tr>';
print '<td>'.$langs->trans("Color").'</td>';
print '<td >';
print '<td>';
print $formother->selectColor($object->color, 'color');
print '</td></tr>';

View File

@ -1,20 +1,20 @@
<?php
/* Advance Targeting Emailling for mass emailing module
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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 <https://www.gnu.org/licenses/>.
*/
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file comm/mailing/class/advtargetemailing.class.php
@ -33,16 +33,6 @@ class AdvanceTargetingMailing extends CommonObject
*/
public $db;
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
/**
* @var string ID to identify managed object
*/
@ -58,17 +48,54 @@ class AdvanceTargetingMailing extends CommonObject
*/
public $id;
/**
* @var string name
*/
public $name;
public $entity;
/**
* @var int element id
*/
public $fk_element;
/**
* @var string type element
*/
public $type_element;
/**
* @var string filter value
*/
public $filtervalue;
/**
* @var int user author id
*/
public $fk_user_author;
/**
* @var int|string datec
*/
public $datec = '';
/**
* @var int user mod id
*/
public $fk_user_mod;
/**
* @var int|string tms
*/
public $tms = '';
/**
* @var array select target type
*/
public $select_target_type = array();
/**
* @var array type status comm prospect
*/
public $type_statuscommprospect = array();
public $thirdparty_lines;
public $contact_lines;
@ -87,17 +114,17 @@ class AdvanceTargetingMailing extends CommonObject
$this->db = $db;
$this->select_target_type = array(
'2' => $langs->trans('Contacts'),
'1' => $langs->trans('Contacts').'+'.$langs->trans('ThirdParty'),
'3' => $langs->trans('ThirdParty'),
'4' => $langs->trans('ContactsWithThirdpartyFilter')
'2' => $langs->trans('Contacts'),
'1' => $langs->trans('Contacts').'+'.$langs->trans('ThirdParty'),
'3' => $langs->trans('ThirdParty'),
'4' => $langs->trans('ContactsWithThirdpartyFilter')
);
$this->type_statuscommprospect = array(
-1 => $langs->trans("StatusProspect-1"),
0 => $langs->trans("StatusProspect0"),
1 => $langs->trans("StatusProspect1"),
2 => $langs->trans("StatusProspect2"),
3 => $langs->trans("StatusProspect3")
-1 => $langs->trans("StatusProspect-1"),
0 => $langs->trans("StatusProspect0"),
1 => $langs->trans("StatusProspect1"),
2 => $langs->trans("StatusProspect2"),
3 => $langs->trans("StatusProspect3")
);
}
@ -114,11 +141,19 @@ class AdvanceTargetingMailing extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->fk_element)) $this->fk_element = (int) $this->fk_element;
if (isset($this->type_element)) $this->type_element = trim($this->type_element);
if (isset($this->fk_element)) {
$this->fk_element = (int) $this->fk_element;
}
if (isset($this->type_element)) {
$this->type_element = trim($this->type_element);
}
if (isset($this->name)) $this->name = trim($this->name);
if (isset($this->filtervalue)) $this->filtervalue = trim($this->filtervalue);
if (isset($this->name)) {
$this->name = trim($this->name);
}
if (isset($this->filtervalue)) {
$this->filtervalue = trim($this->filtervalue);
}
// Check parameters
// Put here code to add control on parameters values
@ -148,18 +183,17 @@ class AdvanceTargetingMailing extends CommonObject
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."advtargetemailing");
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -198,10 +232,8 @@ class AdvanceTargetingMailing extends CommonObject
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -259,10 +291,8 @@ class AdvanceTargetingMailing extends CommonObject
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -324,10 +354,8 @@ class AdvanceTargetingMailing extends CommonObject
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -365,10 +393,18 @@ class AdvanceTargetingMailing extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->fk_element)) $this->fk_element = (int) $this->fk_element;
if (isset($this->type_element)) $this->type_element = trim($this->type_element);
if (isset($this->name)) $this->name = trim($this->name);
if (isset($this->filtervalue)) $this->filtervalue = trim($this->filtervalue);
if (isset($this->fk_element)) {
$this->fk_element = (int) $this->fk_element;
}
if (isset($this->type_element)) {
$this->type_element = trim($this->type_element);
}
if (isset($this->name)) {
$this->name = trim($this->name);
}
if (isset($this->filtervalue)) {
$this->filtervalue = trim($this->filtervalue);
}
// Check parameters
// Put here code to add a control on parameters values
@ -394,10 +430,8 @@ class AdvanceTargetingMailing extends CommonObject
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -423,21 +457,20 @@ class AdvanceTargetingMailing extends CommonObject
$this->db->begin();
if (!$error)
{
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."advtargetemailing";
$sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -563,7 +596,7 @@ class AdvanceTargetingMailing extends CommonObject
$extrafields->fetch_name_optionals_label($elementtype);
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$val) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key])) {
@ -593,7 +626,9 @@ class AdvanceTargetingMailing extends CommonObject
}
}
if (count($sqlwhere) > 0) $sql .= " WHERE ".implode(" AND ", $sqlwhere);
if (count($sqlwhere) > 0) {
$sql .= " WHERE ".implode(" AND ", $sqlwhere);
}
}
@ -604,10 +639,8 @@ class AdvanceTargetingMailing extends CommonObject
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$this->thirdparty_lines[$i] = $obj->rowid;
@ -674,8 +707,7 @@ class AdvanceTargetingMailing extends CommonObject
}
if ($arrayquery['contact_no_email'] != '') {
$tmpwhere = '';
if (!empty($arrayquery['contact_no_email']))
{
if (!empty($arrayquery['contact_no_email'])) {
$tmpwhere .= "(t.email IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))";
} else {
$tmpwhere .= "(t.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))";
@ -704,7 +736,7 @@ class AdvanceTargetingMailing extends CommonObject
$extrafields->fetch_name_optionals_label($elementtype);
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$val) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key.'_cnct'])) {
@ -806,7 +838,7 @@ class AdvanceTargetingMailing extends CommonObject
$extrafields->fetch_name_optionals_label($elementtype);
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$val) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key])) {
@ -837,7 +869,9 @@ class AdvanceTargetingMailing extends CommonObject
}
}
}
if (count($sqlwhere) > 0) $sql .= " WHERE ".implode(" AND ", $sqlwhere);
if (count($sqlwhere) > 0) {
$sql .= " WHERE ".implode(" AND ", $sqlwhere);
}
}
dol_syslog(get_class($this)."::query_contact sql=".$sql, LOG_DEBUG);
@ -847,10 +881,8 @@ class AdvanceTargetingMailing extends CommonObject
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$this->contact_lines[$i] = $obj->rowid;

View File

@ -46,25 +46,96 @@ class Mailing extends CommonObject
*/
public $picto = 'email';
/**
* @var string title
*/
public $title;
/**
* @var string subject
*/
public $sujet;
/**
* @var string body
*/
public $body;
/**
* @var int number of email
*/
public $nbemail;
/**
* @var string background color
*/
public $bgcolor;
/**
* @var string background image
*/
public $bgimage;
/**
* @var int status
*/
public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
/**
* @var string email from
*/
public $email_from;
/**
* @var string email reply to
*/
public $email_replyto;
/**
* @var string email errors to
*/
public $email_errorsto;
/**
* @var string first joined file
*/
public $joined_file1;
/**
* @var string second joined file
*/
public $joined_file2;
/**
* @var string third joined file
*/
public $joined_file3;
/**
* @var string fourth joined file
*/
public $joined_file4;
/**
* @var int id of user create
* @deprecated
*/
public $user_creation;
/**
* @var int id of user create
*/
public $user_creat;
/**
* @var int id of user validate
* @deprecated
*/
public $user_validation;
/**
* @var int id of user validate
*/
public $user_valid;
/**
@ -72,12 +143,24 @@ class Mailing extends CommonObject
*/
public $date_creat;
/**
* @var int date validate
*/
public $date_valid;
/**
* @var array extraparams
*/
public $extraparams = array();
/**
* @var array statut dest
*/
public $statut_dest = array();
/**
* @var array statuts
*/
public $statuts = array();
@ -118,8 +201,7 @@ class Mailing extends CommonObject
$this->title = trim($this->title);
$this->email_from = trim($this->email_from);
if (!$this->email_from)
{
if (!$this->email_from) {
$this->error = $langs->trans("ErrorMailFromRequired");
return -1;
}
@ -130,19 +212,16 @@ class Mailing extends CommonObject
$sql .= " (date_creat, fk_user_creat, entity)";
$sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", ".$conf->entity.")";
if (!$this->title)
{
if (!$this->title) {
$this->title = $langs->trans("NoTitle");
}
dol_syslog("Mailing::Create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
if ($this->update($user) > 0)
{
if ($this->update($user) > 0) {
$this->db->commit();
} else {
$this->error = $this->db->lasterror();
@ -175,12 +254,11 @@ class Mailing extends CommonObject
$sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'";
$sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'";
$sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'";
$sql .= " WHERE rowid = ".$this->id;
$sql .= " WHERE rowid = ".(int) $this->id;
dol_syslog("Mailing::Update", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
return 1;
} else {
$this->error = $this->db->lasterror();
@ -211,10 +289,8 @@ class Mailing extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
@ -286,8 +362,7 @@ class Mailing extends CommonObject
$object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now());
// If no option copy content
if (empty($option1))
{
if (empty($option1)) {
// Clear values
$object->nbemail = 0;
$object->sujet = '';
@ -312,15 +387,13 @@ class Mailing extends CommonObject
$result = $object->create($user);
// Other options
if ($result < 0)
{
if ($result < 0) {
$this->error = $object->error;
$this->errors = array_merge($this->errors, $object->errors);
$error++;
}
if (!$error)
{
if (!$error) {
// Clone recipient targets
if (!empty($option2)) {
require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
@ -341,10 +414,8 @@ class Mailing extends CommonObject
$sql .= " WHERE fk_mailing = ".$fromid;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
while ($obj = $this->db->fetch_object($result)) {
$target_array[] = array(
'fk_contact'=>$obj->fk_contact,
@ -370,8 +441,7 @@ class Mailing extends CommonObject
unset($object->context['createfromclone']);
// End
if (!$error)
{
if (!$error) {
$this->db->commit();
return $object->id;
} else {
@ -395,8 +465,7 @@ class Mailing extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
dol_syslog("Mailing::valid", LOG_DEBUG);
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
return 1;
} else {
$this->error = $this->db->lasterror();
@ -418,8 +487,7 @@ class Mailing extends CommonObject
dol_syslog("Mailing::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
return $this->delete_targets();
} else {
$this->error = $this->db->lasterror();
@ -441,8 +509,7 @@ class Mailing extends CommonObject
dol_syslog("Mailing::delete_targets", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
return 1;
} else {
$this->error = $this->db->lasterror();
@ -467,8 +534,7 @@ class Mailing extends CommonObject
dol_syslog("Mailing::reset_targets_status", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
return 1;
} else {
$this->error = $this->db->lasterror();
@ -487,19 +553,23 @@ class Mailing extends CommonObject
{
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " WHERE fk_mailing = ".$this->id;
if ($mode == 'alreadysent') $sql .= " AND statut <> 0";
elseif ($mode == 'alreadysentok') $sql .= " AND statut > 0";
elseif ($mode == 'alreadysentko') $sql .= " AND statut = -1";
else {
if ($mode == 'alreadysent') {
$sql .= " AND statut <> 0";
} elseif ($mode == 'alreadysentok') {
$sql .= " AND statut > 0";
} elseif ($mode == 'alreadysentko') {
$sql .= " AND statut = -1";
} else {
$this->error = 'BadValueForParameterMode';
return -2;
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj) return $obj->nb;
if ($obj) {
return $obj->nb;
}
} else {
$this->error = $this->db->lasterror();
return -1;
@ -524,7 +594,9 @@ class Mailing extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = '';
$companylink = '';
@ -535,19 +607,20 @@ class Mailing extends CommonObject
$url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id;
if ($option != 'nolink')
{
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowEMailing");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
@ -560,15 +633,21 @@ class Mailing extends CommonObject
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -576,8 +655,11 @@ class Mailing extends CommonObject
$hookmanager->initHooks(array('emailingdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint;
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result;
}
@ -611,8 +693,12 @@ class Mailing extends CommonObject
$labelStatusShort = $langs->trans($this->statuts[$status]);
$statusType = 'status'.$status;
if ($status == 2) $statusType = 'status3';
if ($status == 3) $statusType = 'status6';
if ($status == 2) {
$statusType = 'status3';
}
if ($status == 3) {
$statusType = 'status6';
}
return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
}
@ -647,9 +733,15 @@ class Mailing extends CommonObject
$labelStatusShort[3] = $langs->trans('MailingStatusNotContact');
$statusType = 'status'.$status;
if ($status == -1) $statusType = 'status8';
if ($status == 1) $statusType = 'status6';
if ($status == 2) $statusType = 'status4';
if ($status == -1) {
$statusType = 'status8';
}
if ($status == 1) {
$statusType = 'status6';
}
if ($status == 2) {
$statusType = 'status4';
}
$param = array();
if ($status == - 1) {

View File

@ -366,9 +366,6 @@ if (empty($reshook))
$object->statut = Propal::STATUS_DRAFT;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// the create is done below and further more the existing create_from function is quite hilarating
//$id = $object->create_from($user);
} else {
setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors');
}
@ -2411,7 +2408,8 @@ if ($action == 'create')
if ($action != 'editline')
{
// Validate
if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0)
if (($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0)
|| ($object->statut == Propal::STATUS_DRAFT && !empty($conf->global->PROPAL_ENABLE_NEGATIVE) && count($object->lines) > 0))
{
if ($usercanvalidate)
{

View File

@ -208,7 +208,6 @@ class Propal extends CommonObject
public $demand_reason_id;
public $demand_reason_code;
public $products = array();
public $extraparams = array();
/**
@ -355,15 +354,13 @@ class Propal extends CommonObject
$this->socid = $socid;
$this->id = $propalid;
$this->products = array();
$this->duree_validite = ((int) $conf->global->PROPALE_VALIDITY_DURATION);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Add line into array products
* Add line into array ->lines
* $this->thirdparty should be loaded
*
* @param int $idproduct Product Id to add
@ -372,7 +369,6 @@ class Propal extends CommonObject
* @return int <0 if KO, >0 if OK
*
* TODO Replace calls to this function by generation objet Ligne
* inserted into table $this->products
*/
public function add_product($idproduct, $qty, $remise_percent = 0)
{
@ -1279,24 +1275,6 @@ class Propal extends CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Insert into DB a proposal object completely defined by its data members (ex, results from copy).
*
* @param User $user User that create
* @return int Id of the new object if ok, <0 if ko
* @see create()
*/
public function create_from($user)
{
// phpcs:enable
// i love this function because $this->products is not used in create function...
$this->products = $this->lines;
return $this->create($user);
}
/**
* Load an object from its id and create a new one in database
*
@ -2947,10 +2925,23 @@ class Propal extends CommonObject
if (! $this->db->query($sqlef) || ! $this->db->query($sql)) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (!$error) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
}
if (!$error) {
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) $error++;
}
// Removed extrafields of object
if (!$error) {
$result = $this->deleteExtraFields();
@ -2966,25 +2957,15 @@ class Propal extends CommonObject
$res = $this->db->query($sql);
if (! $res) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (! $error) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
}
if (! $error) {
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) $error++;
}
// Delete record into ECM index and physically
if (!$error) {
$res = $this->deleteEcmFiles(); // Deleting files physically is done later with the dol_delete_dir_recursive
$res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive
if (! $res) {
$error++;
}
@ -3001,7 +2982,7 @@ class Propal extends CommonObject
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = 'ErrorFailToDeleteFile';
$this->errors = array('ErrorFailToDeleteFile');
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
@ -3010,7 +2991,7 @@ class Propal extends CommonObject
$res = @dol_delete_dir_recursive($dir);
if (!$res) {
$this->error = 'ErrorFailToDeleteDir';
$this->errors = array('ErrorFailToDeleteDir');
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}

View File

@ -37,11 +37,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$mode = GETPOST("mode") ?GETPOST("mode") : 'customer';
$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer';
if ($mode == 'customer' && !$user->rights->propale->lire) accessforbidden();
if ($mode == 'supplier' && !$user->rights->supplier_proposal->lire) accessforbidden();
$object_status = GETPOST('object_status');
$object_status = GETPOST('object_status', 'intcomma');
$typent_id = GETPOST('typent_id', 'int');
$categ_id = GETPOST('categ_id', 'categ_id');
@ -55,7 +55,7 @@ if ($user->socid > 0)
}
$nowyear = strftime("%Y", dol_now());
$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear;
//$startyear=$year-2;
$startyear = $year - 1;
$endyear = $year;

View File

@ -453,26 +453,15 @@ if (empty($reshook))
if (!$error)
{
$object_id = $object->create($user);
// If some invoice's lines already known
$NBLINES = 8;
for ($i = 1; $i <= $NBLINES; $i++) {
if ($_POST['idprod'.$i]) {
$xid = 'idprod'.$i;
$xqty = 'qty'.$i;
$xremise = 'remise_percent'.$i;
$object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]);
}
}
}
}
// Insert default contacts if defined
if ($object_id > 0)
{
if (GETPOST('contactid'))
if (GETPOST('contactid', 'int'))
{
$result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external');
$result = $object->add_contact(GETPOST('contactid', 'int'), 'CUSTOMER', 'external');
if ($result < 0) {
setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors');
$error++;
@ -1575,7 +1564,7 @@ if ($action == 'create' && $usercancreate)
print '</td>';
} else {
print '<td>';
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx');
// reload page to retrieve customer informations
if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED))
{
@ -1663,7 +1652,7 @@ if ($action == 'create' && $usercancreate)
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
print '<tr><td>'.$langs->trans('Warehouse').'</td><td>';
print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1);
print img_picto('', 'stock').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth175 maxwidth500 widthcentpercentminusxx');
print '</td></tr>';
}
@ -1680,7 +1669,8 @@ if ($action == 'create' && $usercancreate)
$langs->load("projects");
print '<tr>';
print '<td>'.$langs->trans("Project").'</td><td>';
$numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500');
print img_picto('', 'project');
$numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth175 maxwidth500 widthcentpercentminusxx');
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
print '</td>';
print '</tr>';

View File

@ -199,6 +199,7 @@ class Commande extends CommonOrder
public $rang;
public $special_code;
public $source; // Order mode. How we received order (by phone, by email, ...)
public $extraparams = array();
public $linked_objects = array();
@ -368,8 +369,6 @@ class Commande extends CommonOrder
$this->remise = 0;
$this->remise_percent = 0;
$this->products = array();
}
/**
@ -1690,7 +1689,6 @@ class Commande extends CommonOrder
* @return void
*
* TODO Remplacer les appels a cette fonction par generation objet Ligne
* insere dans tableau $this->products
*/
public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '')
{
@ -1752,15 +1750,13 @@ class Commande extends CommonOrder
$prods_arbo = $prod->get_arbo_each_prod();
if(count($prods_arbo) > 0)
{
foreach($prods_arbo as $key => $value)
{
// print "id : ".$value[1].' :qty: '.$value[0].'<br>';
if(! in_array($value[1],$this->products))
$this->add_product($value[1], $value[0]);
}
}
foreach($prods_arbo as $key => $value)
{
// print "id : ".$value[1].' :qty: '.$value[0].'<br>';
if not in lines {
$this->add_product($value[1], $value[0]);
}
}
}
**/
}
@ -3086,6 +3082,7 @@ class Commande extends CommonOrder
// Clean vat code
$vat_src_code = '';
$reg = array();
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
@ -3342,106 +3339,95 @@ class Commande extends CommonOrder
$this->db->begin();
if (!$error && !$notrigger)
{
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('ORDER_DELETE', $user);
if ($result < 0) $error++;
if ($result < 0) { $error++; }
// End call triggers
}
// Test we can delete
if ($this->nb_expedition() != 0)
{
$this->errors[] = $langs->trans('SomeShipmentExists');
$error++;
}
if (!$error)
{
// Delete extrafields of order details
$main = MAIN_DB_PREFIX.'commandedet';
$ef = $main."_extrafields";
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")";
if (!$this->db->query($sql))
{
// Delete extrafields of lines and lines
if (!$error && !empty($this->table_element_line)) {
$tabletodelete = $this->table_element_line;
$sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")";
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id;
if (! $this->db->query($sqlef) || ! $this->db->query($sql)) {
$error++;
$this->errors[] = $this->db->lasterror();
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (!$error)
{
// Delete order details
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = ".$this->id;
if (!$this->db->query($sql))
{
$error++;
$this->errors[] = $this->db->lasterror();
}
}
if (!$error)
{
if (!$error) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
}
if (!$error)
{
if (!$error) {
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) $error++;
}
if (!$error)
{
// Remove extrafields
// Removed extrafields of object
if (!$error) {
$result = $this->deleteExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (!$error)
{
// Delete object
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
if (!$this->db->query($sql))
{
// Delete main record
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id;
$res = $this->db->query($sql);
if (! $res) {
$error++;
$this->errors[] = $this->db->lasterror();
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (!$error)
{
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
$this->deleteEcmFiles();
// Delete record into ECM index and physically
if (!$error) {
$res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive
if (! $res) {
$error++;
}
}
// Remove directory with files
$comref = dol_sanitizeFileName($this->ref);
if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref))
{
$dir = $conf->commande->multidir_output[$this->entity]."/".$comref;
$file = $conf->commande->multidir_output[$this->entity]."/".$comref."/".$comref.".pdf";
if (file_exists($file)) // We must delete all files before deleting directory
{
if (!$error) {
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref)) {
$dir = $conf->commande->multidir_output[$this->entity]."/".$ref;
$file = $dir."/".$ref.".pdf";
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers
{
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = 'ErrorFailToDeleteFile';
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
}
if (file_exists($dir))
{
if (!dol_delete_dir_recursive($dir))
{
$this->error = $langs->trans("ErrorCanNotDeleteDir", $dir);
if (file_exists($dir)) {
$res = @dol_delete_dir_recursive($dir);
if (!$res) {
$this->error = 'ErrorFailToDeleteDir';
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
@ -3449,17 +3435,13 @@ class Commande extends CommonOrder
}
}
if (!$error)
{
if (!$error) {
dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG);
$this->db->commit();
return 1;
} else {
foreach ($this->errors as $errmsg)
{
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
return -1;
}
}

View File

@ -38,11 +38,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$mode = GETPOST("mode") ?GETPOST("mode") : 'customer';
$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer';
if ($mode == 'customer' && !$user->rights->commande->lire) accessforbidden();
if ($mode == 'supplier' && !$user->rights->fournisseur->commande->lire) accessforbidden();
$object_status = GETPOST('object_status');
$object_status = GETPOST('object_status', 'intcomma');
$typent_id = GETPOST('typent_id', 'int');
$categ_id = GETPOST('categ_id', 'categ_id');
@ -302,11 +302,11 @@ if ($mode == 'customer')
Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"),
Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled")
);
print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4);
print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'intcomma'), -4);
}
if ($mode == 'supplier')
{
$formorder->selectSupplierOrderStatus((strstr($object_status, ',') ?-1 : $object_status), 0, 'object_status');
$formorder->selectSupplierOrderStatus((strstr($object_status, ',') ? -1 : $object_status), 0, 'object_status');
}
print '</td></tr>';
// Year

View File

@ -885,7 +885,7 @@ if ($action == 'create')
print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(isset($_POST["account_min_allowed"]) ?GETPOST("account_min_allowed") : $object->min_allowed).'"></td></tr>';
print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
print '<td ><input size="12" type="text" class="flat" name="account_min_desired" value="'.(isset($_POST["account_min_desired"]) ?GETPOST("account_min_desired") : $object->min_desired).'"></td></tr>';
print '<td><input size="12" type="text" class="flat" name="account_min_desired" value="'.(isset($_POST["account_min_desired"]) ?GETPOST("account_min_desired") : $object->min_desired).'"></td></tr>';
// Web
print '<tr><td>'.$langs->trans("Web").'</td>';

View File

@ -1233,7 +1233,7 @@ if ($action == 'create')
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '<table class="border centpercent tableforfield">';
print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>'.$author->getFullName($langs)."</td></tr>";
@ -1262,7 +1262,7 @@ if ($action == 'create')
// Payment term
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('PaymentConditionsShort');
print '</td>';
if ($action != 'editconditions' && $user->rights->facture->creer)
@ -1452,7 +1452,7 @@ if ($action == 'create')
$title = $langs->trans("Recurrence");
//print load_fiche_titre($title, '', 'calendar');
print '<table class="border centpercent">';
print '<table class="border centpercent tableforfield">';
print '<tr><td colspan="2"><span class="fa fa-calendar"></span> '.$title.'</td></tr>';
@ -1573,7 +1573,7 @@ if ($action == 'create')
}
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '<table class="border centpercent tableforfield">';
// Nb of generation already done
print '<tr><td style="width: 50%">'.$langs->trans("NbOfGenerationDone").'</td>';

View File

@ -358,26 +358,23 @@ if (empty($reshook))
if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date;
$result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error);
} elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer)
{
} elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) {
$object->fetch($id);
$result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float'));
if ($result < 0)
dol_print_error($db, $object->error);
} elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer)
{
} elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) {
$object->fetch($id);
$result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float'));
if ($result < 0)
dol_print_error($db, $object->error);
} // Multicurrency Code
} // Multicurrency Code
elseif ($action == 'setmulticurrencycode' && $usercancreate) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
} // Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
} elseif ($action == 'setinvoicedate' && $usercancreate)
{
} elseif ($action == 'setinvoicedate' && $usercancreate) {
$object->fetch($id);
$old_date_lim_reglement = $object->date_lim_reglement;
$date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']);
@ -395,8 +392,7 @@ if (empty($reshook))
if ($result < 0) {
dol_print_error($db, $object->error);
}
} elseif ($action == 'setdate_pointoftax' && $usercancreate)
{
} elseif ($action == 'setdate_pointoftax' && $usercancreate) {
$object->fetch($id);
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
$object->date_pointoftax = $date_pointoftax;
@ -3649,8 +3645,7 @@ if ($action == 'create')
}
print '</form>';
} elseif ($id > 0 || !empty($ref))
{
} elseif ($id > 0 || !empty($ref)) {
/*
* Show object in view mode
*/
@ -3896,6 +3891,7 @@ if ($action == 'create')
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', "yes", 1);
}
if ($action == 'paid' && $resteapayer > 0) {
$close = array();
// Code
$i = 0;
$close[$i]['code'] = 'discount_vat'; // escompte
@ -3922,7 +3918,7 @@ if ($action == 'create')
$i++;
// arrayreasons[code]=reason
foreach ($close as $key => $val) {
$arrayreasons[$close [$key]['code']] = $close[$key]['reason'];
$arrayreasons[$close[$key]['code']] = $close[$key]['reason'];
}
// Cree un tableau formulaire
@ -4073,24 +4069,26 @@ if ($action == 'create')
// Type
print '<tr><td class="titlefield fieldname_type">'.$langs->trans('Type').'</td><td class="valuefield fieldname_type">';
print '<span class="badgeneutral">';
print $object->getLibType();
print '</span>';
if ($object->module_source) {
print ' <span class="opacitymediumbycolor">('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')</span>';
print ' <span class="opacitymediumbycolor paddingleft">('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')</span>';
}
if ($object->type == Facture::TYPE_REPLACEMENT) {
$facreplaced = new Facture($db);
$facreplaced->fetch($object->fk_facture_source);
print ' <span class="opacitymediumbycolor">('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')</span>';
print ' <span class="opacitymediumbycolor paddingleft">('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')</span>';
}
if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) {
$facusing = new Facture($db);
$facusing->fetch($object->fk_facture_source);
print ' <span class="opacitymediumbycolor">('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')</span>';
print ' <span class="opacitymediumbycolor paddingleft">('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')</span>';
}
$facidavoir = $object->getListIdAvoirFromInvoice();
if (count($facidavoir) > 0) {
print ' <span class="opacitymediumbycolor">('.$langs->transnoentities("InvoiceHasAvoir");
print ' <span class="opacitymediumbycolor paddingleft">('.$langs->transnoentities("InvoiceHasAvoir");
$i = 0;
foreach ($facidavoir as $id) {
if ($i == 0)
@ -4105,14 +4103,16 @@ if ($action == 'create')
if ($objectidnext > 0) {
$facthatreplace = new Facture($db);
$facthatreplace->fetch($objectidnext);
print ' <span class="opacitymediumbycolor">('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')</span>';
print ' <span class="opacitymediumbycolor paddingleft">('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')</span>';
}
if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) {
$discount = new DiscountAbsolute($db);
$result = $discount->fetch(0, $object->id);
if ($result > 0) {
print '. <span class="opacitymediumbycolor">'.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'</span><br>';
print ' <span class="opacitymediumbycolor paddingleft">';
print $langs->transnoentities("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount'));
print '</span><br>';
}
}
@ -4121,10 +4121,9 @@ if ($action == 'create')
$tmptemplate = new FactureRec($db);
$result = $tmptemplate->fetch($object->fk_fac_rec_source);
if ($result > 0) {
print '. <span class="opacitymediumbycolor">'.$langs->trans(
"GeneratedFromTemplate",
'<a href="'.DOL_MAIN_URL_ROOT.'/compta/facture/card-rec.php?facid='.$tmptemplate->id.'">'.$tmptemplate->ref.'</a>'
).'</span>';
print ' <span class="opacitymediumbycolor paddingleft">';
print $langs->transnoentities("GeneratedFromTemplate", '<a href="'.DOL_MAIN_URL_ROOT.'/compta/facture/card-rec.php?facid='.$tmptemplate->id.'">'.dol_escape_htmltag($tmptemplate->ref).'</a>');
print '</span>';
}
}
print '</td></tr>';
@ -4132,13 +4131,11 @@ if ($action == 'create')
// Relative and absolute discounts
print '<!-- Discounts -->'."\n";
print '<tr><td>'.$langs->trans('Discounts');
print '</td><td>';
$thirdparty = $soc;
$discount_type = 0;
$backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';
// Date invoice
@ -4154,7 +4151,7 @@ if ($action == 'create')
if ($action == 'editinvoicedate') {
$form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date, 'invoicedate');
} else {
print dol_print_date($object->date, 'day');
print '<span class="valuedate">'.dol_print_date($object->date, 'day').'</span>';
}
print '</td>';
@ -4173,7 +4170,7 @@ if ($action == 'create')
if ($action == 'editdate_pointoftax') {
$form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_pointoftax, 'date_pointoftax');
} else {
print dol_print_date($object->date_pointoftax, 'day');
print '<span class="valuedate">'.dol_print_date($object->date_pointoftax, 'day').'</span>';
}
print '</td></tr>';
}
@ -4213,7 +4210,7 @@ if ($action == 'create')
if ($action == 'editpaymentterm') {
$form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_lim_reglement, 'paymentterm');
} else {
print dol_print_date($object->date_lim_reglement, 'day');
print '<span class="valuedate">'.dol_print_date($object->date_lim_reglement, 'day').'</span>';
if ($object->hasDelay()) {
print img_warning($langs->trans('Late'));
}
@ -4788,10 +4785,13 @@ if ($action == 'create')
if ($object->type != Facture::TYPE_CREDIT_NOTE) {
// Total already paid
print '<tr><td colspan="'.$nbcols.'" class="right">';
if ($object->type != Facture::TYPE_DEPOSIT)
print '<span class="opacitymedium">';
if ($object->type != Facture::TYPE_DEPOSIT) {
print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits');
else print $langs->trans('AlreadyPaid');
print ' :</td><td class="right'.(($totalpaye > 0) ? ' amountalreadypaid' : '').'">'.price($totalpaye).'</td><td>&nbsp;</td></tr>';
} else {
print $langs->trans('AlreadyPaid');
}
print '</span></td><td class="right'.(($totalpaye > 0) ? ' amountalreadypaid' : '').'">'.price($totalpaye).'</td><td>&nbsp;</td></tr>';
$resteapayeraffiche = $resteapayer;
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
@ -4812,12 +4812,14 @@ if ($action == 'create')
$obj = $db->fetch_object($resql);
$invoice->fetch($obj->fk_facture_source);
print '<tr><td colspan="'.$nbcols.'" class="right">';
print '<span class="opacitymedium">';
if ($invoice->type == Facture::TYPE_CREDIT_NOTE)
print $langs->trans("CreditNote").' ';
if ($invoice->type == Facture::TYPE_DEPOSIT)
print $langs->trans("Deposit").' ';
print $invoice->getNomUrl(0);
print ' :</td>';
print '</span>';
print '</td>';
print '<td class="right">'.price($obj->amount_ttc).'</td>';
print '<td class="right">';
print '<a href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=unlinkdiscount&discountid='.$obj->rowid.'">'.img_delete().'</a>';
@ -4835,7 +4837,9 @@ if ($action == 'create')
// Paye partiellement 'escompte'
if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'discount_vat') {
print '<tr><td colspan="'.$nbcols.'" class="nowrap right">';
print $form->textwithpicto($langs->trans("Discount").':', $langs->trans("HelpEscompte"), - 1);
print '<span class="opacitymedium">';
print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1);
print '</span>';
print '</td><td class="right">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).'</td><td>&nbsp;</td></tr>';
$resteapayeraffiche = 0;
$cssforamountpaymentcomplete = 'amountpaymentneutral';
@ -4843,7 +4847,9 @@ if ($action == 'create')
// Paye partiellement ou Abandon 'badcustomer'
if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'badcustomer') {
print '<tr><td colspan="'.$nbcols.'" class="nowrap right">';
print $form->textwithpicto($langs->trans("Abandoned").':', $langs->trans("HelpAbandonBadCustomer"), - 1);
print '<span class="opacitymedium">';
print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1);
print '</span>';
print '</td><td class="right">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).'</td><td>&nbsp;</td></tr>';
// $resteapayeraffiche=0;
$cssforamountpaymentcomplete = 'amountpaymentneutral';
@ -4851,7 +4857,9 @@ if ($action == 'create')
// Paye partiellement ou Abandon 'product_returned'
if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'product_returned') {
print '<tr><td colspan="'.$nbcols.'" class="nowrap right">';
print $form->textwithpicto($langs->trans("ProductReturned").':', $langs->trans("HelpAbandonProductReturned"), - 1);
print '<span class="opacitymedium">';
print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1);
print '</span>';
print '</td><td class="right">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).'</td><td>&nbsp;</td></tr>';
$resteapayeraffiche = 0;
$cssforamountpaymentcomplete = 'amountpaymentneutral';
@ -4862,20 +4870,27 @@ if ($action == 'create')
$text = $langs->trans("HelpAbandonOther");
if ($object->close_note)
$text .= '<br><br><b>'.$langs->trans("Reason").'</b>:'.$object->close_note;
print $form->textwithpicto($langs->trans("Abandoned").':', $text, - 1);
print '<span class="opacitymedium">';
print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1);
print '</span>';
print '</td><td class="right">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).'</td><td>&nbsp;</td></tr>';
$resteapayeraffiche = 0;
$cssforamountpaymentcomplete = 'amountpaymentneutral';
}
// Billed
print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("Billed").' :</td><td class="right">'.price($object->total_ttc).'</td><td>&nbsp;</td></tr>';
print '<tr><td colspan="'.$nbcols.'" class="right">';
print '<span class="opacitymedium">';
print $langs->trans("Billed");
print '</td><td class="right">'.price($object->total_ttc).'</td><td>&nbsp;</td></tr>';
// Remainder to pay
print '<tr><td colspan="'.$nbcols.'" class="right">';
print '<span class="opacitymedium">';
print $langs->trans('RemainderToPay');
if ($resteapayeraffiche < 0)
print ' ('.$langs->trans('ExcessReceived').')';
print ' :</td>';
print '</span>';
print '</td>';
print '<td class="right'.($resteapayeraffiche ? ' amountremaintopay' : (' '.$cssforamountpaymentcomplete)).'">'.price($resteapayeraffiche).'</td>';
print '<td class="nowrap">&nbsp;</td></tr>';

View File

@ -74,7 +74,7 @@ class Facture extends CommonInvoice
public $fk_element = 'fk_facture';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
* @var string String with name of icon for myobject.
*/
public $picto = 'bill';
@ -176,11 +176,6 @@ class Facture extends CommonInvoice
*/
public $fk_bank;
/**
* @deprecated
*/
public $products = array();
/**
* @var FactureLigne[]
*/
@ -1077,7 +1072,6 @@ class Facture extends CommonInvoice
$facture->origin_id = $this->origin_id;
$facture->lines = $this->lines; // Array of lines of invoice
$facture->products = $this->lines; // Tant que products encore utilise
$facture->situation_counter = $this->situation_counter;
$facture->situation_cycle_ref = $this->situation_cycle_ref;
$facture->situation_final = $this->situation_final;
@ -1179,7 +1173,6 @@ class Facture extends CommonInvoice
$object->ref_client = '';
$object->close_code = '';
$object->close_note = '';
$object->products = $object->lines; // For backward compatibility
if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) {
$object->note_private = '';
$object->note_public = '';
@ -1191,7 +1184,6 @@ class Facture extends CommonInvoice
if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts
{
unset($object->lines[$i]);
unset($object->products[$i]); // Tant que products encore utilise
}
// Bloc to update dates of service (month by month only if previously filled at 1d near start or end of month)
// If it's a service with start and end dates
@ -1432,11 +1424,11 @@ class Facture extends CommonInvoice
$label = '';
if ($user->rights->facture->lire) {
$label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Invoice").'</u>';
if ($this->type == self::TYPE_REPLACEMENT) $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("ReplacementInvoice").'</u>';
if ($this->type == self::TYPE_CREDIT_NOTE) $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("CreditNote").'</u>';
if ($this->type == self::TYPE_DEPOSIT) $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("Deposit").'</u>';
if ($this->type == self::TYPE_SITUATION) $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("InvoiceSituation").'</u>';
$label = img_picto('', $picto).' <u class="paddingrightonly">'.$langs->trans("Invoice").'</u>';
if ($this->type == self::TYPE_REPLACEMENT) $label = img_picto('', $picto).' <u class="paddingrightonly">'.$langs->transnoentitiesnoconv("ReplacementInvoice").'</u>';
if ($this->type == self::TYPE_CREDIT_NOTE) $label = img_picto('', $picto).' <u class="paddingrightonly">'.$langs->transnoentitiesnoconv("CreditNote").'</u>';
if ($this->type == self::TYPE_DEPOSIT) $label = img_picto('', $picto).' <u class="paddingrightonly">'.$langs->transnoentitiesnoconv("Deposit").'</u>';
if ($this->type == self::TYPE_SITUATION) $label = img_picto('', $picto).' <u class="paddingrightonly">'.$langs->transnoentitiesnoconv("InvoiceSituation").'</u>';
if (isset($this->statut) && isset($this->alreadypaid)) {
$label .= ' '.$this->getLibStatut(5, $this->alreadypaid);
}
@ -2184,6 +2176,7 @@ class Facture extends CommonInvoice
if (!$this->db->query($sql))
{
$this->error = $this->db->error()." sql=".$sql;
$this->errors[] = $this->error;
$this->db->rollback();
return -5;
}
@ -2244,6 +2237,7 @@ class Facture extends CommonInvoice
{
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteFile", $file);
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
@ -2254,6 +2248,7 @@ class Facture extends CommonInvoice
{
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteDir", $dir);
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
@ -2264,11 +2259,13 @@ class Facture extends CommonInvoice
return 1;
} else {
$this->error = $this->db->lasterror()." sql=".$sql;
$this->errors[] = $this->error;
$this->db->rollback();
return -6;
}
} else {
$this->error = $this->db->lasterror()." sql=".$sql;
$this->errors[] = $this->error;
$this->db->rollback();
return -4;
}
@ -3290,6 +3287,7 @@ class Facture extends CommonInvoice
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
// Clean vat code
$reg = array();
$vat_src_code = '';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{

View File

@ -44,7 +44,7 @@ $mode = GETPOST("mode") ?GETPOST("mode") : 'customer';
if ($mode == 'customer' && !$user->rights->facture->lire) accessforbidden();
if ($mode == 'supplier' && !$user->rights->fournisseur->facture->lire) accessforbidden();
$object_status = GETPOST('object_status');
$object_status = GETPOST('object_status', 'intcomma');
$typent_id = GETPOST('typent_id', 'int');
$categ_id = GETPOST('categ_id', 'categ_id');
@ -59,7 +59,7 @@ if ($user->socid > 0)
}
$nowyear = strftime("%Y", dol_now());
$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear;
if (!empty($conf->global->INVOICE_STATS_GRAPHS_SHOW_2_YEARS)) $startyear = $year - 2;
else $startyear = $year - 1;
$endyear = $year;

View File

@ -1469,9 +1469,9 @@ class Contrat extends CommonObject
}
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
if (empty($qty)) $qty = 1;

View File

@ -40,7 +40,7 @@ if ($type == 'select') $extrasize = '';
// Add attribute
if ($action == 'add')
{
if ($_POST["button"] != $langs->trans("Cancel"))
if (GETPOST("button") != $langs->trans("Cancel"))
{
// Check values
if (!$type)
@ -132,10 +132,28 @@ if ($action == 'add')
}
}
if (!$error)
{
if (!$error) {
if (strlen(GETPOST('attrname', 'aZ09')) < 3) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3);
$action = 'create';
}
}
// Check reserved keyword with more than 3 characters
if (!$error) {
if (in_array(GETPOST('attrname', 'aZ09'), array('and', 'keyword', 'table', 'index', 'integer', 'float', 'double', 'position'))) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09'));
$action = 'create';
}
}
if (!$error) {
// attrname must be alphabetical and lower case only
if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"]))
if (GETPOSISSET("attrname") && preg_match("/^[a-z0-9-_]+$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09')))
{
// Construct array for parameter (value of select list)
$default_value = GETPOST('default_value', 'alpha');
@ -161,7 +179,7 @@ if ($action == 'add')
if ($type == 'separate') $visibility = 3;
$result = $extrafields->addExtraField(
GETPOST('attrname', 'alpha'),
GETPOST('attrname', 'aZ09'),
GETPOST('label', 'alpha'),
$type,
GETPOST('pos', 'int'),
@ -208,7 +226,7 @@ if ($action == 'add')
// Rename field
if ($action == 'update')
{
if ($_POST["button"] != $langs->trans("Cancel"))
if (GETPOST("button") != $langs->trans("Cancel"))
{
// Check values
if (!$type)
@ -293,9 +311,28 @@ if ($action == 'update')
}
}
if (!$error) {
if (strlen(GETPOST('attrname', 'aZ09')) < 3 && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3);
$action = 'edit';
}
}
// Check reserved keyword with more than 3 characters
if (!$error) {
if (in_array(GETPOST('attrname', 'aZ09'), array('and', 'keyword', 'table', 'index', 'integer', 'float', 'double', 'position')) && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09'));
$action = 'edit';
}
}
if (!$error)
{
if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname']))
if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09')))
{
$pos = GETPOST('pos', 'int');
// Construct array for parameter (value of select list)
@ -321,7 +358,7 @@ if ($action == 'update')
if ($type == 'separate') $visibility = 3;
$result = $extrafields->update(
GETPOST('attrname', 'alpha'),
GETPOST('attrname', 'aZ09'),
GETPOST('label', 'alpha'),
$type,
$extrasize,
@ -342,8 +379,7 @@ if ($action == 'update')
(GETPOST('totalizable', 'alpha') ? 1 : 0),
GETPOST('printable', 'alpha')
);
if ($result > 0)
{
if ($result > 0) {
setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
@ -365,13 +401,10 @@ if ($action == 'update')
}
// Delete attribute
if ($action == 'delete')
{
if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"]))
{
$result = $extrafields->delete($_GET["attrname"], $elementtype);
if ($result >= 0)
{
if ($action == 'delete') {
if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST("attrname", 'aZ09'))) {
$result = $extrafields->delete(GETPOST("attrname", 'aZ09'), $elementtype);
if ($result >= 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else $mesg = $extrafields->error;

View File

@ -137,7 +137,7 @@ class box_task extends ModeleBoxes
$boxcontent .= '<script>date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "'.$cookie_name.'='.$filterValue.'; expires= " + date.toGMTString() + "; path=/ "; </script>';
}
$this->info_box_contents[0][] = array(
'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"',
'tr' => 'class="nohover showiffilter'.$this->boxcode.' hideobject"',
'td' => 'class="nohover"',
'textnoformat' => $boxcontent,
);

View File

@ -1,88 +0,0 @@
<?php
/* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) <year> <name of author>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file core/boxes/mybox.php
* \ingroup intracommreport
* \brief This file is a sample box definition file
* Put some comments here
*/
include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
/**
* Class to manage the box
*/
class intracommreportbox extends ModeleBoxes
{
public $boxcode = "mybox";
public $boximg = "intracommreport";
public $boxlabel;
public $depends = array("intracommreport");
public $db;
public $param;
public $info_box_head = array();
public $info_box_contents = array();
/**
* Constructor
*/
public function __construct()
{
global $langs;
$langs->load("boxes");
$this->boxlabel = $langs->transnoentitiesnoconv("MyBox");
}
/**
* Load data into info_box_contents array to show array later.
*
* @param int $max Maximum number of records to load
* @return void
*/
public function loadBox($max = 5)
{
global $conf, $user, $langs, $db;
$this->max = $max;
//include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php";
$text = $langs->trans("MyBoxDescription", $max);
$this->info_box_head = array(
'text' => $text,
'limit' => dol_strlen($text)
);
$this->info_box_contents[0][0] = array('td' => 'align="left"',
'text' => $langs->trans("MyBoxContent"));
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @return void
*/
public function showBox($head = null, $contents = null)
{
parent::showBox($this->info_box_head, $this->info_box_contents);
}
}

View File

@ -277,7 +277,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
for ($j = 0; $j < $nbcolthisline; $j++) {
// Define tdparam
$tdparam = '';
if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td'];
if (!empty($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td'];
$text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : '';
$textwithnotags = preg_replace('/<([^>]+)>/i', '', $text);

View File

@ -1389,7 +1389,7 @@ abstract class CommonDocGenerator
if ($itemsInRow > 0) {
// close table row and empty cols
for ($i = $itemsInRow; $i <= $maxItemsInRow; $i++) {
$html .= "<td ></td><td></td>";
$html .= "<td></td><td></td>";
}
$html .= "</tr>";

View File

@ -578,7 +578,7 @@ abstract class CommonObject
*
* @param Translate $langs Language object for translation of civility (used only if option is 1)
* @param int $option 0=No option, 1=Add civility
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname, 4=Lastname, 5=Lastname if defined else firstname
* @param int $maxlen Maximum length
* @return string String with full name
*/
@ -6317,8 +6317,18 @@ abstract class CommonObject
$param_list_array = explode(':', $param_list[0]);
$showempty = (($required && $default != '') ? 0 : 1);
if (!preg_match('/search_/', $keyprefix) && !empty($param_list_array[2])) { // If the entry into $fields is set to add a create button
$morecss .= ' widthcentpercentminusx';
if (!preg_match('/search_/', $keyprefix)) {
if (!empty($param_list_array[2])) { // If the entry into $fields is set to add a create button
if ($this->fields[$key]['picto']) {
$morecss .= ' widthcentpercentminusxx';
} else {
$morecss .= ' widthcentpercentminusx';
}
} else {
if ($this->fields[$key]['picto']) {
$morecss .= ' widthcentpercentminusx';
}
}
}
$out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, $moreparam, 0, empty($val['disabled']) ? 0 : 1);
@ -8512,13 +8522,13 @@ abstract class CommonObject
}
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files";
$sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->lasterror();
$this->db->rollback();
return false;
}
$sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->lasterror();
$this->db->rollback();
return false;
}
}
$this->db->commit();

View File

@ -631,11 +631,18 @@ class dolReceiptPrinter extends Printer
break;
case 'DOL_PRINT_OBJECT_LINES':
foreach ($object->lines as $line) {
//var_dump($line);
$spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd);
$this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
$this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n");
if ($line->fk_product)
{
$spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd);
$this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
$this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n");
}
else {
$spacestoadd = $nbcharactbyline - strlen($line->description) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd);
$this->printer->text($line->description.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
}
}
break;
case 'DOL_PRINT_OBJECT_TAX':

View File

@ -266,8 +266,8 @@ class Form
elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) $ret .= dol_htmlentitiesbr($value);
elseif (preg_match('/^safehtmlstring/', $typeofdata)) $ret .= dol_string_onlythesehtmltags($value);
elseif (preg_match('/^restricthtml/', $typeofdata)) $ret .= dol_string_onlythesehtmltags($value);
elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret .= dol_print_date($value, 'day');
elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') $ret .= dol_print_date($value, 'dayhour');
elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret .= '<span class="valuedate">'.dol_print_date($value, 'day').'</span>';
elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') $ret .= '<span class="valuedate">'.dol_print_date($value, 'dayhour').'</span>';
elseif (preg_match('/^select;/', $typeofdata))
{
$arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
@ -636,11 +636,11 @@ class Form
* Generate select HTML to choose massaction
*
* @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default.
* @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action.
* @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action.
* @param int $alwaysvisible 1=select button always visible
* @param string $name Name for massaction
* @param string $cssclass CSS class used to check for select
* @return string|void Select list
* @param string $name Name for massaction
* @param string $cssclass CSS class used to check for select
* @return string|void Select list
*/
public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name = 'massaction', $cssclass = 'checkforselect')
{
@ -780,8 +780,6 @@ class Form
$i = 0;
if ($num)
{
$foundselected = false;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
@ -826,16 +824,22 @@ class Form
$atleastonefavorite = 0;
$out .= '<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
}
if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label']))
{
$foundselected = true;
$out .= '<option value="'.($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']).'" selected>';
} else {
$out .= '<option value="'.($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']).'">';
$labeltoshow = '';
if ($row['label']) $labeltoshow .= dol_trunc($row['label'], $maxlength, 'middle');
else $labeltoshow .= '&nbsp;';
if ($row['code_iso']) {
$labeltoshow .= ' <span class="opacitymedium">('.$row['code_iso'].')</span>';
$tmpflag = picto_from_langcode($row['code_iso'], 'class="saturatemedium marginrightonly"');
$labeltoshow = $tmpflag.' '.$labeltoshow;
}
if ($row['label']) $out .= dol_trunc($row['label'], $maxlength, 'middle');
else $out .= '&nbsp;';
if ($row['code_iso']) $out .= ' ('.$row['code_iso'].')';
if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label'])) {
$out .= '<option value="'.($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']).'" selected data-html="'.dol_escape_htmltag($labeltoshow).'">';
} else {
$out .= '<option value="'.($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']).'" data-html="'.dol_escape_htmltag($labeltoshow).'">';
}
$out .= $labeltoshow;
$out .= '</option>';
}
}
@ -1413,7 +1417,7 @@ class Form
* @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
* @return int <0 if KO, Nb of contact in list if OK
* @deprected You can use selectcontacts directly (warning order of param was changed)
* @deprecated You can use selectcontacts directly (warning order of param was changed)
*/
public function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '')
{
@ -1485,11 +1489,10 @@ class Form
$out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
}
if ($htmlname != 'none' && !$options_only) $out .= '<select class="flat'.($moreclass ? ' '.$moreclass : '').'" id="'.$htmlid.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.(!empty($moreparam) ? $moreparam : '').'>';
if ($htmlname != 'none' && !$options_only) $out .= '<select class="flat'.($moreclass ? ' '.$moreclass : '').'"'.($num?'':' disabled').' id="'.$htmlid.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.(!empty($moreparam) ? $moreparam : '').'>';
if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>&nbsp;</option>';
if ($showempty == 2) $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>-- '.$langs->trans("Internal").' --</option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
@ -1561,8 +1564,9 @@ class Form
$i++;
}
} else {
$out .= '<option value="-1"'.(($showempty == 2 || $multiple) ? '' : ' selected').' disabled>';
$out .= ($socid != -1) ? ($langs->trans($socid ? "NoContactDefinedForThirdParty" : "NoContactDefined")) : $langs->trans('SelectAThirdPartyFirst');
$labeltoshow = ($socid != -1) ? ($langs->trans($socid ? "NoContactDefinedForThirdParty" : "NoContactDefined")) : $langs->trans('SelectAThirdPartyFirst');
$out .= '<option class="disabled" value="-1"'.(($showempty == 2 || $multiple) ? '' : ' selected').' disabled="disabled">';
$out .= $labeltoshow;
$out .= '</option>';
}
@ -2738,12 +2742,13 @@ class Form
* @param int $limit Limit of line number
* @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices
* @param string $morecss Add more CSS
* @param int $showstockinlist Show stock information (slower).
* @return array Array of keys for json
*/
public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '')
public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '', $showstockinlist = 0)
{
// phpcs:enable
global $langs, $conf, $db;
global $langs, $conf, $db, $user;
$out = '';
$outarray = array();
@ -2756,7 +2761,7 @@ class Form
$langs->load('other');
}
$sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type,";
$sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type, p.stock,";
$sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
$sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
$sql .= " pfp.supplier_reputation";
@ -2974,6 +2979,45 @@ class Form
}
}
if (!empty($conf->stock->enabled) && $showstockinlist && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
{
$novirtualstock = ($showstockinlist == 2);
if (!empty($user->rights->stock->lire)) {
$outvallabel .= ' - '.$langs->trans("Stock").':'.$objp->stock;
if ($objp->stock > 0) {
$optlabel .= ' - <span class="product_line_stock_ok">';
} elseif ($objp->stock <= 0) {
$optlabel .= ' - <span class="product_line_stock_too_low">';
}
$optlabel .= $langs->transnoentities("Stock").':'.$objp->stock;
$optlabel .= '</span>';
if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation
{
$langs->load("stocks");
$tmpproduct = new Product($this->db);
$tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after)
$tmpproduct->load_virtual_stock();
$virtualstock = $tmpproduct->stock_theorique;
$outvallabel .= ' - '.$langs->trans("VirtualStock").':'.$virtualstock;
$optlabel .= ' - '.$langs->transnoentities("VirtualStock").':';
if ($virtualstock > 0) {
$optlabel .= '<span class="product_line_stock_ok">';
} elseif ($virtualstock <= 0) {
$optlabel .= '<span class="product_line_stock_too_low">';
}
$optlabel .= $virtualstock;
$optlabel .= '</span>';
unset($tmpproduct);
}
}
}
$opt = '<option value="'.$outkey.'"';
if ($selected && $selected == $objp->idprodfournprice) $opt .= ' selected';
if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled';
@ -5058,19 +5102,21 @@ class Form
$out .= '<select class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'" id="'.$htmlname.'">';
foreach ($langs->cache_currencies as $code_iso => $currency)
{
if ($selected && $selected == $code_iso)
{
$out .= '<option value="'.$code_iso.'" selected>';
} else {
$out .= '<option value="'.$code_iso.'">';
}
$out .= $currency['label'];
$labeltoshow = $currency['label'];
if ($mode == 1)
{
$out .= ' ('.$code_iso.')';
$labeltoshow .= ' <span class="opacitymedium">('.$code_iso.')</span>';
} else {
$out .= ' ('.$langs->getCurrencySymbol($code_iso).')';
$labeltoshow .= ' <span class="opacitymedium">('.$langs->getCurrencySymbol($code_iso).')</span>';
}
if ($selected && $selected == $code_iso)
{
$out .= '<option value="'.$code_iso.'" selected data-html="'.dol_escape_htmltag($labeltoshow).'">';
} else {
$out .= '<option value="'.$code_iso.'" data-html="'.dol_escape_htmltag($labeltoshow).'">';
}
$out .= $labeltoshow;
$out .= '</option>';
}
$out .= '</select>';
@ -6554,7 +6600,7 @@ class Form
var separ = urlBase.indexOf("?") >= 0 ? "&" : "?";
/* console.log("params.term="+params.term); */
/* console.log("params.term encoded="+encodeURIComponent(params.term)); */
saveRemoteData[data.id].url = urlBase + separ + "sall=" + encodeURIComponent(params.term);';
saveRemoteData[data.id].url = urlBase + separ + "sall=" + encodeURIComponent(params.term.replace(/\"/g, ""));';
}
if (!$disableFiltering) {
@ -6585,7 +6631,7 @@ class Form
$.each( saveRemoteData, function( key, value ) {
if (key == selected)
{
console.log("selectArrayAjax - Do a redirect to "+value.url)
console.log("selectArrayFilter - Do a redirect to "+value.url)
location.assign(value.url);
}
});

View File

@ -98,7 +98,7 @@ class FormAdmin
if ($showcode == 1) $valuetoshow = $key.' - '.$value;
if ($showcode == 2) {
if ($mainlangonly) $valuetoshow = $value.' ('.preg_replace('/[_-].*$/', '', $key).')';
else $valuetoshow = $value.' ('.$key.')';
else $valuetoshow = $value.' <span class="opacitymedium">('.$key.')</span>';
}
$keytouse = $key;
@ -111,11 +111,11 @@ class FormAdmin
continue;
}
if ($selected == $keytouse)
{
$out .= '<option value="'.$keytouse.'" selected>'.$valuetoshow.'</option>';
$valuetoshow .= ' '.picto_from_langcode($key, 'class="saturatemedium"');
if ($selected == $keytouse) {
$out .= '<option value="'.$keytouse.'" selected data-html="'.dol_escape_htmltag($valuetoshow).'">'.$valuetoshow.'</option>';
} else {
$out .= '<option value="'.$keytouse.'">'.$valuetoshow.'</option>';
$out .= '<option value="'.$keytouse.'" data-html="'.dol_escape_htmltag($valuetoshow).'">'.$valuetoshow.'</option>';
}
}
$out .= '</select>';

View File

@ -62,8 +62,11 @@ class FormOrder extends Form
$options[$value] = $tmpsupplierorder->getLibStatut($short);
}
print Form::selectarray($hmlname, $options, $selected, 1, 0, 0, '', 0, 0, 0, '', '', 1);
}
if (is_array($selected)) $selectedarray = $selected;
else $selectedarray = explode(',', $selected);
print Form::multiselectarray($hmlname, $options, $selectedarray, 0);
}
/**
* Return list of input method (mode used to receive order, like order received by email, fax, online)

View File

@ -207,7 +207,7 @@ class Interfaces
if ($result < 0)
{
// Action KO
//dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR);
//dol_syslog("Error in trigger ".$action." - result = ".$result." - Nb of error string returned = ".count($objMod->errors), LOG_ERR);
$nbtotal++;
$nbko++;
if (!empty($objMod->errors)) $this->errors = array_merge($this->errors, $objMod->errors);

View File

@ -589,16 +589,15 @@ class Translate
/**
* Return text translated of text received as parameter (and encode it into HTML)
* If there is no match for this text, we look in alternative file and if still not found,
* it is returned as it is
* The parameters of this method can contain HTML tags
* If there is no match for this text, we look in alternative file and if still not found, it is returned as it is.
* The parameters of this method should not contain HTML tags. If there is, they will be htmlencoded to have no effect.
*
* @param string $key Key to translate
* @param string $param1 param1 string
* @param string $param2 param2 string
* @param string $param3 param3 string
* @param string $param4 param4 string
* @param int $maxsize Max length of text
* @param int $maxsize Max length of text. Warning: Will not work if paramX has HTML content. deprecated.
* @return string Translated string (encoded into HTML entities and UTF8)
*/
public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $maxsize = 0)
@ -621,25 +620,33 @@ class Translate
}
}
// We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities because
// we want to keep '"' '<b>' '</b>' '<strong' '</strong>' '<a ' '</a>' '<br>' '< ' '<span' '</span>' that are reliable HTML tags inside translation strings.
$str = str_replace(
array('"', '<b>', '</b>', '<strong>', '</strong>', '<a ', '</a>', '<br>', '<span', '</span>', '< ', '>'), // We accept '< ' but not '<'. We can accept however '>'
array('__quot__', '__tagbold__', '__tagboldend__', '__tagbold__', '__tagboldend__', '__taga__', '__tagaend__', '__tagbr__', '__tagspan__', '__tagspanend__', '__lt__', '__gt__'),
$str
);
if (strpos($key, 'Format') !== 0)
{
$str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
}
// Crypt string into HTML
$str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are embraced by "). Use dol_escape_htmltag around text in HTML content
// Restore reliable HTML tags into original translation string
$str = str_replace(
array('__quot__', '__tagbold__', '__tagboldend__', '__taga__', '__tagaend__', '__tagbr__', '__tagspan__', '__tagspanend__', '__lt__', '__gt__'),
array('"', '<b>', '</b>', '<a ', '</a>', '<br>', '<span', '</span>', '< ', '> '),
$str
);
if ($maxsize) $str = dol_trunc($str, $maxsize);
// We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities
$str = str_replace(array('<', '>', '"',), array('__lt__', '__gt__', '__quot__'), $str);
// Crypt string into HTML
$str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are enmbraced by "). Use dol_escape_htmltag around text in HTML content
// Restore HTML tags
$str = str_replace(array('__lt__', '__gt__', '__quot__'), array('<', '>', '"',), $str);
return $str;
} else // Translation is not available
{
} else { // Translation is not available
//if ($key[0] == '$') { return dol_eval($key,1); }
return $this->getTradFromKey($key);
}

View File

@ -24,6 +24,11 @@
class WorkboardResponse
{
/**
* Unique key of the workboard
* @var string
*/
public $id;
/**
* Image URL to represent the board item

View File

@ -402,36 +402,36 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle
}
}
if ($error == 0)
{
if (!$silent) {
print '<tr><td>'.$langs->trans("ProcessMigrateScript").'</td>';
print '<td class="right">'.$langs->trans("OK");
//if (! empty($conf->use_javascript_ajax)) {
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_trrunsql()
{
console.log("toggle .trforrunsql");
jQuery(".trforrunsql").toggle();
}
init_trrunsql();
jQuery(".trforrunsqlshowhide").click(function() {
init_trrunsql();
});
});
</script>';
print ' - <a class="trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>';
//}
print '</td></tr>'."\n";
if (!$silent) {
print '<tr><td>'.$langs->trans("ProcessMigrateScript").'</td>';
print '<td class="right">';
if ($error == 0) {
print '<span class="ok">'.$langs->trans("OK").'</span>';
} else {
print '<span class="error">'.$langs->trans("Error").'</span>';
}
//if (! empty($conf->use_javascript_ajax)) {
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_trrunsql()
{
console.log("toggle .trforrunsql");
jQuery(".trforrunsql").toggle();
}
init_trrunsql();
jQuery(".trforrunsqlshowhide").click(function() {
init_trrunsql();
});
});
</script>';
print ' - <a class="trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>';
//}
print '</td></tr>'."\n";
}
if ($error == 0) {
$ok = 1;
} else {
if (!$silent) {
print '<tr><td>'.$langs->trans("ProcessMigrateScript").'</td>';
print '<td class="right"><font class="error">'.$langs->trans("KO").'</font>';
print '</td></tr>'."\n";
}
$ok = 0;
}

View File

@ -1060,7 +1060,7 @@ function dol_escape_json($stringtoescape)
* Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
*
* @param string $stringtoescape String to escape
* @param int $keepb 1=Preserve b tags (otherwise, remove them)
* @param int $keepb 1=Keep b tags and escape them, 0=remove them
* @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value). Set to 1 when escaping for a <textarea>.
* @param string $keepmoretags '' or 'common' or list of tags
* @param int $escapeonlyhtmltags 1=Escape only html tags, not the special chars like accents.
@ -1069,7 +1069,7 @@ function dol_escape_json($stringtoescape)
*/
function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $keepmoretags = '', $escapeonlyhtmltags = 0)
{
if ($keepmoretags == 'common') $keepmoretags = 'html,body,a,em,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
if ($keepmoretags == 'common') $keepmoretags = 'html,body,a,b,em,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
// TODO Implement $keepmoretags
// escape quotes and backslashes, newlines, etc.
@ -3192,7 +3192,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$pictowithouttext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto);
if (empty($srconly) && in_array($pictowithouttext, array(
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected',
'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'bookmark', 'bom', 'building',
'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building',
'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cubes',
'delete', 'dolly', 'dollyrevert', 'donation', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt',
'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group',
@ -4761,14 +4761,15 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
* 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK)
* 'CR'=Currency rate
* Numeric = Nb of digits for rounding
* @param int $alreadysqlnb Put 1 if you know that content is already universal format number
* @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done)
* Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator).
* @return string Amount with universal numeric format (Example: '99.99999').
* If conversion fails, it return text unchanged if $rounding = '' or '0' if $rounding is defined.
* If amount is null or '', it returns '' if $rounding = '' or '0' if $rounding is defined..
*
* @see price() Opposite function of price2num
*/
function price2num($amount, $rounding = '', $alreadysqlnb = 0)
function price2num($amount, $rounding = '', $option = 0)
{
global $langs, $conf;
@ -4783,14 +4784,19 @@ function price2num($amount, $rounding = '', $alreadysqlnb = 0)
//print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
// Convert value to universal number format (no thousand separator, '.' as decimal separator)
if ($alreadysqlnb != 1) { // If not a PHP number or unknown, we change or clean format
if ($option != 1) { // If not a PHP number or unknown, we change or clean format
//print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
if ($thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator, not as a decimal separator
$amount = str_replace($thousand, '', $amount); // Replace of thousand before test of is_numeric to avoid pb if thousand is . and there is 3 numbers after
if (!is_numeric($amount)) {
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\-]/', '', $amount);
}
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123
$amount = str_replace($thousand, '', $amount);
}
// Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number
// to format defined by LC_NUMERIC after a calculation and we want source format to be like defined by Dolibarr setup.
// So if number was already a good number, it is converted into local Dolibarr setup.
if (is_numeric($amount))
{
// We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10
@ -4799,7 +4805,7 @@ function price2num($amount, $rounding = '', $alreadysqlnb = 0)
$nbofdec = max(0, dol_strlen($temps) - 2); // -2 to remove "0."
$amount = number_format($amount, $nbofdec, $dec, $thousand);
}
//print "QQ".$amount.'<br>';
//print "QQ".$amount."<br>\n";
// Now make replace (the main goal of function)
if ($thousand != ',' && $thousand != '.') {
@ -6731,7 +6737,7 @@ function get_date_range($date_start, $date_end, $format = '', $outputlangs = '',
*
* @param string $firstname Firstname
* @param string $lastname Lastname
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname, 4=Lastname, 5=Lastname if defined else firstname
* @return string Firstname + lastname or Lastname + firstname
*/
function dolGetFirstLastname($firstname, $lastname, $nameorder = -1)
@ -6741,22 +6747,24 @@ function dolGetFirstLastname($firstname, $lastname, $nameorder = -1)
$ret = '';
// If order not defined, we use the setup
if ($nameorder < 0) $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
if ($nameorder && $nameorder != 2 && $nameorder != 3)
{
if ($nameorder == 1) {
$ret .= $firstname;
if ($firstname && $lastname) $ret .= ' ';
$ret .= $lastname;
} elseif ($nameorder == 2 || $nameorder == 3)
{
} elseif ($nameorder == 2 || $nameorder == 3) {
$ret .= $firstname;
if (empty($ret) && $nameorder == 3)
{
if (empty($ret) && $nameorder == 3) {
$ret .= $lastname;
}
} else {
} else { // 0, 4 or 5
$ret .= $lastname;
if ($firstname && $lastname) $ret .= ' ';
$ret .= $firstname;
if (empty($ret) && $nameorder == 5) {
$ret .= $firstname;
}
if ($nameorder == 0) {
if ($firstname && $lastname) $ret .= ' ';
$ret .= $firstname;
}
}
return $ret;
}
@ -7256,14 +7264,12 @@ function dol_validElement($element)
/**
* Return img flag of country for a language code or country code
*
* @param string $codelang Language code (en_IN, fr_CA...) or Country code (IN, FR)
* @param string $moreatt Add more attribute on img tag (For example 'style="float: right"')
* @param string $codelang Language code ('en_IN', 'fr_CA', ...) or ISO Country code on 2 characters in uppercase ('IN', 'FR')
* @param string $moreatt Add more attribute on img tag (For example 'style="float: right"' or 'class="saturatemedium"')
* @return string HTML img string with flag.
*/
function picto_from_langcode($codelang, $moreatt = '')
{
global $langs;
if (empty($codelang)) return '';
if ($codelang == 'auto')
@ -7276,7 +7282,14 @@ function picto_from_langcode($codelang, $moreatt = '')
'ca_ES' => 'catalonia',
'da_DA' => 'dk',
'fr_CA' => 'mq',
'sv_SV' => 'se'
'sv_SV' => 'se',
'AQ' => 'unknown',
'CW' => 'unknown',
'IM' => 'unknown',
'JE' => 'unknown',
'MF' => 'unknown',
'BL' => 'unknown',
'SX' => 'unknown'
);
if (isset($langtocountryflag[$codelang])) $flagImage = $langtocountryflag[$codelang];

View File

@ -103,8 +103,7 @@ function dol_json_encode($elements)
*/
function _val($val)
{
if (is_string($val))
{
if (is_string($val)) {
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($val);

View File

@ -1180,7 +1180,7 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
{
$special_code = $object->lines[$i]->special_code;
$special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('pdf'=>$pdf, 'i'=>$i, 'outputlangs'=>$outputlangs, 'w'=>$w, 'h'=>$h, 'posx'=>$posx, 'posy'=>$posy, 'hideref'=>$hideref, 'hidedesc'=>$hidedesc, 'issupplierline'=>$issupplierline, 'special_code'=>$special_code);
$action = '';
@ -1338,28 +1338,23 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
// We add ref of product (and supplier ref if defined)
$prefix_prodserv = "";
$ref_prodserv = "";
if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this
{
if ($prodser->isService())
{
if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) { // In standard mode, we do not show this
if ($prodser->isService()) {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
} else {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
}
}
if (empty($hideref))
{
if ($issupplierline)
{
if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1)
$ref_prodserv = $ref_supplier;
elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2)
$ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
else // Common case
{
if (empty($hideref)) {
if ($issupplierline) {
if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) { // Common case
$ref_prodserv = $prodser->ref; // Show local ref
if ($ref_supplier) $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : '');
} elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) {
$ref_prodserv = $ref_supplier;
} elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) {
$ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
}
} else {
$ref_prodserv = $prodser->ref; // Show local ref only
@ -1966,7 +1961,7 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0)
elseif (empty($hidedetails) || $hidedetails > 1)
{
$total_ht = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
if ($object->lines[$i]->situation_percent > 0)
if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0)
{
// TODO Remove this. The total should be saved correctly in database instead of being modified here.
$prev_progress = 0;

View File

@ -163,4 +163,3 @@ function dolSessionGC($max_lifetime)
// Call to register user call back functions.
session_set_save_handler("dolSessionOpen", "dolSessionClose", "dolSessionRead", "dolSessionWrite", "dolSessionDestroy", "dolSessionGC");

View File

@ -103,10 +103,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$seller = $mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc
//var_dump($seller->country_id);exit;
}
if (empty($localtaxes_array) || !is_array($localtaxes_array))
{
if (empty($localtaxes_array) || !is_array($localtaxes_array)) {
dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter localtaxes_array that is missing", LOG_WARNING);
}
if (!is_numeric($txtva)) {
dol_syslog("Price.lib::calcul_price_total Warning: function was called with a parameter vat rate that is not a real numeric value. There is surely a bug.", LOG_ERR);
} elseif ($txtva >= 1000) {
dol_syslog("Price.lib::calcul_price_total Warning: function was called with a bad value for vat rate (should be often < 100, always < 1000). There is surely a bug.", LOG_ERR);
}
// Too verbose. Enable for debug only
//dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress);

View File

@ -483,7 +483,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
$taskstatic->projectstatus = $lines[$i]->projectstatus;
$taskstatic->progress = $lines[$i]->progress;
$taskstatic->fk_statut = $lines[$i]->status;
$taskstatic->datee = $lines[$i]->date_end;
$taskstatic->date_start = $lines[$i]->date_start;
$taskstatic->date_end = $lines[$i]->date_end;
$taskstatic->datee = $lines[$i]->date_end; // deprecated
$taskstatic->planned_workload = $lines[$i]->planned_workload;
$taskstatic->duration_effective = $lines[$i]->duration;
@ -2400,8 +2402,8 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide
// this conf is actually hidden, by default we use 10% for "be carefull or warning"
$warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10;
$diffTitle = '<br/>'.$langs->trans('ProgressDeclared').' : '.$task->progress.($task->progress ? '%' : '');
$diffTitle .= '<br/>'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.($progressCalculated ? '%' : '');
$diffTitle = '<br>'.$langs->trans('ProgressDeclared').' : '.$task->progress.($task->progress ? '%' : '');
$diffTitle .= '<br>'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.($progressCalculated ? '%' : '');
//var_dump($progressCalculated.' '.$warningRatio.' '.$task->progress.' '.doubleval($task->progress * $warningRatio));
if (doubleval($progressCalculated) > doubleval($task->progress * $warningRatio)) {

View File

@ -224,8 +224,9 @@ class pdf_einstein extends ModelePDFCommandes
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
global $outputlangsbis;
$outputlangsbis = null;
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@ -332,7 +333,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->AddPage();
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null));
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);

View File

@ -208,8 +208,9 @@ class pdf_eratosthene extends ModelePDFCommandes
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
global $outputlangsbis;
$outputlangsbis = null;
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@ -390,7 +391,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$nexY = max($pdf->GetY(), $nexY);
$height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
@ -541,7 +542,7 @@ class pdf_eratosthene extends ModelePDFCommandes
// Use new auto column system
$this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
// tab simulation to know line height
// Table simulation to know the height of the title line
$pdf->startTransaction();
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
$pdf->rollbackTransaction(true);
@ -568,6 +569,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$showpricebeforepagebreak = 1;
$posYAfterImage = 0;
$posYAfterDescription = 0;
if ($this->getColumnStatus('photo'))
{
@ -600,8 +602,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->startTransaction();
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
@ -632,10 +634,10 @@ class pdf_eratosthene extends ModelePDFCommandes
{
$pdf->commitTransaction();
}
$posYAfterDescription = $pdf->GetY();
}
$nexY = max($pdf->GetY(), $posYAfterImage);
@ -1244,8 +1246,8 @@ class pdf_eratosthene extends ModelePDFCommandes
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
$totalvat .= ' ';
$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@ -1325,7 +1327,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', 1);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
@ -1452,8 +1454,7 @@ class pdf_eratosthene extends ModelePDFCommandes
} else {
$logo = $logodir.'/logos/'.$this->emetteur->logo;
}
if (is_readable($logo))
{
if (is_readable($logo)) {
$height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else {
@ -1472,17 +1473,28 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$title = $outputlangs->transnoentities($titlekey);
$pdf->MultiCell($w, 4, $title, '', 'R');
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
$title .= ' - ';
$title .= $outputlangsbis->transnoentities($titlekey);
}
$pdf->MultiCell($w, 3, $title, '', 'R');
$pdf->SetFont('', 'B', $default_font_size);
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
$textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
if ($object->statut == $object::STATUS_DRAFT)
{
$pdf->SetTextColor(128, 0, 0);
$textref .= ' - '.$outputlangs->transnoentities("NotValidated");
}
$pdf->MultiCell($w, 4, $textref, '', 'R');
$posy += 1;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->SetFont('', '', $default_font_size - 2);
if ($object->ref_client)
{
@ -1520,7 +1532,11 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
$title = $outputlangs->transnoentities("OrderDate");
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
$title .= ' - '.$outputlangsbis->transnoentities("DateInvoice");
}
$pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client))
{
@ -1572,10 +1588,14 @@ class pdf_eratosthene extends ModelePDFCommandes
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
$posy = 42 + $top_shift;
$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
$posy += $top_shift;
$posx = $this->marge_gauche;
if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
$hautcadre = 40;
$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
// Show sender frame
$pdf->SetTextColor(0, 0, 0);
@ -1584,20 +1604,19 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
$pdf->SetXY($posx, $posy);
$pdf->SetFillColor(230, 230, 230);
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
$pdf->SetTextColor(0, 0, 60);
// Show sender name
$pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
$pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
$posy = $pdf->getY();
// Show sender information
$pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
$pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
// If CUSTOMER contact defined, we use it
$usecontact = false;
@ -1751,7 +1770,7 @@ class pdf_eratosthene extends ModelePDFCommandes
'border-left' => false, // remove left line separator
);
if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE) && !empty($this->atleastonephoto))
{
$this->cols['photo']['status'] = true;
}

View File

@ -168,8 +168,9 @@ class pdf_espadon extends ModelePdfExpedition
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
global $outputlangsbis;
$outputlangsbis = null;
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));

View File

@ -693,6 +693,8 @@ class pdf_merou extends ModelePdfExpedition
$blW = 54;
$Yoff = $Ydef + 1;
$widthrecbox = $blW;
// Show Recipient frame
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->SetXY($blDestX, $Yoff - 4);

View File

@ -526,12 +526,12 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetXY($this->posxweightvol, $curY);
$weighttxt = '';
if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight)
{
$weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
}
$voltxt = '';
if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->volume)
{
$voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
}
@ -712,8 +712,8 @@ class pdf_rouget extends ModelePdfExpedition
if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
if (!empty($object->trueWeight)) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
if (!empty($object->trueVolume)) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);

View File

@ -219,8 +219,9 @@ class pdf_sponge extends ModelePDFFactures
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
global $outputlangsbis;
$outputlangsbis = null;
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies"));
@ -260,7 +261,11 @@ class pdf_sponge extends ModelePDFFactures
{
if (!$arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir;
if ($conf->product->entity != $objphoto->entity) {
$dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
} else {
$dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
}
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
@ -646,6 +651,7 @@ class pdf_sponge extends ModelePDFFactures
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
@ -675,7 +681,8 @@ class pdf_sponge extends ModelePDFFactures
$posYAfterDescription = $pdf->GetY();
}
$nexY = $pdf->GetY();
$nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
$pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
@ -2000,7 +2007,7 @@ class pdf_sponge extends ModelePDFFactures
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
$title .= ' - '.$outputlangsbis->transnoentities("DateInvoice");
}
$pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
$pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
{

View File

@ -300,6 +300,7 @@ class modBom extends DolibarrModules
$this->export_dependencies_array[$r] = array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'bom_bom as t';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bom_extrafields as extra on (t.rowid = extra.fk_object)';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid';
$this->export_sql_end[$r] .= ' WHERE 1 = 1';
$this->export_sql_end[$r] .= ' AND t.entity IN ('.getEntity('bom').')';

View File

@ -176,56 +176,20 @@ class modCategorie extends DolibarrModules
's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", 's.fk_prospectlevel'=>'company',
's.fk_stcomm'=>'company'
); // We define here only fields that use another picto
$keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object ';
$this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
$this->export_sql_end[$r] .= ' AND u.type = 2'; // Customer/Prospect categories
// Add extra fields
$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj = $this->db->fetch_object($resql))
{
$fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label);
$typeFilter = "Text";
switch ($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
$typeFilter = "Date";
break;
case 'boolean':
$typeFilter = "Boolean";
break;
case 'sellist':
$typeFilter = "List:".$obj->param;
break;
case 'select':
$typeFilter = "Select:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname] = $fieldlabel;
$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
$this->export_entities_array[$r][$fieldname] = 'company';
}
}
// End add axtra fields
$r++;
$this->export_code[$r] = 'category_'.$r;
$this->export_label[$r] = 'CatProdList';

View File

@ -137,10 +137,18 @@ abstract class ModeleProductCode
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;
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");
}
@ -159,12 +167,10 @@ abstract class ModeleProductCode
$sql = "";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$row = $db->fetch_row($resql);
$liste[$row[0]] = $row[1];
$i++;
@ -188,37 +194,37 @@ abstract class ModeleProductCode
global $conf;
$langs->load("admin");
$strikestart = '';
$strikeend = '';
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
$strikestart = '<strike>';
$strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
}
$s = '';
if ($type == -1) {
$s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
$s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
} elseif ($type == 0) {
$s .= $langs->trans("ProductCodeDesc").'<br>';
} elseif ($type == 1) {
$s .= $langs->trans("ServiceCodeDesc").'<br>';
}
if ($type != -1) {
$s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
}
if ($type == 0) $s .= $langs->trans("ProductCodeDesc").'<br>';
if ($type == 1) $s .= $langs->trans("ServiceCodeDesc").'<br>';
if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s .= '<br>';
$s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0)
{
$s .= $langs->trans("RequiredIfProduct").': ';
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
$s .= yn(!$this->code_null, 1, 2);
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
if ($type == 0) {
$s .= $langs->trans("RequiredIfProduct").': '.$strikestart;
$s .= yn(!$this->code_null, 1, 2).$strikeend;
$s .= '<br>';
} elseif ($type == 1)
{
$s .= $langs->trans("RequiredIfService").': ';
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
$s .= yn(!$this->code_null, 1, 2);
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
} elseif ($type == 1) {
$s .= $langs->trans("RequiredIfService").': '.$strikestart;
$s .= yn(!$this->code_null, 1, 2).$strikeend;
$s .= '<br>';
} elseif ($type == -1)
{
$s .= $langs->trans("Required").': ';
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
$s .= yn(!$this->code_null, 1, 2);
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
} elseif ($type == -1) {
$s .= $langs->trans("Required").': '.$strikestart;
$s .= yn(!$this->code_null, 1, 2).$strikeend;
$s .= '<br>';
}
$s .= $langs->trans("CanBeModifiedIfOk").': ';
@ -227,16 +233,18 @@ abstract class ModeleProductCode
$s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s .= '<br>';
if ($type == 0 || $type == -1)
{
if ($type == 0 || $type == -1) {
$nextval = $this->getNextValue($product, 0);
if (empty($nextval)) $nextval = $langs->trans("Undefined");
if (empty($nextval)) {
$nextval = $langs->trans("Undefined");
}
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Product").')' : '').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
if ($type == 1 || $type == -1) {
$nextval = $this->getNextValue($product, 1);
if (empty($nextval)) $nextval = $langs->trans("Undefined");
if (empty($nextval)) {
$nextval = $langs->trans("Undefined");
}
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Service").')' : '').': <b>'.$nextval.'</b>';
}
return $s;

View File

@ -209,8 +209,9 @@ class pdf_cyan extends ModelePDFPropales
// Load translation files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
global $outputlangsbis;
$outputlangsbis = null;
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));

View File

@ -85,8 +85,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
$s1 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">', $tooltip, 1, 1);
$s2 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">', $tooltip, 1, 1);
$texte .= '<tr><td>';
$texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2)."<br>\n";
$texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1)."<br>\n";
// trans remove html entities
$texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, '{s2}')."<br>\n";
$texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, '{s1}')."<br>\n";
$texte = str_replace(array('{s1}', '{s2}'), array($s1, $s2), $texte);
$texte .= "<br>\n";
if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."<br>\n";
//if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."<br>\n";

View File

@ -99,8 +99,10 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
$s3 = $form->textwithpicto('<input type="text" class="flat" size="2" name="value3" value="'.$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER.'">', $tooltip, 1, 1);
$s4 = $form->textwithpicto('<input type="text" class="flat" size="2" name="value4" value="'.$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER.'">', $tooltip, 1, 1);
$texte .= '<tr><td>';
$texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2, $s4)."<br>\n";
$texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1, $s3)."<br>\n";
// trans remove html entities
$texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, '{s2}', '{s4}')."<br>\n";
$texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, '{s1}', '{s3}')."<br>\n";
$texte = str_replace(array('{s1}', '{s2}', '{s3}', '{s4}'), array($s1, $s2, $s3, $s4), $texte);
$texte .= "<br>\n";
// Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default)
if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."<br>\n";

View File

@ -168,12 +168,10 @@ abstract class ModeleThirdPartyCode
$sql = "";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$row = $db->fetch_row($resql);
$liste[$row[0]] = $row[1];
$i++;
@ -197,6 +195,12 @@ abstract class ModeleThirdPartyCode
global $conf;
$langs->load("admin");
$strikestart = '';
$strikeend = '';
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
$strikestart = '<strike>';
$strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
}
$s = '';
if ($type == -1) {
@ -207,28 +211,23 @@ abstract class ModeleThirdPartyCode
$s .= $langs->trans("CustomerCodeDesc").'<br>';
} elseif ($type == 1) {
$s .= $langs->trans("SupplierCodeDesc").'<br>';
} elseif ($type != -1) {
}
if ($type != -1) {
$s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
}
$s .= '<br>';
$s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0) {
$s .= $langs->trans("RequiredIfCustomer").': ';
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
$s .= yn(!$this->code_null, 1, 2);
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s .= $langs->trans("RequiredIfCustomer").': '.$strikestart;
$s .= yn(!$this->code_null, 1, 2).$strikeend;
$s .= '<br>';
} elseif ($type == 1) {
$s .= $langs->trans("RequiredIfSupplier").': ';
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
$s .= yn(!$this->code_null, 1, 2);
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s .= $langs->trans("RequiredIfSupplier").': '.$strikestart;
$s .= yn(!$this->code_null, 1, 2).$strikeend;
$s .= '<br>';
} elseif ($type == -1) {
$s .= $langs->trans("Required").': ';
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
$s .= yn(!$this->code_null, 1, 2);
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s .= $langs->trans("Required").': '.$strikestart;
$s .= yn(!$this->code_null, 1, 2).$strikeend;
$s .= '<br>';
}
$s .= $langs->trans("CanBeModifiedIfOk").': ';
@ -239,12 +238,16 @@ abstract class ModeleThirdPartyCode
$s .= '<br>';
if ($type == 0 || $type == -1) {
$nextval = $this->getNextValue($soc, 0);
if (empty($nextval)) $nextval = $langs->trans("Undefined");
if (empty($nextval)) {
$nextval = $langs->trans("Undefined");
}
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1) {
$nextval = $this->getNextValue($soc, 1);
if (empty($nextval)) $nextval = $langs->trans("Undefined");
if (empty($nextval)) {
$nextval = $langs->trans("Undefined");
}
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
}
return $s;
@ -360,13 +363,17 @@ abstract class ModeleAccountancyCode
if ($type == 0 || $type == -1) {
$result = $this->get_code($db, $soc, 'customer');
$nextval = $this->code;
if (empty($nextval)) $nextval = $langs->trans("Undefined");
if (empty($nextval)) {
$nextval = $langs->trans("Undefined");
}
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1) {
$result = $this->get_code($db, $soc, 'supplier');
$nextval = $this->code;
if (empty($nextval)) $nextval = $langs->trans("Undefined");
if (empty($nextval)) {
$nextval = $langs->trans("Undefined");
}
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
}
return $s;

View File

@ -400,6 +400,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pageposbefore = $pdf->getPage();
$showpricebeforepagebreak = 1;
$posYAfterImage = 0;
// Description of product line
$curX = $this->posxdesc - 1;

View File

@ -192,8 +192,9 @@ class pdf_cornas extends ModelePDFSuppliersOrders
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
global $outputlangsbis;
$outputlangsbis = null;
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$outputlangsbis->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));

View File

@ -53,6 +53,7 @@ foreach ($object->fields as $key => $val)
else print $langs->trans($val['label']);
print '</td>';
print '<td>';
if (!empty($val['picto'])) { print img_picto('', $val['picto']); }
if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int');
elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOST($key, 'restricthtml');
else $value = GETPOST($key, 'alpha');

View File

@ -51,6 +51,7 @@ foreach ($object->fields as $key => $val)
else print $langs->trans($val['label']);
print '</td>';
print '<td>';
if (!empty($val['picto'])) { print img_picto('', $val['picto']); }
if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key;
elseif (preg_match('/^(text|html)/', $val['type'])) {
$tmparray = explode(':', $val['type']);

View File

@ -140,7 +140,8 @@ if ($permission)
</div>
<div class="tagtd maxwidthonsmartphone noborderbottom">
<?php
$nbofcontacts = $form->select_contacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp');
print $form->selectcontacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp');
$nbofcontacts = $form->num;
$newcardbutton = '';
if (!empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer)
@ -281,7 +282,7 @@ print_liste_field_titre($arrayfields['thirdparty']['label'], $_SERVER["PHP_SELF"
print_liste_field_titre($arrayfields['contact']['label'], $_SERVER["PHP_SELF"], "contact_name", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "statut", "", $param, "", $sortfield, $sortorder, 'center ');
print_liste_field_titre($arrayfields['link']['label'], $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder, 'center maxwidthsearch ');
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>";
foreach ($list as $entry)

View File

@ -44,7 +44,7 @@ if ($fixedDiscount > 0)
print $langs->trans($translationKey, $fixedDiscount).'.';
} else {
$translationKey = (!empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount';
print $langs->trans($translationKey).'.';
print '<span class="opacitymedium">'.$langs->trans($translationKey).'.</span>';
}
if ($isNewObject) print ' ('.$addrelativediscount.')';
@ -95,7 +95,7 @@ if ($absolute_creditnote > 0) {
if ($absolute_discount <= 0 && $absolute_creditnote <= 0) {
$translationKey = !empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount';
print '<br>'.$langs->trans($translationKey).'.';
print '<br><span class="opacitymedium">'.$langs->trans($translationKey).'.</span>';
if ($isInvoice && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) {
print ' ('.$addabsolutediscount.')';

View File

@ -82,11 +82,9 @@ if ($pageid > 0)
if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) {
header("X-Content-Type-Options: nosniff");
/* TODO Manage allow_frames flag on websitepage.
if (empty($websitepage->allow_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) {
if (empty($websitepage->allowed_in_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) {
header("X-Frame-Options: SAMEORIGIN");
}
*/
}
// A lang was forced, so we change weblangs init

View File

@ -102,6 +102,8 @@ class Delivery extends CommonObject
*/
public $model_pdf;
public $lines = array();
/**
* Constructor
@ -111,8 +113,6 @@ class Delivery extends CommonObject
public function __construct($db)
{
$this->db = $db;
$this->lines = array();
$this->products = array();
// List of short language codes for status
$this->statuts[-1] = 'StatusDeliveryCanceled';

View File

@ -62,8 +62,19 @@ class EcmDirectory extends CommonObject
*/
public $description;
/**
* @var int cache nb of doc
*/
public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated'
/**
* @var int date_c
*/
public $date_c;
/**
* @var int date_m
*/
public $date_m;
/**
@ -81,25 +92,31 @@ class EcmDirectory extends CommonObject
*/
public $ref;
/**
* @var array array of categories
*/
public $cats = array();
/**
* @var array array of children categories
*/
public $motherof = array();
/**
* @var array array of forbidden chars
*/
public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"');
/**
* @var array array of forbidden chars for dir
*/
public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"');
/**
* @var int 1 if full arbo loaded
*/
public $full_arbo_loaded;
/**
* @var string Error code (or message)
*/
public $error;
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
/**
* Constructor
*
@ -131,13 +148,14 @@ class EcmDirectory extends CommonObject
$this->description = trim($this->description);
$this->date_c = $now;
$this->fk_user_c = $user->id;
if ($this->fk_parent <= 0) $this->fk_parent = 0;
if ($this->fk_parent <= 0) {
$this->fk_parent = 0;
}
// Check if same directory does not exists with this name
$relativepath = $this->label;
if ($this->fk_parent)
{
if ($this->fk_parent) {
$parent = new EcmDirectory($this->db);
$parent->fetch($this->fk_parent);
$relativepath = $parent->getRelativePath().$relativepath;
@ -148,19 +166,16 @@ class EcmDirectory extends CommonObject
$cat = new EcmDirectory($this->db);
$cate_arbo = $cat->get_full_arbo(1);
$pathfound = 0;
foreach ($cate_arbo as $key => $categ)
{
foreach ($cate_arbo as $key => $categ) {
$path = str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']);
//print $relativepath.' - '.$path.'<br>';
if ($path == $relativepath)
{
if ($path == $relativepath) {
$pathfound = 1;
break;
}
}
if ($pathfound)
{
if ($pathfound) {
$this->error = "ErrorDirAlreadyExists";
dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
return -1;
@ -188,21 +203,23 @@ class EcmDirectory extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories");
$dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
$result = dol_mkdir($dir);
if ($result < 0) { $error++; $this->error = "ErrorFailedToCreateDir"; }
if ($result < 0) {
$error++; $this->error = "ErrorFailedToCreateDir";
}
// Call trigger
$result = $this->call_trigger('MYECMDIR_CREATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
if (!$error)
{
if (!$error) {
$this->db->commit();
return $this->id;
} else {
@ -249,22 +266,21 @@ class EcmDirectory extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$error++;
$this->error = "Error ".$this->db->lasterror();
}
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('MYECMDIR_MODIFY', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -284,20 +300,26 @@ class EcmDirectory extends CommonObject
{
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
if (preg_match('/[0-9]+/', $value)) $sql .= " cachenbofdoc = ".(int) $value;
else $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1";
if (preg_match('/[0-9]+/', $value)) {
$sql .= " cachenbofdoc = ".(int) $value;
} else {
$sql .= " cachenbofdoc = cachenbofdoc ".$value." 1";
}
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
return -1;
} else {
if (preg_match('/[0-9]+/', $value)) $this->cachenbofdoc = (int) $value;
elseif ($value == '+') $this->cachenbofdoc++;
elseif ($value == '-') $this->cachenbofdoc--;
if (preg_match('/[0-9]+/', $value)) {
$this->cachenbofdoc = (int) $value;
} elseif ($value == '+') {
$this->cachenbofdoc++;
} elseif ($value == '-') {
$this->cachenbofdoc--;
}
}
return 1;
@ -327,11 +349,9 @@ class EcmDirectory extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
@ -374,7 +394,9 @@ class EcmDirectory extends CommonObject
$error = 0;
if ($mode != 'databaseonly') $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
if ($mode != 'databaseonly') {
$relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
}
dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath));
@ -385,35 +407,30 @@ class EcmDirectory extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->db->rollback();
$this->error = "Error ".$this->db->lasterror();
return -2;
} else {
// Call trigger
$result = $this->call_trigger('MYECMDIR_DELETE', $user);
if ($result < 0)
{
if ($result < 0) {
$this->db->rollback();
return -2;
}
// End call triggers
}
if ($mode != 'databaseonly')
{
if ($mode != 'databaseonly') {
$file = $conf->ecm->dir_output."/".$relativepath;
if ($deletedirrecursive)
{
if ($deletedirrecursive) {
$result = @dol_delete_dir_recursive($file, 0, 0);
} else {
$result = @dol_delete_dir($file, 0);
}
}
if ($result || !@is_dir(dol_osencode($file)))
{
if ($result || !@is_dir(dol_osencode($file))) {
$this->db->commit();
} else {
$this->error = 'ErrorFailToDeleteDir';
@ -422,8 +439,11 @@ class EcmDirectory extends CommonObject
$error++;
}
if (!$error) return 1;
else return -1;
if (!$error) {
return 1;
} else {
return -1;
}
}
@ -465,17 +485,27 @@ class EcmDirectory extends CommonObject
$linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
if ($option == 'index') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
if ($option == 'indexexpanded') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
if ($option == 'indexnotexpanded') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
if ($option == 'index') {
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
}
if ($option == 'indexexpanded') {
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
}
if ($option == 'indexnotexpanded') {
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
}
$linkend = '</a>';
//$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
$picto = 'dir';
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref);
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref);
}
$result .= $linkend;
return $result;
@ -497,18 +527,15 @@ class EcmDirectory extends CommonObject
do {
// Get index cursor in this->cats for id_mere
$cursorindex = -1;
foreach ($this->cats as $key => $val)
{
if ($this->cats[$key]['id'] == $idtosearch)
{
foreach ($this->cats as $key => $val) {
if ($this->cats[$key]['id'] == $idtosearch) {
$cursorindex = $key;
break;
}
}
//print "c=".$idtosearch."-".$cursorindex;
if ($cursorindex >= 0)
{
if ($cursorindex >= 0) {
// Path is label sanitized (no space and no special char) and concatenated
$ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret;
@ -541,11 +568,9 @@ class EcmDirectory extends CommonObject
dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
// This assignment in condition is not a bug. It allows walking the results.
while ($obj = $this->db->fetch_object($resql))
{
while ($obj = $this->db->fetch_object($resql)) {
$this->motherof[$obj->id_son] = $obj->id_parent;
}
return 1;
@ -608,8 +633,7 @@ class EcmDirectory extends CommonObject
// phpcs:enable
global $conf;
if (empty($force) && !empty($this->full_arbo_loaded))
{
if (empty($force) && !empty($this->full_arbo_loaded)) {
return $this->cats;
}
@ -632,13 +656,11 @@ class EcmDirectory extends CommonObject
dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->cats = array();
$i = 0;
// This assignment in condition is not a bug. It allows walking the results.
while ($obj = $this->db->fetch_object($resql))
{
while ($obj = $this->db->fetch_object($resql)) {
$this->cats[$obj->rowid]['id'] = $obj->rowid;
$this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : '');
$this->cats[$obj->rowid]['label'] = $obj->label;
@ -648,10 +670,8 @@ class EcmDirectory extends CommonObject
$this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c;
$this->cats[$obj->rowid]['login_c'] = $obj->login_c;
if (!empty($obj->rowid_fille))
{
if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children']))
{
if (!empty($obj->rowid_fille)) {
if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) {
$newelempos = count($this->cats[$obj->rowid]['id_children']);
//print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
$this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille;
@ -668,9 +688,10 @@ class EcmDirectory extends CommonObject
}
// We add properties fullxxx to all elements
foreach ($this->cats as $key => $val)
{
if (isset($motherof[$key])) continue;
foreach ($this->cats as $key => $val) {
if (isset($motherof[$key])) {
continue;
}
$this->build_path_from_id_categ($key, 0);
}
@ -693,8 +714,7 @@ class EcmDirectory extends CommonObject
{
// phpcs:enable
// Define fullpath
if (!empty($this->cats[$id_categ]['id_mere']))
{
if (!empty($this->cats[$id_categ]['id_mere'])) {
$this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
$this->cats[$id_categ]['fullpath'] .= '_'.$id_categ;
$this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
@ -711,11 +731,11 @@ class EcmDirectory extends CommonObject
// Traite ces enfants
$protection++;
if ($protection > 20) return; // On ne traite pas plus de 20 niveaux
if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children']))
{
foreach ($this->cats[$id_categ]['id_children'] as $key => $val)
{
if ($protection > 20) {
return; // On ne traite pas plus de 20 niveaux
}
if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
$this->build_path_from_id_categ($val, $protection);
}
}
@ -741,8 +761,7 @@ class EcmDirectory extends CommonObject
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
$sql .= " cachenbofdoc = '".count($filelist)."'";
if (empty($all)) // By default
{
if (empty($all)) { // By default
$sql .= " WHERE rowid = ".$this->id;
} else {
$sql .= " WHERE entity = ".$conf->entity;
@ -750,8 +769,7 @@ class EcmDirectory extends CommonObject
dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->cachenbofdoc = count($filelist);
return $this->cachenbofdoc;
} else {
@ -782,8 +800,7 @@ class EcmDirectory extends CommonObject
$interface = new Interfaces($this->db);
$result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
if ($result < 0) {
if (!empty($this->errors))
{
if (!empty($this->errors)) {
$this->errors = array_merge($this->errors, $interface->errors);
} else {
$this->errors = $interface->errors;

View File

@ -94,7 +94,15 @@ class EcmFiles extends CommonObject
* @var string keywords
*/
public $keywords;
/**
* @var string cover
*/
public $cover;
/**
* @var int position
*/
public $position;
/**
@ -131,7 +139,15 @@ class EcmFiles extends CommonObject
* @var string acl
*/
public $acl;
/**
* @var string src object type
*/
public $src_object_type;
/**
* @var int src object id
*/
public $src_object_id;
@ -233,8 +249,7 @@ class EcmFiles extends CommonObject
$sql .= " WHERE filepath ='".$this->db->escape($this->filepath)."'";
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
$maxposition = (int) $obj->maxposition;
} else {
@ -247,13 +262,11 @@ class EcmFiles extends CommonObject
}
// Check parameters
if (empty($this->filename) || empty($this->filepath))
{
if (empty($this->filename) || empty($this->filepath)) {
$this->errors[] = 'Bad property filename or filepath';
return --$error;
}
if (!isset($this->entity))
{
if (!isset($this->entity)) {
$this->entity = $conf->entity;
}
// Put here code to add control on parameters values
@ -317,11 +330,12 @@ class EcmFiles extends CommonObject
$this->position = $maxposition;
// Triggers
if (!$notrigger)
{
if (!$notrigger) {
// Call triggers
$result = $this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
}
@ -401,8 +415,7 @@ class EcmFiles extends CommonObject
} elseif (!empty($hashforshare)) {
$sql .= " AND t.share = '".$this->db->escape($hashforshare)."'";
//$sql .= " AND t.entity = ".$conf->entity; // hashforshare already unique
} elseif ($src_object_type && $src_object_id)
{
} elseif ($src_object_type && $src_object_id) {
// Warning: May return several record, and only first one is returned !
$sql .= " AND t.src_object_type ='".$this->db->escape($src_object_type)."' AND t.src_object_id = ".$this->db->escape($src_object_id);
$sql .= " AND t.entity = ".$conf->entity;
@ -668,11 +681,12 @@ class EcmFiles extends CommonObject
}
// Triggers
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call triggers
$result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
if ($result < 0) {
$error++;
} //Do also here what you must do to rollback action if trigger fail
// End call triggers
}
@ -705,11 +719,12 @@ class EcmFiles extends CommonObject
$this->db->begin();
// Triggers
if (!$notrigger)
{
if (!$notrigger) {
// Call triggers
$result = $this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
if ($result < 0) {
$error++;
} //Do also here what you must do to rollback action if trigger fail
// End call triggers
}
@ -804,7 +819,9 @@ class EcmFiles extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = '';
@ -815,25 +832,26 @@ class EcmFiles extends CommonObject
$url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id;
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowProject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
if ($withpicto)
{
if ($withpicto) {
$result .= ($linkstart.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result .= ' ';
if ($withpicto != 2) {
$result .= ' ';
}
}
$result .= $linkstart.$this->ref.$linkend;
return $result;
@ -877,16 +895,16 @@ class EcmFiles extends CommonObject
global $conf, $user;
$this->id = 0;
$this->specimen = 1;
$this->label = '0a1b2c3e4f59999999';
$this->entity = '1';
$this->entity = 1;
$this->filename = 'myspecimenfilefile.pdf';
$this->filepath = '/aaa/bbb';
$this->fullpath_orig = 'c:/file on my disk.pdf';
$this->description = 'This is a long description of file';
$this->keywords = 'key1,key2';
$this->cover = '1';
$this->position = '5';
$this->position = 5;
$this->gen_or_uploaded = 'uploaded';
$this->extraparams = '';
$this->date_c = (dol_now() - 3600 * 24 * 10);

View File

@ -41,20 +41,22 @@ $confirm = GETPOST('confirm', 'alpha');
$module = GETPOST('module', 'alpha');
$website = GETPOST('website', 'alpha');
$pageid = GETPOST('pageid', 'int');
if (empty($module)) $module = 'ecm';
if (empty($module)) {
$module = 'ecm';
}
// Security check
if ($user->socid > 0)
{
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
$section = $urlsection = GETPOST('section', 'alpha');
if (empty($urlsection)) $urlsection = 'misc';
if (empty($urlsection)) {
$urlsection = 'misc';
}
if ($module == 'ecm')
{
if ($module == 'ecm') {
$upload_dir = $conf->ecm->dir_output.'/'.$urlsection;
} else // For example $module == 'medias'
{
@ -65,19 +67,23 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "label";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "label";
}
$ecmdir = new EcmDirectory($db);
if (!empty($section))
{
if (!empty($section)) {
$result = $ecmdir->fetch($section);
if (!$result > 0)
{
if (!$result > 0) {
dol_print_error($db, $ecmdir->error);
exit;
}
@ -86,18 +92,18 @@ if (!empty($section))
// Permissions
$permtoadd = 0;
$permtoupload = 0;
if ($module == 'ecm')
{
if ($module == 'ecm') {
$permtoadd = $user->rights->ecm->setup;
$permtoupload = $user->rights->ecm->upload;
}
if ($module == 'medias')
{
if ($module == 'medias') {
$permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
$permtoupload = ($user->rights->mailing->creer || $user->rights->website->write);
}
if (!$permtoadd) accessforbidden();
if (!$permtoadd) {
accessforbidden();
}
@ -106,12 +112,9 @@ if (!$permtoadd) accessforbidden();
*/
// Action ajout d'un produit ou service
if ($action == 'add' && $permtoadd)
{
if ($cancel)
{
if (!empty($backtopage))
{
if ($action == 'add' && $permtoadd) {
if ($cancel) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
} else {
@ -120,33 +123,31 @@ if ($action == 'add' && $permtoadd)
}
}
$ref = GETPOST("ref", 'alpha');
$label = GETPOST("label", 'alpha');
$desc = GETPOST("desc", 'alpha');
$ref = (string) GETPOST("ref", 'alpha');
$label = (string) GETPOST("label", 'alpha');
$desc = (string) GETPOST("desc", 'alpha');
$catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager)
if ($catParent == '-1') $catParent = 0;
if ($catParent == '-1') {
$catParent = 0;
}
$error = 0;
if (empty($label))
{
if (empty($label)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'create';
$error++;
}
if (!$error)
{
if ($module == 'ecm')
{
if (!$error) {
if ($module == 'ecm') {
$ecmdir->ref = $ref;
$ecmdir->label = $label;
$ecmdir->description = $desc;
$ecmdir->fk_parent = (int) $catParent;
$id = $ecmdir->create($user);
if ($id <= 0)
{
if ($id <= 0) {
$error++;
$langs->load("errors");
setEventMessages($ecmdir->error, $ecmdir->errors, 'errors');
@ -155,22 +156,18 @@ if ($action == 'add' && $permtoadd)
} else // For example $module == 'medias'
{
$dirfornewdir = '';
if ($module == 'medias')
{
if ($module == 'medias') {
$dirfornewdir = $conf->medias->multidir_output[$conf->entity];
}
if (empty($dirfornewdir))
{
if (empty($dirfornewdir)) {
$error++;
dol_print_error('', 'Bad value for module. Not supported.');
}
if (!$error)
{
if (!$error) {
$fullpathofdir = $dirfornewdir.'/'.($catParent ? $catParent.'/' : '').$label;
$result = dol_mkdir($fullpathofdir, DOL_DATA_ROOT);
if ($result < 0)
{
if ($result < 0) {
setEventMessages($langs->trans('ErrorFailToCreateDir', $label), null, 'errors');
$error++;
} else {
@ -180,10 +177,8 @@ if ($action == 'add' && $permtoadd)
}
}
if (!$error)
{
if (!empty($backtopage))
{
if (!$error) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
} else {
@ -194,8 +189,7 @@ if ($action == 'add' && $permtoadd)
}
// Deleting file
elseif ($action == 'confirm_deletesection' && $confirm == 'yes')
{
elseif ($action == 'confirm_deletesection' && $confirm == 'yes') {
$result = $ecmdir->delete($user);
setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
}
@ -212,8 +206,7 @@ llxHeader('', $langs->trans("ECMNewSection"));
$form = new Form($db);
$formecm = new FormEcm($db);
if ($action == 'create')
{
if ($action == 'create') {
//***********************
// Create
//***********************
@ -222,8 +215,12 @@ if ($action == 'create')
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
if ($website) print '<input type="hidden" name="website" value="'.dol_escape_htmltag($website).'">';
if ($pageid) print '<input type="hidden" name="pageid" value="'.dol_escape_htmltag($pageid).'">';
if ($website) {
print '<input type="hidden" name="website" value="'.dol_escape_htmltag($website).'">';
}
if ($pageid) {
print '<input type="hidden" name="pageid" value="'.dol_escape_htmltag($pageid).'">';
}
$title = $langs->trans("ECMNewSection");
print load_fiche_titre($title);
@ -240,8 +237,7 @@ if ($action == 'create')
print '</td></tr>'."\n";
// Description
if ($module == 'ecm')
{
if ($module == 'ecm') {
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
print '<textarea name="desc" rows="4" class="quatrevingtpercent">';
print $ecmdir->description;
@ -262,8 +258,7 @@ if ($action == 'create')
}
if (empty($action) || $action == 'delete_section')
{
if (empty($action) || $action == 'delete_section') {
//***********************
// List
//***********************
@ -277,21 +272,17 @@ if (empty($action) || $action == 'delete_section')
print '<a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php">'.$langs->trans("ECMRoot").'</a>';
//print ' -> <b>'.$ecmdir->getNomUrl(1).'</b><br>';
print "<br><br>";
*/
*/
// Confirmation de la suppression d'une ligne categorie
if ($action == 'delete_section')
{
if ($action == 'delete_section') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection');
}
// Construit fiche rubrique
// Actions buttons
print '<div class="tabsAction">';
if ($user->rights->ecm->setup)
{
if ($user->rights->ecm->setup) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=delete_section&token='.newToken().'">'.$langs->trans('Delete').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';

View File

@ -418,10 +418,8 @@ if (empty($reshook))
$result = $object->valid($user);
if ($result < 0)
{
$langs->load("errors");
setEventMessages($langs->trans($object->error), $object->errors, 'errors');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))

View File

@ -106,7 +106,6 @@ class Expedition extends CommonObject
* @var int warehouse id
*/
public $entrepot_id;
public $lines = array();
/**
* @var string Tracking number
@ -171,6 +170,9 @@ class Expedition extends CommonObject
public $meths;
public $listmeths; // List of carriers
public $lines = array();
/**
* Draft status
*/
@ -202,8 +204,6 @@ class Expedition extends CommonObject
global $conf;
$this->db = $db;
$this->lines = array();
$this->products = array();
// List of long language codes for status
$this->statuts = array();

Some files were not shown because too many files have changed in this diff Show More