Merge branch 'develop' into 13a11

This commit is contained in:
Laurent Destailleur 2020-09-09 19:12:08 +02:00 committed by GitHub
commit 08ab4855f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
92 changed files with 18851 additions and 18280 deletions

View File

@ -15,6 +15,8 @@ Following changes may create regressions for some external modules, but were nec
* Rename property $paiementid in API api_supplier_invoices into $payment_mode_id * Rename property $paiementid in API api_supplier_invoices into $payment_mode_id
* The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you still use old syntax in * The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you still use old syntax in
your email templates. your email templates.
* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom
days of holiday.
***** ChangeLog for 12.0.2 compared to 12.0.1 ***** ***** ChangeLog for 12.0.2 compared to 12.0.1 *****
FIX: computation of the bottom margin of <body> returns NaN because body is not loaded yet FIX: computation of the bottom margin of <body> returns NaN because body is not loaded yet

View File

@ -1,38 +1,50 @@
FROM php:7.2-apache FROM php:7.3-apache
ENV HOST_USER_ID 33
ENV PHP_INI_DATE_TIMEZONE 'UTC' ENV PHP_INI_DATE_TIMEZONE 'UTC'
ENV PHP_INI_MEMORY_LIMIT 256M
RUN apt-get update && apt-get install -y libpng16-16 libpng-dev libjpeg62-turbo libjpeg62-turbo-dev libldap2-dev zlib1g-dev libicu-dev g++\ RUN apt-get update -y \
&& rm -rf /var/lib/apt/lists/* \ && apt-get install -y --no-install-recommends \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ libfreetype6-dev \
&& docker-php-ext-install gd \ libjpeg62-turbo-dev \
&& docker-php-ext-install zip \ libjpeg62-turbo \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ libpng-dev \
&& docker-php-ext-install ldap \ libpng16-16 \
&& docker-php-ext-install mysqli \ libldap2-dev \
&& docker-php-ext-install calendar \ libxml2-dev \
&& docker-php-ext-configure intl \ libzip-dev \
&& docker-php-ext-install intl \ zlib1g-dev \
&& apt-get autoremove --purge -y libpng-dev libjpeg62-turbo-dev libldap2-dev zlib1g-dev libicu-dev g++ libicu-dev \
g++ \
default-mysql-client \
unzip \
curl \
apt-utils \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install -j$(nproc) ldap && \
mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini
RUN mkdir /var/documents RUN mkdir /var/documents
RUN chown www-data /var/documents RUN chown www-data:www-data /var/documents
COPY docker-run.sh /usr/local/bin/ COPY docker-run.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-run.sh RUN chmod +x /usr/local/bin/docker-run.sh
RUN pecl install xdebug && docker-php-ext-enable xdebug RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"' >> /usr/local/etc/php/php.ini RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so"' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_autostart=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_autostart=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_enable=1' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_enable=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.default_enable=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.default_enable=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_host=docker.host' >> /usr/local/etc/php/php.ini #RUN echo 'xdebug.remote_host=docker.host' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_port=9000' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_connect_back=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.profiler_enable=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini
RUN echo '172.17.0.1 docker.host' >> /etc/hosts #RUN echo '172.17.0.1 docker.host' >> /etc/hosts
EXPOSE 80 EXPOSE 80

View File

@ -1,6 +1,8 @@
# How to use it ? # How to use it ?
The docker-compose.yml file is used to build and run Dolibarr in the current workspace. The docker-compose.yml file is used to build and run Dolibarr in the current workspace.
This docker image intended for developpement usage.
For production usage you should consider other contributor reference like https://hub.docker.com/r/tuxgasy/dolibarr
Before build/run, define the variable HOST_USER_ID as following: Before build/run, define the variable HOST_USER_ID as following:
@ -26,3 +28,4 @@ The URL to go to PhpMyAdmin is (login/password is root/root) :
Setup the database connection during the installation process, please use mariad Setup the database connection during the installation process, please use mariad
b (name of the database container) as database host. b (name of the database container) as database host.
Setup documents folder, during the installation process, to /var/documents

View File

@ -1,32 +1,51 @@
mariadb: version: '3'
build: mariadb
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: dolibarr
phpmyadmin: networks:
image: phpmyadmin/phpmyadmin internal-pod:
environment: internal: true
PMA_HOST: mariadb external-pod:
links: internal: false
- mariadb
ports:
- "8080:80"
web: services:
build: . mariadb:
environment: image: mariadb:latest
HOST_USER_ID: $HOST_USER_ID environment:
volumes: MYSQL_ROOT_PASSWORD: root
- ../../htdocs:/var/www/html MYSQL_DATABASE: dolibarr
links: networks:
- mariadb - internal-pod
- mail
ports:
- "80:80"
mail: phpmyadmin:
image: maildev/maildev image: phpmyadmin/phpmyadmin
ports: environment:
- "8081:80" PMA_HOST: mariadb
- "25:25" depends_on:
- mariadb
ports:
- "8080:80"
networks:
- internal-pod
- external-pod
web:
build: .
environment:
HOST_USER_ID: $HOST_USER_ID
volumes:
- ../../htdocs:/var/www/html/
- ../../documents:/var/documents
ports:
- "80:80"
- "9000:9000"
depends_on:
- mariadb
- mail
networks:
- internal-pod
- external-pod
mail:
image: maildev/maildev
ports:
- "8081:80"
- "25:25"

View File

@ -1,15 +1,21 @@
#!/bin/bash #!/bin/bash
usermod -u $HOST_USER_ID www-data usermod -u ${HOST_USER_ID} www-data
groupmod -g $HOST_USER_ID www-data groupmod -g ${HOST_USER_ID} www-data
chgrp -hR www-data /var/www/html chgrp -hR www-data /var/www/html
chmod g+rwx /var/www/html/conf chmod g+rwx /var/www/html/conf
if [ ! -d /var/documents ]; then
echo "[docker-run] => create volume directory /var/documents ..."
mkdir -p /var/documents
fi
echo "[docker-run] => Set Permission to www-data for /var/documents"
chown -R www-data:www-data /var/documents
if [ ! -f /usr/local/etc/php/php.ini ]; then if [ ! -f /usr/local/etc/php/php.ini ]; then
cat <<EOF > /usr/local/etc/php/php.ini cat <<EOF > /usr/local/etc/php/php.ini
date.timezone = $PHP_INI_DATE_TIMEZONE date.timezone = $PHP_INI_DATE_TIMEZONE
display_errors = On
EOF EOF
fi fi

View File

@ -297,12 +297,12 @@ print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>'; print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=0">'; print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
} else { } else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=1">'; print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>'; print '</a></td>';
} }
print '</tr>'; print '</tr>';
@ -310,12 +310,12 @@ print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>'; print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=0">'; print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
} else { } else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=1">'; print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>'; print '</a></td>';
} }
print '</tr>'; print '</tr>';
@ -387,7 +387,7 @@ foreach ($list_binding as $key)
} elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') {
$array=array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); $array=array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear"));
print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER)?$conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER:0)); print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER)?$conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER:0));
} else { } else {
print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">'; print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
} }

View File

@ -140,48 +140,48 @@ if (empty($reshook))
if ($massaction == 'ventil') { if ($massaction == 'ventil') {
$msg = ''; $msg = '';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (!empty($mesCasesCochees)) { if (!empty($mesCasesCochees)) {
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>'; $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
$msg .= '<div class="detail">'; $msg .= '<div class="detail">';
$cpt = 0; $cpt = 0;
$ok = 0; $ok = 0;
$ko = 0; $ko = 0;
foreach ($mesCasesCochees as $maLigneCochee) { foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee); $maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0) if ($monCompte <= 0)
{ {
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>'; $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
$ko++; $ko++;
} else { } else {
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
$sql .= " SET fk_code_ventilation = ".$monCompte; $sql .= " SET fk_code_ventilation = ".$monCompte;
$sql .= " WHERE rowid = ".$monId; $sql .= " WHERE rowid = ".$monId;
$accountventilated = new AccountingAccount($db); $accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, ''); $accountventilated->fetch($monCompte, '');
dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG); dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG);
if ($db->query($sql)) { if ($db->query($sql)) {
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>'; $msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
$ok++; $ok++;
} else { } else {
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br> <pre>'.$sql.'</pre></font></div>'; $msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br> <pre>'.$sql.'</pre></font></div>';
$ko++; $ko++;
} }
} }
$cpt++; $cpt++;
} }
$msg .= '</div>'; $msg .= '</div>';
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>'; $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
} }
} }
@ -199,8 +199,8 @@ if (empty($chartaccountcode))
{ {
print $langs->trans("ErrorChartOfAccountSystemNotSelected"); print $langs->trans("ErrorChartOfAccountSystemNotSelected");
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
exit; exit;
} }
@ -236,28 +236,28 @@ if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1); $sql .= natural_search("l.rowid", $search_lineid, 1);
} }
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= natural_search("f.ref", $search_invoice); $sql .= natural_search("f.ref", $search_invoice);
} }
if (strlen(trim($search_ref))) { if (strlen(trim($search_ref))) {
$sql .= natural_search("p.ref", $search_ref); $sql .= natural_search("p.ref", $search_ref);
} }
if (strlen(trim($search_label))) { if (strlen(trim($search_label))) {
$sql .= natural_search("p.label", $search_label); $sql .= natural_search("p.label", $search_label);
} }
if (strlen(trim($search_desc))) { if (strlen(trim($search_desc))) {
$sql .= natural_search("l.description", $search_desc); $sql .= natural_search("l.description", $search_desc);
} }
if (strlen(trim($search_amount))) { if (strlen(trim($search_amount))) {
$sql .= natural_search("l.total_ht", $search_amount, 1); $sql .= natural_search("l.total_ht", $search_amount, 1);
} }
if (strlen(trim($search_account))) { if (strlen(trim($search_account))) {
$sql .= natural_search("aa.account_number", $search_account); $sql .= natural_search("aa.account_number", $search_account);
} }
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1); $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
} }
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) { if (strlen(trim($search_country))) {
@ -295,13 +295,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -336,9 +336,9 @@ if ($result) {
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate") 'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
@ -376,8 +376,8 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre center nowraponall minwidth100imp">'; print '<td class="liste_titre center nowraponall minwidth100imp">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
} }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); $formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
@ -425,7 +425,7 @@ if ($result) {
$isSellerInEEC = isInEEC($mysoc); $isSellerInEEC = isInEEC($mysoc);
$accountingaccount_codetotid_cache = array(); $accountingaccount_codetotid_cache = array();
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
@ -464,29 +464,29 @@ if ($result) {
$code_sell_p_notset = ''; $code_sell_p_notset = '';
$objp->aarowid_suggest = ''; // Will be set later $objp->aarowid_suggest = ''; // Will be set later
$isBuyerInEEC = isInEEC($objp); $isBuyerInEEC = isInEEC($objp);
// Search suggested default account for product/service // Search suggested default account for product/service
$suggestedaccountingaccountbydefaultfor = ''; $suggestedaccountingaccountbydefaultfor = '';
if ($objp->type_l == 1) { if ($objp->type_l == 1) {
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = ''; $suggestedaccountingaccountbydefaultfor = '';
} else { } else {
if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eecwithvat'; $suggestedaccountingaccountbydefaultfor = 'eecwithvat';
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eec'; $suggestedaccountingaccountbydefaultfor = 'eec';
} else { // Foreign sale } else { // Foreign sale
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'export'; $suggestedaccountingaccountbydefaultfor = 'export';
} }
} }
} elseif ($objp->type_l == 0) { } elseif ($objp->type_l == 0) {
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
@ -512,28 +512,28 @@ if ($result) {
// Search suggested account for product/service (similar code exists in page index.php to make automatic binding) // Search suggested account for product/service (similar code exists in page index.php to make automatic binding)
$suggestedaccountingaccountfor = ''; $suggestedaccountingaccountfor = '';
if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_p = $objp->code_sell; $objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid; $objp->aarowid_suggest = $objp->aarowid;
$suggestedaccountingaccountfor = ''; $suggestedaccountingaccountfor = '';
} else { } else {
if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT
$objp->code_sell_p = $objp->code_sell; $objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid; $objp->aarowid_suggest = $objp->aarowid;
$suggestedaccountingaccountfor = 'eecwithvat'; $suggestedaccountingaccountfor = 'eecwithvat';
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
$objp->code_sell_p = $objp->code_sell; $objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
$suggestedaccountingaccountfor = 'eecwithoutvatnumber'; $suggestedaccountingaccountfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra; $objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra; $objp->aarowid_suggest = $objp->aarowid_intra;
$suggestedaccountingaccountfor = 'eec'; $suggestedaccountingaccountfor = 'eec';
} else { // Foreign sale } else { // Foreign sale
$objp->code_sell_p = $objp->code_sell_export; $objp->code_sell_p = $objp->code_sell_export;
$objp->aarowid_suggest = $objp->aarowid_export; $objp->aarowid_suggest = $objp->aarowid_export;
$suggestedaccountingaccountfor = 'export'; $suggestedaccountingaccountfor = 'export';
} }
} }
if (!empty($objp->code_sell_p)) { if (!empty($objp->code_sell_p)) {
// Value was defined previously // Value was defined previously
@ -585,32 +585,32 @@ if ($result) {
print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
// Country // Country
print '<td>'; print '<td>';
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
print $labelcountry; print $labelcountry;
print '</td>'; print '</td>';
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
// Found accounts // Found accounts
print '<td>'; print '<td>';
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>'; $s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
$shelp = ''; $shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
$s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>'); $s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
if ($objp->product_id > 0) if ($objp->product_id > 0)
{ {
print '<br>'; print '<br>';
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>'; $s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$shelp = ''; $shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT"); elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT");
elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber"); elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber");
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s .= (empty($objp->code_sell_p) ? '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_sell_p)); $s .= (empty($objp->code_sell_p) ? '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_sell_p));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
} }
print '</td>'; print '</td>';

View File

@ -264,7 +264,7 @@ if ($result) {
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>'; print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
@ -287,7 +287,7 @@ if ($result) {
print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
} }
print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
@ -341,7 +341,7 @@ if ($result) {
print '<td>'.$expensereportstatic->getNomUrl(1).'</td>'; print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
// Date validation // Date validation
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>';
} }

View File

@ -303,7 +303,7 @@ if ($result) {
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
print '<td class="liste_titre center nowraponall minwidth100imp">'; print '<td class="liste_titre center nowraponall minwidth100imp">';
@ -327,7 +327,7 @@ if ($result) {
print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
} }
print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
@ -381,7 +381,7 @@ if ($result) {
print '<td>'.$expensereport_static->getNomUrl(1).'</td>'; print '<td>'.$expensereport_static->getNomUrl(1).'</td>';
// Date validation // Date validation
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>';
} }

View File

@ -144,48 +144,48 @@ if (empty($reshook))
if ($massaction == 'ventil') { if ($massaction == 'ventil') {
$msg = ''; $msg = '';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (!empty($mesCasesCochees)) { if (!empty($mesCasesCochees)) {
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>'; $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
$msg .= '<div class="detail">'; $msg .= '<div class="detail">';
$cpt = 0; $cpt = 0;
$ok = 0; $ok = 0;
$ko = 0; $ko = 0;
foreach ($mesCasesCochees as $maLigneCochee) { foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee); $maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0) if ($monCompte <= 0)
{ {
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>'; $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
$ko++; $ko++;
} else { } else {
$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
$sql .= " SET fk_code_ventilation = ".$monCompte; $sql .= " SET fk_code_ventilation = ".$monCompte;
$sql .= " WHERE rowid = ".$monId; $sql .= " WHERE rowid = ".$monId;
$accountventilated = new AccountingAccount($db); $accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, ''); $accountventilated->fetch($monCompte, '');
dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG); dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG);
if ($db->query($sql)) { if ($db->query($sql)) {
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>'; $msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
$ok++; $ok++;
} else { } else {
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>'; $msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
$ko++; $ko++;
} }
} }
$cpt++; $cpt++;
} }
$msg .= '</div>'; $msg .= '</div>';
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>'; $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
} }
} }
@ -203,8 +203,8 @@ if (empty($chartaccountcode))
{ {
print $langs->trans("ErrorChartOfAccountSystemNotSelected"); print $langs->trans("ErrorChartOfAccountSystemNotSelected");
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
exit; exit;
} }
@ -240,28 +240,28 @@ if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1); $sql .= natural_search("l.rowid", $search_lineid, 1);
} }
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= natural_search("f.ref", $search_invoice); $sql .= natural_search("f.ref", $search_invoice);
} }
if (strlen(trim($search_label))) { if (strlen(trim($search_label))) {
$sql .= natural_search("f.libelle", $search_label); $sql .= natural_search("f.libelle", $search_label);
} }
if (strlen(trim($search_ref))) { if (strlen(trim($search_ref))) {
$sql .= natural_search("p.ref", $search_ref); $sql .= natural_search("p.ref", $search_ref);
} }
if (strlen(trim($search_desc))) { if (strlen(trim($search_desc))) {
$sql .= natural_search("l.description", $search_desc); $sql .= natural_search("l.description", $search_desc);
} }
if (strlen(trim($search_amount))) { if (strlen(trim($search_amount))) {
$sql .= natural_search("l.total_ht", $search_amount, 1); $sql .= natural_search("l.total_ht", $search_amount, 1);
} }
if (strlen(trim($search_account))) { if (strlen(trim($search_account))) {
$sql .= natural_search("aa.account_number", $search_account); $sql .= natural_search("aa.account_number", $search_account);
} }
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1); $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
} }
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) { if (strlen(trim($search_country))) {
@ -299,13 +299,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -337,9 +337,9 @@ if ($result) {
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate") 'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
@ -572,12 +572,12 @@ if ($result) {
print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
// Country // Country
print '<td>'; print '<td>';
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
print $labelcountry; print $labelcountry;
print '</td>'; print '</td>';
// VAT Num // VAT Num
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
// Found accounts // Found accounts

View File

@ -51,147 +51,147 @@ $type = 'bankaccount';
// Order display of bank account // Order display of bank account
if ($action == 'setbankorder') { if ($action == 'setbankorder') {
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
// Auto report last num releve on conciliate // Auto report last num releve on conciliate
if ($action == 'setreportlastnumreleve') { if ($action == 'setreportlastnumreleve') {
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} elseif ($action == 'unsetreportlastnumreleve') { } elseif ($action == 'unsetreportlastnumreleve') {
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
// Colorize movements // Colorize movements
if ($action == 'setbankcolorizemovement') { if ($action == 'setbankcolorizemovement') {
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} elseif ($action == 'unsetbankcolorizemovement') { } elseif ($action == 'unsetbankcolorizemovement') {
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
if ($actionsave) if ($actionsave)
{ {
$db->begin(); $db->begin();
$i = 1; $errorsaved = 0; $i = 1; $errorsaved = 0;
$error = 0; $error = 0;
// Save colors // Save colors
while ($i <= 2) while ($i <= 2)
{ {
$color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha'); $color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha');
if ($color == '-1') $color = ''; if ($color == '-1') $color = '';
$res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
$i++; $i++;
} }
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
$db->rollback(); $db->rollback();
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if ($action == 'specimen') { if ($action == 'specimen') {
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
if ($modele == 'sepamandate') { if ($modele == 'sepamandate') {
$object = new CompanyBankAccount($db); $object = new CompanyBankAccount($db);
} else { } else {
$object = new Account($db); $object = new Account($db);
} }
$object->initAsSpecimen(); $object->initAsSpecimen();
// Search template files // Search template files
$file = ''; $file = '';
$classname = ''; $classname = '';
$filefound = 0; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) { foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) { if (file_exists($file)) {
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) { if ($filefound) {
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($object, $langs) > 0) { if ($module->write_file($object, $langs) > 0) {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf");
return; return;
} else { } else {
setEventMessages($module->error, null, 'errors'); setEventMessages($module->error, null, 'errors');
dol_syslog($module->error, LOG_ERR); dol_syslog($module->error, LOG_ERR);
} }
} else { } else {
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
// Activate a model // Activate a model
if ($action == 'set') { if ($action == 'set') {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') { } elseif ($action == 'del') {
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) { if ($ret > 0) {
if ($conf->global->BANKADDON_PDF == "$value") if ($conf->global->BANKADDON_PDF == "$value")
dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity); dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity);
} }
} }
// Set default model // Set default model
elseif ($action == 'setdoc') { elseif ($action == 'setdoc') {
if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
// The constant that was read before the new set // The constant that was read before the new set
// We therefore requires a variable to have a coherent view // We therefore requires a variable to have a coherent view
$conf->global->BANKADDON_PDF = $value; $conf->global->BANKADDON_PDF = $value;
} }
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) { if ($ret > 0) {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} }

View File

@ -670,12 +670,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Clone // Clone
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>';
// Collect now // Collect now
if (count($object->actions) > 0) { if (count($object->actions) > 0) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=collect">'.$langs->trans("CollectNow").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=collect">'.$langs->trans("CollectNow").'</a></div>';
} else { } else {
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoOperations")).'">'.$langs->trans("CollectNow").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoOperations")).'">'.$langs->trans("CollectNow").'</a></div>';
} }
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>';
} }

View File

@ -35,13 +35,11 @@ $langs->loadLangs(array("admin", "trips", "errors", "other", "dict"));
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
//Init error $error = 0;
$error = false;
$message = false;
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$offset = GETPOST('offset', 'int'); $ikoffset = GETPOST('ikoffset', 'int');
$coef = GETPOST('coef', 'int'); $coef = GETPOST('coef', 'int');
$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat');
@ -59,10 +57,13 @@ if ($action == 'updateik')
$expIk->setValues($_POST); $expIk->setValues($_POST);
$result = $expIk->create($user); $result = $expIk->create($user);
if ($result > 0) setEventMessages('SetupSaved', null, 'mesgs'); if ($result > 0) {
setEventMessages('SetupSaved', null, 'mesgs');
header('Location: '.$_SERVER['PHP_SELF']); header('Location: '.$_SERVER['PHP_SELF']);
exit; exit;
} else {
setEventMessages($expIk->error, $expIk->errors, 'errors');
}
} elseif ($action == 'delete') // TODO add confirm } elseif ($action == 'delete') // TODO add confirm
{ {
$expIk = new ExpenseReportIk($db); $expIk = new ExpenseReportIk($db);
@ -81,6 +82,7 @@ if ($action == 'updateik')
$rangesbycateg = ExpenseReportIk::getAllRanges(); $rangesbycateg = ExpenseReportIk::getAllRanges();
/* /*
* View * View
*/ */
@ -90,12 +92,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup"));
$form = new Form($db); $form = new Form($db);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ExpenseReportsIkSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
$head = expensereport_admin_prepare_head(); $head = expensereport_admin_prepare_head();
dol_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), -1, 'trip'); dol_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), -1, 'trip');
echo $langs->trans('ExpenseReportIkDesc'); echo '<span class="opacitymedium">'.$langs->trans('ExpenseReportIkDesc').'</span>';
print '<br><br>';
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">'; echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
@ -136,21 +139,23 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab)
echo '<tr class="oddeven">'; echo '<tr class="oddeven">';
// Label // Label
echo '<td width="20%"><b>['.$langs->trans('RangeNum', $tranche++).']</b> - '.$label.'</td>'; echo '<td class="nowraponall"><b>['.$langs->trans('RangeNum', $tranche++).']</b> - '.$label.'</td>';
// Offset // Offset
echo '<td width="20%">'; echo '<td class="nowraponall">';
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" name="offset" value="'.$range->ik->offset.'" />'; if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" class="maxwidth100" name="ikoffset" value="'.$range->ik->ikoffset.'" />';
else echo $range->ik->offset; else {
echo $range->ik->ikoffset;
}
echo '</td>'; echo '</td>';
// Coef // Coef
echo '<td width="20%">'; echo '<td class="nowraponall">';
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" name="coef" value="'.$range->ik->coef.'" />'; if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo '<input type="text" class="maxwidth100" name="coef" value="'.$range->ik->coef.'" />';
else echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined')); else echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined'));
echo '</td>'; echo '</td>';
// Total for one // Total for one
echo '<td width="30%">'.$langs->trans('expenseReportPrintExample', price($range->ik->offset + 5 * $range->ik->coef)).'</td>'; echo '<td class="nowraponall">'.$langs->trans('expenseReportPrintExample', price($range->ik->ikoffset + 5 * $range->ik->coef)).'</td>';
// Action // Action
echo '<td class="right">'; echo '<td class="right">';
@ -161,8 +166,8 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab)
echo '<input id="" class="button" name="save" value="'.$langs->trans('Save').'" type="submit" />'; echo '<input id="" class="button" name="save" value="'.$langs->trans('Save').'" type="submit" />';
echo '<input class="button" value="'.$langs->trans('Cancel').'" onclick="javascript:history.go(-1)" type="button" />'; echo '<input class="button" value="'.$langs->trans('Cancel').'" onclick="javascript:history.go(-1)" type="button" />';
} else { } else {
echo '<a href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$range->ik->id.'&fk_c_exp_tax_cat='.$range->fk_c_exp_tax_cat.'&fk_range='.$range->rowid.'">'.img_edit().'</a>'; echo '<a class="editfielda marginrightonly paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$range->ik->id.'&fk_c_exp_tax_cat='.$range->fk_c_exp_tax_cat.'&fk_range='.$range->rowid.'">'.img_edit().'</a>';
if (!empty($range->ik->id)) echo '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$range->ik->id.'">'.img_delete().'</a>'; if (!empty($range->ik->id)) echo '<a class="paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$range->ik->id.'">'.img_delete().'</a>';
// TODO add delete link // TODO add delete link
} }
} }

View File

@ -138,6 +138,7 @@ $rules = ExpenseReportRule::getAllRule();
$tab_apply = array('A' => $langs->trans('All'), 'G' => $langs->trans('Group'), 'U' => $langs->trans('User')); $tab_apply = array('A' => $langs->trans('All'), 'G' => $langs->trans('Group'), 'U' => $langs->trans('User'));
$tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->trans('Month'), 'EX_YEA' => $langs->trans('Year'), 'EX_EXP' => $langs->trans('OnExpense')); $tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->trans('Month'), 'EX_YEA' => $langs->trans('Year'), 'EX_EXP' => $langs->trans('OnExpense'));
/* /*
* View * View
*/ */
@ -147,12 +148,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup"));
$form = new Form($db); $form = new Form($db);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ExpenseReportsRulesSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
$head = expensereport_admin_prepare_head(); $head = expensereport_admin_prepare_head();
dol_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip'); dol_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip');
echo $langs->trans('ExpenseReportRulesDesc'); echo '<span class="opacitymedium">'.$langs->trans('ExpenseReportRulesDesc').'</span>';
print '<br><br>';
if ($action != 'edit') if ($action != 'edit')
{ {
@ -164,7 +166,7 @@ if ($action != 'edit')
echo '<tr class="liste_titre">'; echo '<tr class="liste_titre">';
echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>'; echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDomain').'</th>'; echo '<th>'.$langs->trans('Type').'</th>';
echo '<th>'.$langs->trans('ExpenseReportLimitOn').'</th>'; echo '<th>'.$langs->trans('ExpenseReportLimitOn').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDateStart').'</th>'; echo '<th>'.$langs->trans('ExpenseReportDateStart').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDateEnd').'</th>'; echo '<th>'.$langs->trans('ExpenseReportDateEnd').'</th>';
@ -184,7 +186,7 @@ if ($action != 'edit')
echo '<td>'.$form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0).'</td>'; echo '<td>'.$form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0).'</td>';
echo '<td>'.$form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0).'</td>'; echo '<td>'.$form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0).'</td>';
echo '<td>'.$form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0).'</td>'; echo '<td>'.$form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0).'</td>';
echo '<td><input type="text" value="" name="amount" class="amount" />'.$conf->currency.'</td>'; echo '<td><input type="text" value="" class="maxwidth100" name="amount" class="amount" /> '.$conf->currency.'</td>';
echo '<td>'.$form->selectyesno('restrictive', 0, 1).'</td>'; echo '<td>'.$form->selectyesno('restrictive', 0, 1).'</td>';
echo '<td class="right"><input type="submit" class="button" value="'.$langs->trans('Add').'" /></td>'; echo '<td class="right"><input type="submit" class="button" value="'.$langs->trans('Add').'" /></td>';
echo '</tr>'; echo '</tr>';
@ -207,7 +209,7 @@ echo '<table class="noborder centpercent">';
echo '<tr class="liste_titre">'; echo '<tr class="liste_titre">';
echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>'; echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDomain').'</th>'; echo '<th>'.$langs->trans('Type').'</th>';
echo '<th>'.$langs->trans('ExpenseReportLimitOn').'</th>'; echo '<th>'.$langs->trans('ExpenseReportLimitOn').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDateStart').'</th>'; echo '<th>'.$langs->trans('ExpenseReportDateStart').'</th>';
echo '<th>'.$langs->trans('ExpenseReportDateEnd').'</th>'; echo '<th>'.$langs->trans('ExpenseReportDateEnd').'</th>';
@ -300,11 +302,11 @@ foreach ($rules as $rule)
echo '</td>'; echo '</td>';
echo '<td>'; echo '<td class="center">';
if ($object->id != $rule->id) if ($object->id != $rule->id)
{ {
echo '<a href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$rule->id.'">'.img_edit().'</a>&nbsp;'; echo '<a class="editfielda paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$rule->id.'">'.img_edit().'</a>&nbsp;';
echo '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$rule->id.'">'.img_delete().'</a>'; echo '<a class="paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$rule->id.'">'.img_delete().'</a>';
} else { } else {
echo '<input type="submit" class="button" value="'.$langs->trans('Update').'" />&nbsp;'; echo '<input type="submit" class="button" value="'.$langs->trans('Update').'" />&nbsp;';
echo '<a href="'.$_SERVER['PHP_SELF'].'" class="button">'.$langs->trans('Cancel').'</a>'; echo '<a href="'.$_SERVER['PHP_SELF'].'" class="button">'.$langs->trans('Cancel').'</a>';

View File

@ -40,8 +40,8 @@ $dirsmartphone = array();
$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
foreach ($dirmenus as $dirmenu) foreach ($dirmenus as $dirmenu)
{ {
$dirstandard[] = $dirmenu.'standard'; $dirstandard[] = $dirmenu.'standard';
$dirsmartphone[] = $dirmenu.'smartphone'; $dirsmartphone[] = $dirmenu.'smartphone';
} }
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -66,192 +66,192 @@ if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler");
if ($action == 'update') if ($action == 'update')
{ {
if (!$cancel) if (!$cancel)
{ {
$leftmenu = ''; $mainmenu = ''; $leftmenu = ''; $mainmenu = '';
if (GETPOST('menuIdParent', 'alpha') && !is_numeric(GETPOST('menuIdParent', 'alpha'))) if (GETPOST('menuIdParent', 'alpha') && !is_numeric(GETPOST('menuIdParent', 'alpha')))
{ {
$tmp = explode('&', GETPOST('menuIdParent', 'alpha')); $tmp = explode('&', GETPOST('menuIdParent', 'alpha'));
foreach ($tmp as $s) foreach ($tmp as $s)
{ {
if (preg_match('/fk_mainmenu=/', $s)) if (preg_match('/fk_mainmenu=/', $s))
{ {
$mainmenu = preg_replace('/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); $leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
} }
} }
} }
$menu = new Menubase($db); $menu = new Menubase($db);
$result = $menu->fetch(GETPOST('menuId', 'int')); $result = $menu->fetch(GETPOST('menuId', 'int'));
if ($result > 0) if ($result > 0)
{ {
$menu->title = GETPOST('titre', 'alpha'); $menu->title = GETPOST('titre', 'alpha');
$menu->leftmenu = GETPOST('leftmenu', 'aZ09'); $menu->leftmenu = GETPOST('leftmenu', 'aZ09');
$menu->url = GETPOST('url', 'alpha'); $menu->url = GETPOST('url', 'alpha');
$menu->langs = GETPOST('langs', 'alpha'); $menu->langs = GETPOST('langs', 'alpha');
$menu->position = GETPOST('position', 'int'); $menu->position = GETPOST('position', 'int');
$menu->enabled = GETPOST('enabled', 'alpha'); $menu->enabled = GETPOST('enabled', 'alpha');
$menu->perms = GETPOST('perms', 'alpha'); $menu->perms = GETPOST('perms', 'alpha');
$menu->target = GETPOST('target', 'alpha'); $menu->target = GETPOST('target', 'alpha');
$menu->user = GETPOST('user', 'alpha'); $menu->user = GETPOST('user', 'alpha');
$menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); $menu->mainmenu = GETPOST('propertymainmenu', 'alpha');
if (is_numeric(GETPOST('menuIdParent', 'alpha'))) if (is_numeric(GETPOST('menuIdParent', 'alpha')))
{ {
$menu->fk_menu = GETPOST('menuIdParent', 'alpha'); $menu->fk_menu = GETPOST('menuIdParent', 'alpha');
} else { } else {
if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0; if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0;
else $menu->fk_menu = -1; else $menu->fk_menu = -1;
$menu->fk_mainmenu = $mainmenu; $menu->fk_mainmenu = $mainmenu;
$menu->fk_leftmenu = $leftmenu; $menu->fk_leftmenu = $leftmenu;
} }
$result = $menu->update($user); $result = $menu->update($user);
if ($result > 0) if ($result > 0)
{ {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} else { } else {
setEventMessages($menu->error, $menu->errors, 'errors'); setEventMessages($menu->error, $menu->errors, 'errors');
} }
} else { } else {
setEventMessages($menu->error, $menu->errors, 'errors'); setEventMessages($menu->error, $menu->errors, 'errors');
} }
$action = "edit"; $action = "edit";
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
exit; exit;
} else { } else {
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
exit; exit;
} }
} }
if ($action == 'add') if ($action == 'add')
{ {
if ($cancel) if ($cancel)
{ {
header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
exit; exit;
} }
$leftmenu = ''; $mainmenu = ''; $leftmenu = ''; $mainmenu = '';
if (GETPOST('menuId', 'alpha', 3) && !is_numeric(GETPOST('menuId', 'alpha', 3))) if (GETPOST('menuId', 'alpha', 3) && !is_numeric(GETPOST('menuId', 'alpha', 3)))
{ {
$tmp = explode('&', GETPOST('menuId', 'alpha', 3)); $tmp = explode('&', GETPOST('menuId', 'alpha', 3));
foreach ($tmp as $s) foreach ($tmp as $s)
{ {
if (preg_match('/fk_mainmenu=/', $s)) if (preg_match('/fk_mainmenu=/', $s))
{ {
$mainmenu = preg_replace('/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); $leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
} }
} }
} }
$langs->load("errors"); $langs->load("errors");
$error = 0; $error = 0;
if (!$error && !$_POST['menu_handler']) if (!$error && !$_POST['menu_handler'])
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (!$error && !$_POST['type']) if (!$error && !$_POST['type'])
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (!$error && !$_POST['url']) if (!$error && !$_POST['url'])
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (!$error && !$_POST['titre']) if (!$error && !$_POST['titre'])
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (!$error && $_POST['menuId'] && $_POST['type'] == 'top') if (!$error && $_POST['menuId'] && $_POST['type'] == 'top')
{ {
setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors'); setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left') if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left')
{ {
setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors'); setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (!$error) if (!$error)
{ {
$menu = new Menubase($db); $menu = new Menubase($db);
$menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09'));
$menu->type = GETPOST('type', 'alpha'); $menu->type = GETPOST('type', 'alpha');
$menu->title = GETPOST('titre', 'alpha'); $menu->title = GETPOST('titre', 'alpha');
$menu->url = GETPOST('url', 'alpha'); $menu->url = GETPOST('url', 'alpha');
$menu->langs = GETPOST('langs', 'alpha'); $menu->langs = GETPOST('langs', 'alpha');
$menu->position = GETPOST('position', 'int'); $menu->position = GETPOST('position', 'int');
$menu->enabled = GETPOST('enabled', 'alpha'); $menu->enabled = GETPOST('enabled', 'alpha');
$menu->perms = GETPOST('perms', 'alpha'); $menu->perms = GETPOST('perms', 'alpha');
$menu->target = GETPOST('target', 'alpha'); $menu->target = GETPOST('target', 'alpha');
$menu->user = GETPOST('user', 'alpha'); $menu->user = GETPOST('user', 'alpha');
$menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); $menu->mainmenu = GETPOST('propertymainmenu', 'alpha');
if (is_numeric(GETPOST('menuId', 'alpha', 3))) if (is_numeric(GETPOST('menuId', 'alpha', 3)))
{ {
$menu->fk_menu = GETPOST('menuId', 'alpha', 3); $menu->fk_menu = GETPOST('menuId', 'alpha', 3);
} else { } else {
if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0; if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0;
else $menu->fk_menu = -1; else $menu->fk_menu = -1;
$menu->fk_mainmenu = $mainmenu; $menu->fk_mainmenu = $mainmenu;
$menu->fk_leftmenu = $leftmenu; $menu->fk_leftmenu = $leftmenu;
} }
$result = $menu->create($user); $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')); header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09'));
exit; exit;
} else { } else {
$action = 'create'; $action = 'create';
setEventMessages($menu->error, $menu->errors, 'errors'); setEventMessages($menu->error, $menu->errors, 'errors');
} }
} }
} }
// delete // delete
if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
{ {
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int'); $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int');
$result = $db->query($sql); $result = $db->query($sql);
if ($result == 0) if ($result == 0)
{ {
$this->db->commit(); $this->db->commit();
llxHeader(); llxHeader();
setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs'); setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs');
llxFooter(); llxFooter();
exit; exit;
} else { } else {
$this->db->rollback(); $this->db->rollback();
$reload = 0; $reload = 0;
$_GET["action"] = ''; $_GET["action"] = '';
} }
} }
@ -268,7 +268,7 @@ llxHeader('', $langs->trans("Menu"));
if ($action == 'create') if ($action == 'create')
{ {
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
function init_topleft() function init_topleft()
{ {
@ -292,231 +292,231 @@ if ($action == 'create')
}); });
</script>'; </script>';
print load_fiche_titre($langs->trans("NewMenu"), '', 'title_setup'); print load_fiche_titre($langs->trans("NewMenu"), '', 'title_setup');
print '<form action="./edit.php?action=add&menuId='.GETPOST('menuId', 'int').'" method="post" name="formmenucreate">'; print '<form action="./edit.php?action=add&menuId='.GETPOST('menuId', 'int').'" method="post" name="formmenucreate">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
dol_fiche_head(); dol_fiche_head();
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Id // Id
$parent_rowid = GETPOST('menuId', 'int'); $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'); $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); $res = $db->query($sql);
if ($res) if ($res)
{ {
while ($menu = $db->fetch_array($res)) while ($menu = $db->fetch_array($res))
{ {
$parent_rowid = $menu['rowid']; $parent_rowid = $menu['rowid'];
$parent_mainmenu = $menu['mainmenu']; $parent_mainmenu = $menu['mainmenu'];
$parent_leftmenu = $menu['leftmenu']; $parent_leftmenu = $menu['leftmenu'];
$parent_langs = $menu['langs']; $parent_langs = $menu['langs'];
$parent_level = $menu['level']; $parent_level = $menu['level'];
} }
} }
} }
// Handler // Handler
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>';
print '<td>'; print '<td>';
$formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone)); $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone));
print '</td>'; print '</td>';
print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>'; print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
// User // User
print '<tr><td class="nowrap fieldrequired">'.$langs->trans('MenuForUsers').'</td>'; print '<tr><td class="nowrap fieldrequired">'.$langs->trans('MenuForUsers').'</td>';
print '<td><select class="flat" name="user">'; print '<td><select class="flat" name="user">';
print '<option value="2" selected>'.$langs->trans("AllMenus").'</option>'; print '<option value="2" selected>'.$langs->trans("AllMenus").'</option>';
print '<option value="0">'.$langs->trans('Internal').'</option>'; print '<option value="0">'.$langs->trans('Internal').'</option>';
print '<option value="1">'.$langs->trans('External').'</option>'; print '<option value="1">'.$langs->trans('External').'</option>';
print '</select></td>'; print '</select></td>';
print '<td>'.$langs->trans('DetailUser').'</td></tr>'; print '<td>'.$langs->trans('DetailUser').'</td></tr>';
// Type // Type
print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>';
if ($parent_rowid) if ($parent_rowid)
{ {
print $langs->trans('Left'); print $langs->trans('Left');
print '<input type="hidden" name="type" value="left">'; print '<input type="hidden" name="type" value="left">';
} else { } else {
print '<select name="type" class="flat" id="topleft">'; print '<select name="type" class="flat" id="topleft">';
print '<option value="">&nbsp;</option>'; print '<option value="">&nbsp;</option>';
print '<option value="top"'.($_POST["type"] && $_POST["type"] == 'top' ? ' selected' : '').'>'.$langs->trans('Top').'</option>'; print '<option value="top"'.($_POST["type"] && $_POST["type"] == 'top' ? ' selected' : '').'>'.$langs->trans('Top').'</option>';
print '<option value="left"'.($_POST["type"] && $_POST["type"] == 'left' ? ' selected' : '').'>'.$langs->trans('Left').'</option>'; print '<option value="left"'.($_POST["type"] && $_POST["type"] == 'left' ? ' selected' : '').'>'.$langs->trans('Left').'</option>';
print '</select>'; print '</select>';
} }
print '</td><td>'.$langs->trans('DetailType').'</td></tr>'; print '</td><td>'.$langs->trans('DetailType').'</td></tr>';
// Mainmenu code // Mainmenu code
print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>';
print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha') ?GETPOST("propertymainmenu", 'alpha') : '').'"></td>'; print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha') ?GETPOST("propertymainmenu", 'alpha') : '').'"></td>';
print '<td>'; print '<td>';
print $langs->trans("Example").': mytopmenukey'; print $langs->trans("Example").': mytopmenukey';
print '</td></tr>'; print '</td></tr>';
// MenuId Parent // MenuId Parent
print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent').'</td>'; 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>'; print '<td>'.$parent_rowid.'<input type="hidden" name="menuId" value="'.$parent_rowid.'"></td>';
} else { } else {
print '<td><input type="text" class="minwidth300" id="menuId" name="menuId" value="'.(GETPOST("menuId", 'int') ?GETPOST("menuId", 'int') : '').'"></td>'; print '<td><input type="text" class="minwidth300" id="menuId" name="menuId" value="'.(GETPOST("menuId", 'int') ?GETPOST("menuId", 'int') : '').'"></td>';
} }
print '<td>'.$langs->trans('DetailMenuIdParent'); print '<td>'.$langs->trans('DetailMenuIdParent');
print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
print '</td></tr>'; print '</td></tr>';
// Title // Title
print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag(GETPOST("titre", 'alpha')).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag(GETPOST("titre", 'alpha')).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
// URL // URL
print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="minwidth500" name="url" value="'.GETPOST("url", 'alpha').'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="minwidth500" name="url" value="'.GETPOST("url", 'alpha').'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
// Langs // 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><td><input type="text" class="minwidth300" name="langs" value="'.$parent_langs.'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
// Position // Position
print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="width100" name="position" value="'.dol_escape_htmltag(isset($_POST["position"]) ? $_POST["position"] : 100).'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>'; print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="width100" name="position" value="'.dol_escape_htmltag(isset($_POST["position"]) ? $_POST["position"] : 100).'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
// Target // Target
print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">'; print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
print '<option value=""'.($menu->target == "" ? ' selected' : '').'>&nbsp;</option>'; print '<option value=""'.($menu->target == "" ? ' selected' : '').'>&nbsp;</option>';
print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>'; print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>';
print '</select></td></td><td>'.$langs->trans('DetailTarget').'</td></tr>'; print '</select></td></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
// Enabled // Enabled
print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.(GETPOSTISSET('enabled') ?GETPOST("enabled", 'alpha') : '1').'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>'; print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.(GETPOSTISSET('enabled') ?GETPOST("enabled", 'alpha') : '1').'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>';
// Perms // Perms
print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.(GETPOSTISSET('perms') ?GETPOST('perms', 'alpha') : '1').'"></td><td>'.$langs->trans('DetailRight').'</td></tr>'; print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.(GETPOSTISSET('perms') ?GETPOST('perms', 'alpha') : '1').'"></td><td>'.$langs->trans('DetailRight').'</td></tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} elseif ($action == 'edit') } elseif ($action == 'edit')
{ {
print load_fiche_titre($langs->trans("ModifMenu"), '', 'title_setup'); print load_fiche_titre($langs->trans("ModifMenu"), '', 'title_setup');
print '<br>'; print '<br>';
print '<form action="./edit.php?action=update" method="POST" name="formmenuedit">'; print '<form action="./edit.php?action=update" method="POST" name="formmenuedit">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="handler_origine" value="'.$menu_handler.'">'; print '<input type="hidden" name="handler_origine" value="'.$menu_handler.'">';
print '<input type="hidden" name="menuId" value="'.GETPOST('menuId', 'int').'">'; print '<input type="hidden" name="menuId" value="'.GETPOST('menuId', 'int').'">';
dol_fiche_head(); dol_fiche_head();
print '<table class="border centpercent">'; print '<table class="border centpercent">';
$menu = new Menubase($db); $menu = new Menubase($db);
$result = $menu->fetch(GETPOST('menuId', 'int')); $result = $menu->fetch(GETPOST('menuId', 'int'));
//var_dump($menu); //var_dump($menu);
// Id // Id
print '<tr><td>'.$langs->trans('Id').'</td><td>'.$menu->id.'</td><td>'.$langs->trans('DetailId').'</td></tr>'; print '<tr><td>'.$langs->trans('Id').'</td><td>'.$menu->id.'</td><td>'.$langs->trans('DetailId').'</td></tr>';
// Module // Module
print '<tr><td>'.$langs->trans('MenuModule').'</td><td>'.$menu->module.'</td><td>'.$langs->trans('DetailMenuModule').'</td></tr>'; print '<tr><td>'.$langs->trans('MenuModule').'</td><td>'.$menu->module.'</td><td>'.$langs->trans('DetailMenuModule').'</td></tr>';
// Handler // Handler
if ($menu->menu_handler == 'all') $handler = $langs->trans('AllMenus'); if ($menu->menu_handler == 'all') $handler = $langs->trans('AllMenus');
else $handler = $menu->menu_handler; else $handler = $menu->menu_handler;
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td><td>'.$handler.'</td><td>'.$langs->trans('DetailMenuHandler').'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td><td>'.$handler.'</td><td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
// User // User
print '<tr><td class="nowrap fieldrequired">'.$langs->trans('MenuForUsers').'</td><td><select class="flat" name="user">'; print '<tr><td class="nowrap fieldrequired">'.$langs->trans('MenuForUsers').'</td><td><select class="flat" name="user">';
print '<option value="2"'.($menu->user == 2 ? ' selected' : '').'>'.$langs->trans("AllMenus").'</option>'; print '<option value="2"'.($menu->user == 2 ? ' selected' : '').'>'.$langs->trans("AllMenus").'</option>';
print '<option value="0"'.($menu->user == 0 ? ' selected' : '').'>'.$langs->trans('Internal').'</option>'; print '<option value="0"'.($menu->user == 0 ? ' selected' : '').'>'.$langs->trans('Internal').'</option>';
print '<option value="1"'.($menu->user == 1 ? ' selected' : '').'>'.$langs->trans('External').'</option>'; print '<option value="1"'.($menu->user == 1 ? ' selected' : '').'>'.$langs->trans('External').'</option>';
print '</select></td><td>'.$langs->trans('DetailUser').'</td></tr>'; print '</select></td><td>'.$langs->trans('DetailUser').'</td></tr>';
// Type // 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><td>'.$langs->trans(ucfirst($menu->type)).'</td><td>'.$langs->trans('DetailType').'</td></tr>';
// Mainmenu code // Mainmenu code
if ($menu->type == 'top') if ($menu->type == 'top')
{ {
print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>';
/*if ($parent_rowid) /*if ($parent_rowid)
{ {
print '<td>'.$parent_rowid.'<input type="hidden" name="propertyleftmenu" value="'.$parent_rowid.'"></td>'; print '<td>'.$parent_rowid.'<input type="hidden" name="propertyleftmenu" value="'.$parent_rowid.'"></td>';
} }
else else
{*/ {*/
print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha') ?GETPOST("propertymainmenu", 'alpha') : $menu->mainmenu).'"></td>'; print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha') ?GETPOST("propertymainmenu", 'alpha') : $menu->mainmenu).'"></td>';
//} //}
print '<td>'; print '<td>';
print $langs->trans("Example").': mytopmenukey'; print $langs->trans("Example").': mytopmenukey';
print '</td></tr>'; print '</td></tr>';
} }
// MenuId Parent // MenuId Parent
print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent'); print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent');
print '</td>'; print '</td>';
$valtouse = $menu->fk_menu; $valtouse = $menu->fk_menu;
if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu; if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu;
if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu; if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu;
print '<td><input type="text" name="menuIdParent" value="'.$valtouse.'" class="minwidth300"></td>'; print '<td><input type="text" name="menuIdParent" value="'.$valtouse.'" class="minwidth300"></td>';
print '<td>'.$langs->trans('DetailMenuIdParent'); print '<td>'.$langs->trans('DetailMenuIdParent');
print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
print '</td></tr>'; print '</td></tr>';
// Niveau // Niveau
//print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>'; //print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>';
// Title // 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><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag($menu->title).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
// Url // 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><td><input type="text" class="quatrevingtpercent" name="url" value="'.$menu->url.'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
// Langs // 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><td><input type="text" class="minwidth300" name="langs" value="'.dol_escape_htmltag($menu->langs).'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
// Position // 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><td><input type="text" class="minwidth100" name="position" value="'.$menu->position.'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
// Target // Target
print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">'; print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
print '<option value=""'.($menu->target == "" ? ' selected' : '').'>&nbsp;</option>'; print '<option value=""'.($menu->target == "" ? ' selected' : '').'>&nbsp;</option>';
print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>'; print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>';
print '</select></td><td>'.$langs->trans('DetailTarget').'</td></tr>'; print '</select></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
// Enabled // 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'); 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)).')'; if (!empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')';
print '</td></tr>'; print '</td></tr>';
// Perms // 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'); 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)).')'; if (!empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
// Bouton // Bouton
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
print '<br>'; print '<br>';
} }
// End of page // End of page

View File

@ -25,68 +25,93 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("install", "other", "admin")); $langs->loadLangs(array("install", "other", "admin"));
if (!$user->admin) $optioncss = GETPOST('optioncss', 'alpha');
accessforbidden(); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview';
$search_name = GETPOST("search_name", 'alpha');
$search_id = GETPOST("search_id", 'alpha');
$search_version = GETPOST("search_version", 'alpha');
$search_permission = GETPOST("search_permission", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
if (!$sortfield) $sortfield = "id";
if (!$sortorder) $sortorder = "asc";
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager->initHooks(array('moduleoverview'));
$form = new Form($db);
$object = new stdClass();
// Definition of fields for lists
$arrayfields = array(
'name'=>array('label'=>$langs->trans("Modules"), 'checked'=>1, 'position'=>10),
'version'=>array('label'=>$langs->trans("Version"), 'checked'=>1, 'position'=>20),
'id'=>array('label'=>$langs->trans("IdModule"), 'checked'=>1, 'position'=>30),
'permission'=>array('label'=>$langs->trans("IdPermissions"), 'checked'=>1, 'position'=>40)
);
$arrayfields = dol_sort_array($arrayfields, 'position');
/* /*
* View * Actions
*/ */
llxHeader(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
print load_fiche_titre($langs->trans("AvailableModules"), '', 'title_setup'); if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
}
print '<span class="opacitymedium">'.$langs->trans("ToActivateModule").'</span><br>';
print "<br>\n";
// Load list of modules
$moduleList = array();
$modules = array(); $modules = array();
$modules_names = array();
$modules_files = array(); $modules_files = array();
$modules_fullpath = array(); $modules_fullpath = array();
$modulesdir = dolGetModulesDirs(); $modulesdir = dolGetModulesDirs();
$rights_ids = array();
// Load list of modules foreach ($modulesdir as $dir) {
$i = 0;
foreach ($modulesdir as $dir)
{
$handle = @opendir(dol_osencode($dir)); $handle = @opendir(dol_osencode($dir));
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
{
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
{
$modName = substr($file, 0, dol_strlen($file) - 10); $modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName) if ($modName) {
{
//print 'xx'.$dir.$file.'<br>'; //print 'xx'.$dir.$file.'<br>';
if (in_array($file, $modules_files)) if (in_array($file, $modules_files)) {
{
// File duplicate // File duplicate
print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")<br>"; print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")<br>";
} else { }
else {
// File to load // File to load
$res = include_once $dir.$file; $res = include_once $dir.$file;
if (class_exists($modName)) if (class_exists($modName)) {
{
try { try {
$objMod = new $modName($db); $objMod = new $modName($db);
$modules[$objMod->numero] = $objMod; $modules[$objMod->numero] = $objMod;
$modules_names[$objMod->numero] = $objMod->name;
$modules_files[$objMod->numero] = $file; $modules_files[$objMod->numero] = $file;
$modules_fullpath[$file] = $dir.$file; $modules_fullpath[$file] = $dir.$file;
$picto[$objMod->numero] = (isset($objMod->picto) && $objMod->picto) ? $objMod->picto : 'generic'; }
} catch (Exception $e) catch (Exception $e) {
{
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
} }
} else { }
else {
print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>"; print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
} }
} }
@ -97,60 +122,280 @@ foreach ($modulesdir as $dir)
} }
} }
print '<div class="div-table-responsive-no-min">'; // create pre-filtered list for modules
print '<table class="noborder centpercent">'; foreach ($modules as $key=>$module) {
print '<tr class="liste_titre">'; $newModule = new stdClass();
print '<td>'.$langs->trans("Modules").'</td>';
print '<td>'.$langs->trans("Version").'</td>'; $newModule->name = $module->getName();
print '<td class="center">'.$langs->trans("IdModule").'</td>'; $newModule->version = $module->getVersion();
print '<td>'.$langs->trans("IdPermissions").'</td>'; $newModule->id = $key;
print '</tr>';
$var = false; $alt = $module->name.' - '.$modules_files[$key];
$sortorder = $modules_names;
ksort($sortorder); if (!empty($module->picto)) {
$rights_ids = array(); if (preg_match('/^\//', $module->picto)) $newModule->picto = img_picto($alt, $module->picto, 'width="14px"', 1);
foreach ($sortorder as $numero=>$name) else $newModule->picto = img_object($alt, $module->picto, 'width="14px"');
{
$idperms = "";
// Module
print '<tr class="oddeven"><td width="300" class="nowrap">';
$alt = $name.' - '.$modules_files[$numero];
if (!empty($picto[$numero]))
{
if (preg_match('/^\//', $picto[$numero])) print img_picto($alt, $picto[$numero], 'width="14px"', 1);
else print img_object($alt, $picto[$numero], 'width="14px"');
} else {
print img_object($alt, $picto[$numero], 'width="14px"');
} }
print ' '.$modules[$numero]->getName(); else {
print "</td>"; $newModule->picto = img_object($alt, 'generic', 'width="14px"');
// Version }
print '<td>'.$modules[$numero]->getVersion().'</td>';
// Id $permission = array();
print '<td class="center">'.$numero.'</td>'; if ($module->rights) {
// Permissions foreach ($module->rights as $rights) {
if ($modules[$numero]->rights) if (empty($rights[0])) {
{ continue;
foreach ($modules[$numero]->rights as $rights) }
{
$idperms .= ($idperms ? ", " : "").$rights[0]; $permission[] = $rights[0];
array_push($rights_ids, $rights[0]); array_push($rights_ids, $rights[0]);
} }
} }
print '<td>'.($idperms ? $idperms : "&nbsp;").'</td>';
print "</tr>\n"; $newModule->permission = $permission;
// pre-filter list
if ($search_name && !stristr($newModule->name, $search_name)) continue;
if ($search_version && !stristr($newModule->version, $search_version)) continue;
if ($search_id && !stristr($newModule->id, $search_id)) continue;
if ($search_permission) {
$found = false;
foreach ($newModule->permission as $permission) {
if (stristr($permission, $search_permission)) {
$found = true;
break;
}
}
if (!$found) continue;
}
$moduleList[] = $newModule;
} }
/*
* View
*/
llxHeader();
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($langs->trans("AvailableModules"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $massactionbutton, -1, '', 'title_setup', 0, '', '', 0, 1, 1);
print '<span class="opacitymedium">'.$langs->trans("ToActivateModule").'</span>';
print '<br>';
print '<br>';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
// Lines with input filters
print '<tr class="liste_titre_filter">';
if ($arrayfields['name']['checked']) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_name" size="8" value="'.$search_name.'">';
print '</td>';
}
if ($arrayfields['version']['checked']) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_version" size="8" value="'.$search_version.'">';
print '</td>';
}
if ($arrayfields['id']['checked']) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_id" size="8" value="'.$search_id.'">';
print '</td>';
}
if ($arrayfields['permission']['checked']) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_permission" size="8" value="'.$search_permission.'">';
print '</td>';
}
print '<td class="liste_titre center maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
if ($arrayfields['name']['checked']) {
print_liste_field_titre($arrayfields['name']['label'], $_SERVER["PHP_SELF"], "name", "", "", "", $sortfield, $sortorder);
}
if ($arrayfields['version']['checked']) {
print_liste_field_titre($arrayfields['version']['label'], $_SERVER["PHP_SELF"], "version", "", "", "", $sortfield, $sortorder);
}
if ($arrayfields['id']['checked']) {
print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder);
}
if ($arrayfields['permission']['checked']) {
print_liste_field_titre($arrayfields['permission']['label'], $_SERVER["PHP_SELF"], "permission", "", "", "", $sortfield, $sortorder);
}
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print '</tr>';
// sort list
if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) {
return strcasecmp($a->name, $b->name); });
if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) {
return strcasecmp($b->name, $a->name); });
if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) {
return strcasecmp($a->version, $b->version); });
if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) {
return strcasecmp($b->version, $a->version); });
if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "compareIdAsc");
if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "compareIdDesc");
if ($sortfield == "permission" && $sortorder == "asc") usort($moduleList, "comparePermissionIdsAsc");
if ($sortfield == "permission" && $sortorder == "desc") usort($moduleList, "comparePermissionIdsDesc");
foreach ($moduleList as $module) {
print '<tr class="oddeven">';
if ($arrayfields['name']['checked']) {
print '<td width="300" class="nowrap">';
print $module->picto;
print ' '.$module->name;
print "</td>";
}
if ($arrayfields['version']['checked']) {
print '<td>'.$module->version.'</td>';
}
if ($arrayfields['id']['checked']) {
print '<td class="center">'.$module->id.'</td>';
}
if ($arrayfields['permission']['checked']) {
$idperms = '';
foreach ($module->permission as $permission) {
$idperms .= ($idperms ? ", " : "").$permission;
$translationKey = "Permission".$permission;
if (! empty($conf->global->MAIN_SHOW_PERMISSION)) {
if (empty($langs->tab_translate[$translationKey])) {
$tooltip = 'Missing translation (key '.$translationkey.' not found in admin.lang)';
$idperms .= ' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="'.$tooltip.'">';
}
}
}
print '<td>'.($idperms ? $idperms : "&nbsp;").'</td>';
}
print '<td></td>';
print '</tr>';
}
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '</form>';
print '<br>'; print '<br>';
sort($rights_ids); sort($rights_ids);
$old = ''; $old = '';
foreach ($rights_ids as $right_id)
{ foreach ($rights_ids as $right_id) {
if ($old == $right_id) print "Warning duplicate id on permission : ".$right_id."<br>"; if ($old == $right_id) {
print "Warning duplicate id on permission : ".$right_id."<br>";
}
$old = $right_id; $old = $right_id;
} }
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
/**
* Compare two modules by their ID for a ascending order
*
* @param stdClass $a First module
* @param stdClass $b Second module
* @return int Compare result (-1, 0, 1)
*/
function compareIdAsc(stdClass $a, stdClass $b)
{
if ($a->id == $b->id) return 0;
return $a->id > $b->id ? -1 : 1;
}
/**
* Compare two modules by their ID for a descending order
*
* @param stdClass $a First module
* @param stdClass $b Second module
* @return int Compare result (-1, 0, 1)
*/
function compareIdDesc(stdClass $a, stdClass $b)
{
if ($a->id == $b->id) return 0;
return $b->id > $a->id ? -1 : 1;
}
/**
* Compare two modules by their ID for a ascending order
*
* @param stdClass $a First module
* @param stdClass $b Second module
* @return int Compare result (-1, 0, 1)
*/
function comparePermissionIdsAsc(stdClass $a, stdClass $b)
{
if (empty($a->permission) && empty($b->permission)) return compareIdAsc($a, $b);
if (empty($a->permission)) return 1;
if (empty($b->permission)) return -1;
if ($a->permission[0] == $b->permission[0]) return 0;
return $a->permission[0] > $b->permission[0] ? -1 : 1;
}
/**
* Compare two modules by their permissions for a descending order
*
* @param stdClass $a First module
* @param stdClass $b Second module
* @return int Compare result (-1, 0, 1)
*/
function comparePermissionIdsDesc(stdClass $a, stdClass $b)
{
if (empty($a->permission) && empty($b->permission)) return compareIdDesc($a, $b);
if (empty($a->permission)) return -1;
if (empty($b->permission)) return 1;
if ($a->permission[0] == $b->permission[0]) return 0;
return $a->permission[0] > $b->permission[0] ? 1 : -1;
}

View File

@ -498,7 +498,7 @@ class ActionComm extends CommonObject
$sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", ";
$sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", ";
$sql .= " '".$this->db->escape($this->note_private)."', "; $sql .= " '".$this->db->escape($this->note_private)."', ";
$sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned
$sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", ";
$sql .= ($userownerid > 0 ? $userownerid : "null").", "; $sql .= ($userownerid > 0 ? $userownerid : "null").", ";
$sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; $sql .= ($userdoneid > 0 ? $userdoneid : "null").", ";
@ -632,173 +632,173 @@ class ActionComm extends CommonObject
//$this->fetch_userassigned(); //$this->fetch_userassigned();
$this->fetchResources(); $this->fetchResources();
$this->id = 0; $this->id = 0;
// Create clone // Create clone
$this->context['createfromclone'] = 'createfromclone'; $this->context['createfromclone'] = 'createfromclone';
$result = $this->create($fuser); $result = $this->create($fuser);
if ($result < 0) $error++; if ($result < 0) $error++;
if (!$error) if (!$error)
{ {
// Hook of thirdparty module // Hook of thirdparty module
if (is_object($hookmanager)) if (is_object($hookmanager))
{ {
$parameters = array('objFrom'=>$objFrom); $parameters = array('objFrom'=>$objFrom);
$action = ''; $action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++; if ($reshook < 0) $error++;
} }
// Call trigger // Call trigger
$result = $this->call_trigger('ACTION_CLONE', $fuser); $result = $this->call_trigger('ACTION_CLONE', $fuser);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// End call triggers // End call triggers
} }
unset($this->context['createfromclone']); unset($this->context['createfromclone']);
// End // End
if (!$error) if (!$error)
{ {
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
} else { } else {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
/** /**
* Load object from database * Load object from database
* *
* @param int $id Id of action to get * @param int $id Id of action to get
* @param string $ref Ref of action to get * @param string $ref Ref of action to get
* @param string $ref_ext Ref ext to get * @param string $ref_ext Ref ext to get
* @param string $email_msgid Email msgid * @param string $email_msgid Email msgid
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '') public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '')
{ {
global $langs; global $langs;
$sql = "SELECT a.id,"; $sql = "SELECT a.id,";
$sql .= " a.id as ref,"; $sql .= " a.id as ref,";
$sql .= " a.entity,"; $sql .= " a.entity,";
$sql .= " a.ref_ext,"; $sql .= " a.ref_ext,";
$sql .= " a.datep,"; $sql .= " a.datep,";
$sql .= " a.datep2,"; $sql .= " a.datep2,";
$sql .= " a.durationp,"; // deprecated $sql .= " a.durationp,"; // deprecated
$sql .= " a.datec,"; $sql .= " a.datec,";
$sql .= " a.tms as datem,"; $sql .= " a.tms as datem,";
$sql .= " a.code, a.label, a.note,"; $sql .= " a.code, a.label, a.note,";
$sql .= " a.fk_soc,"; $sql .= " a.fk_soc,";
$sql .= " a.fk_project,"; $sql .= " a.fk_project,";
$sql .= " a.fk_user_author, a.fk_user_mod,"; $sql .= " a.fk_user_author, a.fk_user_mod,";
$sql .= " a.fk_user_action, a.fk_user_done,"; $sql .= " a.fk_user_action, a.fk_user_done,";
$sql .= " a.fk_contact, a.percent as percentage,"; $sql .= " a.fk_contact, a.percent as percentage,";
$sql .= " a.fk_element as elementid, a.elementtype,"; $sql .= " a.fk_element as elementid, a.elementtype,";
$sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,";
$sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,"; $sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,";
$sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,";
$sql .= " s.nom as socname,"; $sql .= " s.nom as socname,";
$sql .= " u.firstname, u.lastname as lastname"; $sql .= " u.firstname, u.lastname as lastname";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id "; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc";
$sql .= " WHERE "; $sql .= " WHERE ";
if ($ref) $sql .= " a.id = ".((int) $ref); // No field ref, we use id if ($ref) $sql .= " a.id = ".((int) $ref); // No field ref, we use id
elseif ($ref_ext) $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'"; elseif ($ref_ext) $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'";
elseif ($email_msgid) $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'"; elseif ($email_msgid) $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'";
else $sql .= " a.id = ".((int) $id); else $sql .= " a.id = ".((int) $id);
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->id; $this->id = $obj->id;
$this->entity = $obj->entity; $this->entity = $obj->entity;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->ref_ext = $obj->ref_ext; $this->ref_ext = $obj->ref_ext;
// Properties of parent table llx_c_actioncomm // Properties of parent table llx_c_actioncomm
$this->type_id = $obj->type_id; $this->type_id = $obj->type_id;
$this->type_code = $obj->type_code; $this->type_code = $obj->type_code;
$this->type_color = $obj->type_color; $this->type_color = $obj->type_color;
$this->type_picto = $obj->type_picto; $this->type_picto = $obj->type_picto;
$transcode = $langs->trans("Action".$obj->type_code); $transcode = $langs->trans("Action".$obj->type_code);
$this->type = (($transcode != "Action".$obj->type_code) ? $transcode : $obj->type_label); $this->type = (($transcode != "Action".$obj->type_code) ? $transcode : $obj->type_label);
$transcode = $langs->trans("Action".$obj->type_code.'Short'); $transcode = $langs->trans("Action".$obj->type_code.'Short');
$this->type_short = (($transcode != "Action".$obj->type_code.'Short') ? $transcode : ''); $this->type_short = (($transcode != "Action".$obj->type_code.'Short') ? $transcode : '');
$this->code = $obj->code; $this->code = $obj->code;
$this->label = $obj->label; $this->label = $obj->label;
$this->datep = $this->db->jdate($obj->datep); $this->datep = $this->db->jdate($obj->datep);
$this->datef = $this->db->jdate($obj->datep2); $this->datef = $this->db->jdate($obj->datep2);
$this->datec = $this->db->jdate($obj->datec); $this->datec = $this->db->jdate($obj->datec);
$this->datem = $this->db->jdate($obj->datem); $this->datem = $this->db->jdate($obj->datem);
$this->note = $obj->note; // deprecated $this->note = $obj->note; // deprecated
$this->note_private = $obj->note; $this->note_private = $obj->note;
$this->percentage = $obj->percentage; $this->percentage = $obj->percentage;
$this->authorid = $obj->fk_user_author; $this->authorid = $obj->fk_user_author;
$this->usermodid = $obj->fk_user_mod; $this->usermodid = $obj->fk_user_mod;
if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning
$this->author->id = $obj->fk_user_author; // deprecated $this->author->id = $obj->fk_user_author; // deprecated
$this->author->firstname = $obj->firstname; // deprecated $this->author->firstname = $obj->firstname; // deprecated
$this->author->lastname = $obj->lastname; // deprecated $this->author->lastname = $obj->lastname; // deprecated
if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning
$this->usermod->id = $obj->fk_user_mod; // deprecated $this->usermod->id = $obj->fk_user_mod; // deprecated
$this->userownerid = $obj->fk_user_action; $this->userownerid = $obj->fk_user_action;
$this->userdoneid = $obj->fk_user_done; $this->userdoneid = $obj->fk_user_done;
$this->priority = $obj->priority; $this->priority = $obj->priority;
$this->fulldayevent = $obj->fulldayevent; $this->fulldayevent = $obj->fulldayevent;
$this->location = $obj->location; $this->location = $obj->location;
$this->transparency = $obj->transparency; $this->transparency = $obj->transparency;
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
$this->contact_id = $obj->fk_contact; // To have fetch_contact method working $this->contact_id = $obj->fk_contact; // To have fetch_contact method working
$this->fk_project = $obj->fk_project; // To have fetch_projet method working $this->fk_project = $obj->fk_project; // To have fetch_projet method working
//$this->societe->id = $obj->fk_soc; // deprecated //$this->societe->id = $obj->fk_soc; // deprecated
//$this->contact->id = $obj->fk_contact; // deprecated //$this->contact->id = $obj->fk_contact; // deprecated
$this->fk_element = $obj->elementid; $this->fk_element = $obj->elementid;
$this->elementid = $obj->elementid; $this->elementid = $obj->elementid;
$this->elementtype = $obj->elementtype; $this->elementtype = $obj->elementtype;
$this->fetchResources(); $this->fetchResources();
} }
$this->db->free($resql); $this->db->free($resql);
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
return $num; return $num;
} }
/** /**
* Initialize $this->userassigned & this->socpeopleassigned array with list of id of user and contact assigned to event * Initialize $this->userassigned & this->socpeopleassigned array with list of id of user and contact assigned to event
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchResources() public function fetchResources()
{ {
$this->userassigned = array(); $this->userassigned = array();
$this->socpeopleassigned = array(); $this->socpeopleassigned = array();
$sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; $sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency';
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm_resources';
$sql .= ' WHERE fk_actioncomm = '.$this->id; $sql .= ' WHERE fk_actioncomm = '.$this->id;
$sql .= " AND element_type IN ('user', 'socpeople')"; $sql .= " AND element_type IN ('user', 'socpeople')";
@ -1937,168 +1937,168 @@ class ActionComm extends CommonObject
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
} }
/** /**
* Is the action delayed? * Is the action delayed?
* *
* @return bool * @return bool
*/ */
public function hasDelay() public function hasDelay()
{ {
global $conf; global $conf;
$now = dol_now(); $now = dol_now();
return $this->datep && ($this->datep < ($now - $conf->agenda->warning_delay)); return $this->datep && ($this->datep < ($now - $conf->agenda->warning_delay));
} }
/** /**
* Send reminders by emails * Send reminders by emails
* CAN BE A CRON TASK * CAN BE A CRON TASK
* *
* @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
*/ */
public function sendEmailsReminder() public function sendEmailsReminder()
{ {
global $conf, $langs, $user; global $conf, $langs, $user;
$error = 0; $error = 0;
$this->output = ''; $this->output = '';
$this->error = ''; $this->error = '';
$nbMailSend = 0; $nbMailSend = 0;
$errorsMsg = array(); $errorsMsg = array();
if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible. if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible.
{ {
$langs->load("agenda"); $langs->load("agenda");
$this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Agenda")); $this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Agenda"));
return 0; return 0;
} }
if (empty($conf->global->AGENDA_REMINDER_EMAIL)) if (empty($conf->global->AGENDA_REMINDER_EMAIL))
{ {
$langs->load("agenda"); $langs->load("agenda");
$this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda")); $this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda"));
return 0; return 0;
} }
$now = dol_now(); $now = dol_now();
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$this->db->begin(); $this->db->begin();
//Select all action comm reminder //Select all action comm reminder
$sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder";
$sql .= " WHERE typeremind = 'email' AND status = 0"; $sql .= " WHERE typeremind = 'email' AND status = 0";
$sql .= " AND dateremind <= '".$this->db->idate(dol_now())."'"; $sql .= " AND dateremind <= '".$this->db->idate(dol_now())."'";
$sql .= $this->db->order("dateremind", "ASC"); $sql .= $this->db->order("dateremind", "ASC");
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$formmail = new FormMail($this->db); $formmail = new FormMail($this->db);
$actionCommReminder = new ActionCommReminder($this->db); $actionCommReminder = new ActionCommReminder($this->db);
while ($obj = $this->db->fetch_object($resql)){ while ($obj = $this->db->fetch_object($resql)){
$res = $actionCommReminder->fetch($obj->id); $res = $actionCommReminder->fetch($obj->id);
if ($res < 0) { if ($res < 0) {
$error++; $error++;
$errorsMsg[] = "Failed to load invoice ActionComm Reminder"; $errorsMsg[] = "Failed to load invoice ActionComm Reminder";
} }
if (!$error) if (!$error)
{ {
//Select email template //Select email template
$arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1); $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1);
// Load event // Load event
$res = $this->fetch($actionCommReminder->fk_actioncomm); $res = $this->fetch($actionCommReminder->fk_actioncomm);
if ($res > 0) if ($res > 0)
{ {
// PREPARE EMAIL // PREPARE EMAIL
// Make substitution in email content // Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this);
complete_substitutions_array($substitutionarray, $langs, $this); complete_substitutions_array($substitutionarray, $langs, $this);
// Content // Content
$sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
//Topic //Topic
$sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder')); $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder'));
// Recipient // Recipient
$recipient = new User($this->db); $recipient = new User($this->db);
$res = $recipient->fetch($actionCommReminder->fk_user); $res = $recipient->fetch($actionCommReminder->fk_user);
if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; if ($res > 0 && !empty($recipient->email)) $to = $recipient->email;
else { else {
$errorsMsg[] = "Failed to load recipient"; $errorsMsg[] = "Failed to load recipient";
$error++; $error++;
} }
// Sender // Sender
$from = $conf->global->MAIN_MAIL_EMAIL_FROM; $from = $conf->global->MAIN_MAIL_EMAIL_FROM;
if (empty($from)) { if (empty($from)) {
$errorsMsg[] = "Failed to load recipient"; $errorsMsg[] = "Failed to load recipient";
$error++; $error++;
} }
// Errors Recipient // Errors Recipient
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
// Mail Creation // Mail Creation
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', '');
// Sending Mail // Sending Mail
if ($cMailFile->sendfile()) if ($cMailFile->sendfile())
{ {
$actionCommReminder->status = $actionCommReminder::STATUS_DONE; $actionCommReminder->status = $actionCommReminder::STATUS_DONE;
$res = $actionCommReminder->update($user); $res = $actionCommReminder->update($user);
if ($res < 0) if ($res < 0)
{ {
$errorsMsg[] = "Failed to update status of ActionComm Reminder"; $errorsMsg[] = "Failed to update status of ActionComm Reminder";
$error++; $error++;
break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first.
} else { } else {
$nbMailSend++; $nbMailSend++;
} }
} else { } else {
$errorsMsg[] = $cMailFile->error.' : '.$to; $errorsMsg[] = $cMailFile->error.' : '.$to;
$error++; $error++;
} }
} else { } else {
$error++; $error++;
} }
} }
} }
} else { } else {
$error++; $error++;
} }
if (!$error) if (!$error)
{ {
// Delete also very old past events (we do not keep more than 1 month record in past) // Delete also very old past events (we do not keep more than 1 month record in past)
$sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder";
$sql .= " WHERE dateremind < '".$this->db->idate($now - (3600 * 24 * 32))."'"; $sql .= " WHERE dateremind < '".$this->db->idate($now - (3600 * 24 * 32))."'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$errorsMsg[] = 'Failed to delete old reminders'; $errorsMsg[] = 'Failed to delete old reminders';
//$error++; // If this fails, we must not rollback other SQL requests already done. Never mind. //$error++; // If this fails, we must not rollback other SQL requests already done. Never mind.
} }
} }
if (!$error) { if (!$error) {
$this->output = 'Nb of emails sent : '.$nbMailSend; $this->output = 'Nb of emails sent : '.$nbMailSend;
$this->db->commit(); $this->db->commit();
return 0; return 0;
} }
else { else {
$this->db->rollback(); $this->db->rollback();
$this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error;
return $error; return $error;
} }
} }
/** /**
* Udpate the percent value of a event with the given id * Udpate the percent value of a event with the given id

File diff suppressed because it is too large Load Diff

View File

@ -1291,21 +1291,21 @@ if ($resql)
foreach ($toselect as $checked) { foreach ($toselect as $checked) {
if ($tmpproposal->fetch($checked)) { if ($tmpproposal->fetch($checked)) {
if ($tmpproposal->statut == 0) { if ($tmpproposal->statut == 0) {
if ($tmpproposal->valid($user)){ if ($tmpproposal->valid($user)) {
setEventMessage($tmpproposal->ref . " " . $langs->trans('PassedInOpenStatus'), 'mesgs'); setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs');
} else { } else {
setEventMessage($langs->trans('CantBeValidated'), 'errors'); setEventMessage($langs->trans('CantBeValidated'), 'errors');
$error++; $error++;
} }
} else { } else {
setEventMessage($tmpproposal->ref . " " . $langs->trans('IsNotADraft'), 'errors'); setEventMessage($tmpproposal->ref." ".$langs->trans('IsNotADraft'), 'errors');
$error++; $error++;
} }
} }
dol_print_error($db); dol_print_error($db);
$error++; $error++;
} }
if ($error){ if ($error) {
$db->rollback(); $db->rollback();
} else { } else {
$db->commit(); $db->commit();
@ -1323,13 +1323,13 @@ if ($resql)
if ($tmpproposal->statut == 1) { if ($tmpproposal->statut == 1) {
$tmpproposal->statut = 2; $tmpproposal->statut = 2;
if ($tmpproposal->update($user)) { if ($tmpproposal->update($user)) {
setEventMessage($tmpproposal->ref . " " . $langs->trans('Signed'), 'mesgs'); setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs');
} else { } else {
dol_print_error($db); dol_print_error($db);
$error++; $error++;
} }
} else { } else {
setEventMessage($tmpproposal->ref . " " . $langs->trans('CantBeSign'), 'errors'); setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors');
$error++; $error++;
} }
} else { } else {
@ -1337,7 +1337,7 @@ if ($resql)
$error++; $error++;
} }
} }
if ($error){ if ($error) {
$db->rollback(); $db->rollback();
} else { } else {
$db->commit(); $db->commit();

File diff suppressed because it is too large Load Diff

View File

@ -99,13 +99,13 @@ class Commande extends CommonOrder
*/ */
public $ref_client; public $ref_client;
/** /**
* @var string Internal ref for order * @var string Internal ref for order
* @deprecated * @deprecated
*/ */
public $ref_int; public $ref_int;
/** /**
* @var int Contact ID * @var int Contact ID
*/ */
public $contactid; public $contactid;
@ -121,15 +121,15 @@ class Commande extends CommonOrder
*/ */
public $billed; public $billed;
/** /**
* @var int Draft Status of the order * @var int Draft Status of the order
*/ */
public $brouillon; public $brouillon;
public $cond_reglement_code; public $cond_reglement_code;
/** /**
* @var int bank account ID * @var int bank account ID
*/ */
public $fk_account; public $fk_account;
/** /**
@ -168,12 +168,12 @@ class Commande extends CommonOrder
public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...) public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...)
public $demand_reason_code; public $demand_reason_code;
/** /**
* @var int Date of order * @var int Date of order
*/ */
public $date; public $date;
/** /**
* @var int Date of order * @var int Date of order
* @deprecated * @deprecated
* @see $date * @see $date
*/ */
@ -182,8 +182,8 @@ class Commande extends CommonOrder
public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after)
/** /**
* @var int ID * @var int ID
*/ */
public $fk_remise_except; public $fk_remise_except;
public $remise_percent; public $remise_percent;
@ -197,13 +197,13 @@ class Commande extends CommonOrder
public $linked_objects = array(); public $linked_objects = array();
/** /**
* @var int User author ID * @var int User author ID
*/ */
public $user_author_id; public $user_author_id;
/** /**
* @var int User validator ID * @var int User validator ID
*/ */
public $user_valid; public $user_valid;
/** /**
@ -213,8 +213,8 @@ class Commande extends CommonOrder
// Multicurrency // Multicurrency
/** /**
* @var int Currency ID * @var int Currency ID
*/ */
public $fk_multicurrency; public $fk_multicurrency;
public $multicurrency_code; public $multicurrency_code;
@ -223,9 +223,9 @@ class Commande extends CommonOrder
public $multicurrency_total_tva; public $multicurrency_total_tva;
public $multicurrency_total_ttc; public $multicurrency_total_ttc;
/** /**
* @var Commande clone of order object * @var Commande clone of order object
*/ */
public $oldcopy; public $oldcopy;
//! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...)
@ -394,11 +394,11 @@ class Commande extends CommonOrder
$mybool |= @include_once $dir.$file; $mybool |= @include_once $dir.$file;
} }
if ($mybool === false) if ($mybool === false)
{ {
dol_print_error('', "Failed to include file ".$file); dol_print_error('', "Failed to include file ".$file);
return ''; return '';
} }
$obj = new $classname(); $obj = new $classname();
$numref = $obj->getNextValue($soc, $this); $numref = $obj->getNextValue($soc, $this);
@ -568,7 +568,7 @@ class Commande extends CommonOrder
{ {
$this->ref = $num; $this->ref = $num;
$this->statut = self::STATUS_VALIDATED; $this->statut = self::STATUS_VALIDATED;
$this->brouillon = 0; $this->brouillon = 0;
} }
if (!$error) if (!$error)
@ -589,9 +589,9 @@ class Commande extends CommonOrder
* @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on)
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function setDraft($user, $idwarehouse = -1) public function setDraft($user, $idwarehouse = -1)
{ {
//phpcs:enable //phpcs:enable
global $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
@ -619,12 +619,12 @@ class Commande extends CommonOrder
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
if (!$error) if (!$error)
{ {
$this->oldcopy = clone $this; $this->oldcopy = clone $this;
} }
// If stock is decremented on validate order, we must reincrement it // If stock is decremented on validate order, we must reincrement it
if (!empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) if (!empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
{ {
$result = 0; $result = 0;
@ -665,7 +665,7 @@ class Commande extends CommonOrder
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -678,7 +678,7 @@ class Commande extends CommonOrder
*/ */
public function set_reopen($user) public function set_reopen($user)
{ {
// phpcs:enable // phpcs:enable
$error = 0; $error = 0;
if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED) if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED)
@ -958,7 +958,7 @@ class Commande extends CommonOrder
$sql .= ", ".(int) $this->fk_incoterms; $sql .= ", ".(int) $this->fk_incoterms;
$sql .= ", '".$this->db->escape($this->location_incoterms)."'"; $sql .= ", '".$this->db->escape($this->location_incoterms)."'";
$sql .= ", ".setEntity($this); $sql .= ", ".setEntity($this);
$sql .= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); $sql .= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null");
$sql .= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); $sql .= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null");
$sql .= ", ".(int) $this->fk_multicurrency; $sql .= ", ".(int) $this->fk_multicurrency;
$sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
@ -1009,7 +1009,7 @@ class Commande extends CommonOrder
$line->ref_ext = ''; $line->ref_ext = '';
} }
$result = $this->addline( $result = $this->addline(
$line->desc, $line->desc,
$line->subprice, $line->subprice,
$line->qty, $line->qty,
@ -1033,10 +1033,10 @@ class Commande extends CommonOrder
$line->label, $line->label,
$line->array_options, $line->array_options,
$line->fk_unit, $line->fk_unit,
$origintype, $origintype,
$originid, $originid,
0, 0,
$line->ref_ext $line->ref_ext
); );
if ($result < 0) if ($result < 0)
{ {
@ -1357,8 +1357,8 @@ class Commande extends CommonOrder
if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN))
{ {
$this->note_private = $object->note_private; $this->note_private = $object->note_private;
$this->note_public = $object->note_public; $this->note_public = $object->note_public;
} }
$this->origin = $object->element; $this->origin = $object->element;
@ -1502,7 +1502,7 @@ class Commande extends CommonOrder
return -1; return -1;
} }
$this->db->begin(); $this->db->begin();
$product_type = $type; $product_type = $type;
if (!empty($fk_product)) if (!empty($fk_product))
@ -1681,7 +1681,7 @@ class Commande extends CommonOrder
*/ */
public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '')
{ {
// phpcs:enable // phpcs:enable
global $conf, $mysoc; global $conf, $mysoc;
if (!$qty) $qty = 1; if (!$qty) $qty = 1;
@ -1780,7 +1780,7 @@ class Commande extends CommonOrder
$sql .= ', c.fk_incoterms, c.location_incoterms'; $sql .= ', c.fk_incoterms, c.location_incoterms';
$sql .= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc"; $sql .= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc";
$sql .= ", c.module_source, c.pos_source"; $sql .= ", c.module_source, c.pos_source";
$sql .= ", i.libelle as label_incoterms"; $sql .= ", i.libelle as label_incoterms";
$sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql .= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; $sql .= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
$sql .= ', ca.code as availability_code, ca.label as availability_label'; $sql .= ', ca.code as availability_code, ca.label as availability_label';
@ -1917,7 +1917,7 @@ class Commande extends CommonOrder
*/ */
public function insert_discount($idremise) public function insert_discount($idremise)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -1992,7 +1992,7 @@ class Commande extends CommonOrder
public function fetch_lines($only_product = 0, $loadalsotranslation = 0) public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
{ {
global $langs, $conf; global $langs, $conf;
// phpcs:enable // phpcs:enable
$this->lines = array(); $this->lines = array();
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,'; $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,';
@ -2086,13 +2086,13 @@ class Commande extends CommonOrder
$line->fetch_optionals(); $line->fetch_optionals();
// multilangs // multilangs
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) {
$line = new Product($this->db); $line = new Product($this->db);
$line->fetch($objp->fk_product); $line->fetch($objp->fk_product);
$line->getMultiLangs(); $line->getMultiLangs();
} }
$this->lines[$i] = $line; $this->lines[$i] = $line;
$i++; $i++;
} }
@ -2224,7 +2224,7 @@ class Commande extends CommonOrder
*/ */
public function nb_expedition() public function nb_expedition()
{ {
// phpcs:enable // phpcs:enable
$sql = 'SELECT count(*)'; $sql = 'SELECT count(*)';
$sql .= ' FROM '.MAIN_DB_PREFIX.'expedition as e'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expedition as e';
$sql .= ', '.MAIN_DB_PREFIX.'element_element as el'; $sql .= ', '.MAIN_DB_PREFIX.'element_element as el';
@ -2251,7 +2251,7 @@ class Commande extends CommonOrder
*/ */
public function stock_array($filtre_statut = self::STATUS_CANCELED) public function stock_array($filtre_statut = self::STATUS_CANCELED)
{ {
// phpcs:enable // phpcs:enable
$this->stocks = array(); $this->stocks = array();
// Tableau des id de produit de la commande // Tableau des id de produit de la commande
@ -2359,7 +2359,7 @@ class Commande extends CommonOrder
*/ */
public function set_remise($user, $remise, $notrigger = 0) public function set_remise($user, $remise, $notrigger = 0)
{ {
// phpcs:enable // phpcs:enable
$remise = trim($remise) ?trim($remise) : 0; $remise = trim($remise) ?trim($remise) : 0;
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
@ -2425,7 +2425,7 @@ class Commande extends CommonOrder
*/ */
public function set_remise_absolue($user, $remise, $notrigger = 0) public function set_remise_absolue($user, $remise, $notrigger = 0)
{ {
// phpcs:enable // phpcs:enable
$remise = trim($remise) ?trim($remise) : 0; $remise = trim($remise) ?trim($remise) : 0;
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
@ -2491,7 +2491,7 @@ class Commande extends CommonOrder
*/ */
public function set_date($user, $date, $notrigger = 0) public function set_date($user, $date, $notrigger = 0)
{ {
// phpcs:enable // phpcs:enable
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$error = 0; $error = 0;
@ -2553,7 +2553,7 @@ class Commande extends CommonOrder
*/ */
public function set_date_livraison($user, $date_livraison, $notrigger = 0) public function set_date_livraison($user, $date_livraison, $notrigger = 0)
{ {
// phpcs:enable // phpcs:enable
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$error = 0; $error = 0;
@ -2620,7 +2620,7 @@ class Commande extends CommonOrder
*/ */
public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC')
{ {
// phpcs:enable // phpcs:enable
global $user; global $user;
$ga = array(); $ga = array();
@ -2750,7 +2750,7 @@ class Commande extends CommonOrder
*/ */
public function demand_reason($demand_reason_id, $notrigger = 0) public function demand_reason($demand_reason_id, $notrigger = 0)
{ {
// phpcs:enable // phpcs:enable
global $user; global $user;
dol_syslog('Commande::demand_reason('.$demand_reason_id.')'); dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
@ -2819,7 +2819,7 @@ class Commande extends CommonOrder
*/ */
public function set_ref_client($user, $ref_client, $notrigger = 0) public function set_ref_client($user, $ref_client, $notrigger = 0)
{ {
// phpcs:enable // phpcs:enable
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$error = 0; $error = 0;
@ -3321,9 +3321,9 @@ class Commande extends CommonOrder
if (!$error) if (!$error)
{ {
// Delete extrafields of order details // Delete extrafields of order details
$main = MAIN_DB_PREFIX.'commandedet'; $main = MAIN_DB_PREFIX.'commandedet';
$ef = $main."_extrafields"; $ef = $main."_extrafields";
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")"; $sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")";
if (!$this->db->query($sql)) if (!$this->db->query($sql))
{ {
$error++; $error++;
@ -3432,7 +3432,7 @@ class Commande extends CommonOrder
*/ */
public function load_board($user) public function load_board($user)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
$clause = " WHERE"; $clause = " WHERE";
@ -3521,45 +3521,45 @@ class Commande extends CommonOrder
*/ */
public function LibStatut($status, $billed, $mode, $donotshowbilled = 0) public function LibStatut($status, $billed, $mode, $donotshowbilled = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs, $conf; global $langs, $conf;
$billedtext = ''; $billedtext = '';
if (empty($donotshowbilled)) $billedtext .= ($billed ? ' - '.$langs->trans("Billed") : ''); if (empty($donotshowbilled)) $billedtext .= ($billed ? ' - '.$langs->trans("Billed") : '');
if ($status == self::STATUS_CANCELED) { if ($status == self::STATUS_CANCELED) {
$labelStatus = $langs->trans('StatusOrderCanceled'); $labelStatus = $langs->trans('StatusOrderCanceled');
$labelStatusShort = $langs->trans('StatusOrderCanceledShort'); $labelStatusShort = $langs->trans('StatusOrderCanceledShort');
$statusType = 'status9'; $statusType = 'status9';
} elseif ($status == self::STATUS_DRAFT) { } elseif ($status == self::STATUS_DRAFT) {
$labelStatus = $langs->trans('StatusOrderDraft'); $labelStatus = $langs->trans('StatusOrderDraft');
$labelStatusShort = $langs->trans('StatusOrderDraftShort'); $labelStatusShort = $langs->trans('StatusOrderDraftShort');
$statusType = 'status0'; $statusType = 'status0';
} elseif ($status == self::STATUS_VALIDATED) { } elseif ($status == self::STATUS_VALIDATED) {
$labelStatus = $langs->trans('StatusOrderValidated').$billedtext; $labelStatus = $langs->trans('StatusOrderValidated').$billedtext;
$labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext; $labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext;
$statusType = 'status1'; $statusType = 'status1';
} elseif ($status == self::STATUS_SHIPMENTONPROCESS) { } elseif ($status == self::STATUS_SHIPMENTONPROCESS) {
$labelStatus = $langs->trans('StatusOrderSentShort').$billedtext; $labelStatus = $langs->trans('StatusOrderSentShort').$billedtext;
$labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext; $labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext;
$statusType = 'status4'; $statusType = 'status4';
} elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { } elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
$labelStatus = $langs->trans('StatusOrderToBill'); $labelStatus = $langs->trans('StatusOrderToBill');
$labelStatusShort = $langs->trans('StatusOrderToBillShort'); $labelStatusShort = $langs->trans('StatusOrderToBillShort');
$statusType = 'status4'; $statusType = 'status4';
} elseif ($status == self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { } elseif ($status == self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
$labelStatus = $langs->trans('StatusOrderProcessed').$billedtext; $labelStatus = $langs->trans('StatusOrderProcessed').$billedtext;
$labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext; $labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext;
$statusType = 'status6'; $statusType = 'status6';
} elseif ($status == self::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { } elseif ($status == self::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
$labelStatus = $langs->trans('StatusOrderDelivered'); $labelStatus = $langs->trans('StatusOrderDelivered');
$labelStatusShort = $langs->trans('StatusOrderDelivered'); $labelStatusShort = $langs->trans('StatusOrderDelivered');
$statusType = 'status6'; $statusType = 'status6';
} else { } else {
$labelStatus = $langs->trans('Unknown'); $labelStatus = $langs->trans('Unknown');
$labelStatusShort = ''; $labelStatusShort = '';
$statusType = ''; $statusType = '';
$mode = 0; $mode = 0;
} }
return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
@ -3825,7 +3825,7 @@ class Commande extends CommonOrder
*/ */
public function load_state_board() public function load_state_board()
{ {
// phpcs:enable // phpcs:enable
global $user; global $user;
$this->nb = array(); $this->nb = array();
@ -4024,10 +4024,10 @@ class OrderLine extends CommonOrderLine
* *
* @param DoliDB $db handler d'acces base de donnee * @param DoliDB $db handler d'acces base de donnee
*/ */
public function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
/** /**
* Load line order * Load line order
@ -4125,32 +4125,32 @@ class OrderLine extends CommonOrderLine
$error = 0; $error = 0;
// check if order line is not in a shipment line before deleting // check if order line is not in a shipment line before deleting
$sqlCheckShipmentLine = "SELECT"; $sqlCheckShipmentLine = "SELECT";
$sqlCheckShipmentLine .= " ed.rowid"; $sqlCheckShipmentLine .= " ed.rowid";
$sqlCheckShipmentLine .= " FROM ".MAIN_DB_PREFIX."expeditiondet ed"; $sqlCheckShipmentLine .= " FROM ".MAIN_DB_PREFIX."expeditiondet ed";
$sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".$this->rowid; $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".$this->rowid;
$resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine); $resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine);
if (!$resqlCheckShipmentLine) { if (!$resqlCheckShipmentLine) {
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
} else { } else {
$langs->load('errors'); $langs->load('errors');
$num = $this->db->num_rows($resqlCheckShipmentLine); $num = $this->db->num_rows($resqlCheckShipmentLine);
if ($num > 0) { if ($num > 0) {
$error++; $error++;
$objCheckShipmentLine = $this->db->fetch_object($resqlCheckShipmentLine); $objCheckShipmentLine = $this->db->fetch_object($resqlCheckShipmentLine);
$this->error = $langs->trans('ErrorRecordAlreadyExists').' : '.$langs->trans('ShipmentLine').' '.$objCheckShipmentLine->rowid; $this->error = $langs->trans('ErrorRecordAlreadyExists').' : '.$langs->trans('ShipmentLine').' '.$objCheckShipmentLine->rowid;
$this->errors[] = $this->error; $this->errors[] = $this->error;
} }
$this->db->free($resqlCheckShipmentLine); $this->db->free($resqlCheckShipmentLine);
} }
if ($error) { if ($error) {
dol_syslog(__METHOD__.'Error ; '.$this->error, LOG_ERR); dol_syslog(__METHOD__.'Error ; '.$this->error, LOG_ERR);
return -1; return -1;
} }
$this->db->begin(); $this->db->begin();
@ -4482,7 +4482,7 @@ class OrderLine extends CommonOrderLine
*/ */
public function update_total() public function update_total()
{ {
// phpcs:enable // phpcs:enable
$this->db->begin(); $this->db->begin();
// Clean parameters // Clean parameters

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -29,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta", "banks", "bills", "accountancy")); $langs->loadLangs(array("compta", "banks", "bills", "accountancy"));
@ -44,11 +46,14 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$search_ref = GETPOST('search_ref', 'int'); $search_ref = GETPOST('search_ref', 'int');
$search_user = GETPOST('search_user', 'alpha'); $search_user = GETPOST('search_user', 'alpha');
$search_label = GETPOST('search_label', 'alpha'); $search_label = GETPOST('search_label', 'alpha');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); $search_datep_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_datep_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
$search_datev_start = dol_mktime(0, 0, 0, GETPOST('search_date_value_startmonth', 'int'), GETPOST('search_date_value_startday', 'int'), GETPOST('search_date_value_startyear', 'int'));
$search_datev_end = dol_mktime(23, 59, 59, GETPOST('search_date_value_endmonth', 'int'), GETPOST('search_date_value_endday', 'int'), GETPOST('search_date_value_endyear', 'int'));
$search_amount_deb = GETPOST('search_amount_deb', 'alpha'); $search_amount_deb = GETPOST('search_amount_deb', 'alpha');
$search_amount_cred = GETPOST('search_amount_cred', 'alpha'); $search_amount_cred = GETPOST('search_amount_cred', 'alpha');
$search_account = GETPOST('search_account', 'int'); $search_bank_account = GETPOST('search_account', 'int');
$search_bank_entry = GETPOST('search_bank_entry', 'int');
$search_accountancy_account = GETPOST("search_accountancy_account"); $search_accountancy_account = GETPOST("search_accountancy_account");
if ($search_accountancy_account == - 1) $search_accountancy_account = ''; if ($search_accountancy_account == - 1) $search_accountancy_account = '';
$search_accountancy_subledger = GETPOST("search_accountancy_subledger"); $search_accountancy_subledger = GETPOST("search_accountancy_subledger");
@ -81,18 +86,51 @@ if (!GETPOST('typeid'))
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
$search_ref = ""; $search_ref = '';
$search_label = ""; $search_label = '';
$search_date_start = ''; $search_datep_start = '';
$search_date_end = ''; $search_datep_end = '';
$search_amount_deb = ""; $search_datev_start = '';
$search_amount_cred = ""; $search_datev_end = '';
$search_account = ''; $search_amount_deb = '';
$search_amount_cred = '';
$search_bank_account = '';
$search_bank_entry = '';
$search_accountancy_account = ''; $search_accountancy_account = '';
$search_accountancy_subledger = ''; $search_accountancy_subledger = '';
$typeid = ""; $typeid = '';
} }
// Definition of fields for lists
$arrayfields = array(
'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100),
'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110),
'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120),
'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130),
'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140),
'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)),
'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)),
'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>!empty($conf->banque->enabled)),
'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>!empty($conf->accounting->enabled)),
'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>!empty($conf->accounting->enabled)),
'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500),
'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510),
);
$arrayfields = dol_sort_array($arrayfields, 'position');
/*
* Actions
*/
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
}
/* /*
* View * View
@ -101,11 +139,15 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
llxHeader(); llxHeader();
$form = new Form($db); $form = new Form($db);
$formaccounting = new FormAccounting($db); if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db);
$variousstatic = new PaymentVarious($db); if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db);
$accountstatic = new Account($db); if ($arrayfields['ref']['checked']) $variousstatic = new PaymentVarious($db);
if ($arrayfields['bank']['checked']) $accountstatic = new Account($db);
if ($arrayfields['project']['checked']) $proj = new Project($db);
if ($arrayfields['entry']['checked']) $bankline = new AccountLine($db);
if ($arrayfields['account']['checked']) $accountingaccount = new AccountingAccount($db);
$sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account,"; $sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account, v.fk_projet as fk_project,";
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,";
$sql .= " pst.code as payment_code"; $sql .= " pst.code as payment_code";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
@ -117,11 +159,14 @@ $sql .= " WHERE v.entity IN (".getEntity('payment_various').")";
// Search criteria // Search criteria
if ($search_ref) $sql .= " AND v.rowid=".$db->escape($search_ref); if ($search_ref) $sql .= " AND v.rowid=".$db->escape($search_ref);
if ($search_label) $sql .= natural_search(array('v.label'), $search_label); if ($search_label) $sql .= natural_search(array('v.label'), $search_label);
if ($search_date_start) $sql .= " AND v.datep >= '".$db->idate($search_date_start)."'"; if ($search_datep_start) $sql .= " AND v.datep >= '".$db->idate($search_datep_start)."'";
if ($search_date_end) $sql .= " AND v.datep <= '".$db->idate($search_date_end)."'"; if ($search_datep_end) $sql .= " AND v.datep <= '".$db->idate($search_datep_end)."'";
if ($search_datev_start) $sql .= " AND v.datev >= '".$db->idate($search_datev_start)."'";
if ($search_datev_end) $sql .= " AND v.datev <= '".$db->idate($search_datev_end)."'";
if ($search_amount_deb) $sql .= natural_search("v.amount", $search_amount_deb, 1); if ($search_amount_deb) $sql .= natural_search("v.amount", $search_amount_deb, 1);
if ($search_amount_cred) $sql .= natural_search("v.amount", $search_amount_cred, 1); if ($search_amount_cred) $sql .= natural_search("v.amount", $search_amount_cred, 1);
if ($search_account > 0) $sql .= " AND b.fk_account=".$db->escape($search_account); if ($search_bank_account > 0) $sql .= " AND b.fk_account=".$db->escape($search_bank_account);
if ($search_bank_entry > 0) $sql .= " AND b.fk_account=".$db->escape($search_bank_account);
if ($search_accountancy_account > 0) $sql .= " AND v.accountancy_code=".$db->escape($search_accountancy_account); if ($search_accountancy_account > 0) $sql .= " AND v.accountancy_code=".$db->escape($search_accountancy_account);
if ($search_accountancy_subledger > 0) $sql .= " AND v.subledger_account=".$db->escape($search_accountancy_subledger); if ($search_accountancy_subledger > 0) $sql .= " AND v.subledger_account=".$db->escape($search_accountancy_subledger);
if ($typeid > 0) $sql .= " AND v.fk_typepayment=".$typeid; if ($typeid > 0) $sql .= " AND v.fk_typepayment=".$typeid;
@ -154,10 +199,10 @@ if ($result)
if ($search_label) $param .= '&search_label='.urlencode($search_label); if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start); if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start);
if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end); if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end);
if ($typeid > 0) $param .= '&typeid='.urlencode($typeid); if ($typeid > 0) $param .= '&typeid='.urlencode($typeid);
if ($search_amount_deb) $param .= '&search_amount_deb='.urlencode($search_amount_deb); if ($search_amount_deb) $param .= '&search_amount_deb='.urlencode($search_amount_deb);
if ($search_amount_cred) $param .= '&search_amount_cred='.urlencode($search_amount_cred); if ($search_amount_cred) $param .= '&search_amount_cred='.urlencode($search_amount_cred);
if ($search_account > 0) $param .= '&search_amount='.urlencode($search_account); if ($search_bank_account > 0) $param .= '&search_amount='.urlencode($search_bank_account);
if ($search_accountancy_account > 0) $param .= '&search_accountancy_account='.urlencode($search_accountancy_account); if ($search_accountancy_account > 0) $param .= '&search_accountancy_account='.urlencode($search_accountancy_account);
if ($search_accountancy_subledger > 0) $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger); if ($search_accountancy_subledger > 0) $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger);
@ -177,59 +222,104 @@ if ($result)
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
print '<td class="liste_titre">';
print '</td>';
}
// Ref // Ref
print '<td class="liste_titre left">'; if ($arrayfields['ref']['checked']) {
print '<input class="flat" type="text" size="3" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '<td class="liste_titre left">';
print '</td>'; print '<input class="flat" type="text" size="3" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
// Label // Label
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; if ($arrayfields['label']['checked']) {
// Date
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to').' ';
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1);
print '</div>';
print '</td>';
// Type
print '<td class="liste_titre left">';
$form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16);
print '</td>';
// Account
if (!empty($conf->banque->enabled))
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$form->select_comptes($search_account, 'search_account', 0, '', 1); print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
print '</td>';
}
// Payment date
if ($arrayfields['datep']['checked']) {
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
print $form->selectDate($search_datep_start ? $search_datep_start : -1, 'search_date_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to').' ';
print $form->selectDate($search_datep_end ? $search_datep_end : -1, 'search_date_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// Value date
if ($arrayfields['datev']['checked']) {
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
print $form->selectDate($search_datev_start ? $search_datev_start : -1, 'search_date_value_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to').' ';
print $form->selectDate($search_datev_end ? $search_datev_end : -1, 'search_date_value_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// Payment type
if ($arrayfields['type']['checked']) {
print '<td class="liste_titre left">';
$form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16);
print '</td>';
}
// Project
if ($arrayfields['project']['checked']) {
print '<td class="liste_titre">';
// TODO
print '</td>';
}
// Bank account
if ($arrayfields['bank']['checked']) {
print '<td class="liste_titre">';
$form->select_comptes($search_bank_account, 'search_account', 0, '', 1);
print '</td>';
}
// Bank entry
if ($arrayfields['entry']['checked']) {
print '<td class="liste_titre right">';
print '<input name="search_bank_entry" class="flat" type="text" size="8" value="'.$search_bank_entry.'">';
print '</td>'; print '</td>';
} }
// Accounting account // Accounting account
if (!empty($conf->accounting->enabled)) if ($arrayfields['account']['checked']) {
{
// Accounting account
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array(), 1, 1, 'maxwidth200'); print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array(), 1, 1, 'maxwidth200');
print '</div>'; print '</div>';
print '</td>'; print '</td>';
}
// Subledger account // Subledger account
if ($arrayfields['subledger']['checked']) {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, 'maxwidth200'); print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, 'maxwidth200');
@ -238,31 +328,50 @@ if ($result)
} }
// Debit // Debit
print '<td class="liste_titre right"><input name="search_amount_deb" class="flat" type="text" size="8" value="'.$search_amount_deb.'"></td>'; if ($arrayfields['debit']['checked']) {
print '<td class="liste_titre right">';
print '<input name="search_amount_deb" class="flat" type="text" size="8" value="'.$search_amount_deb.'">';
print '</td>';
}
// Credit // Credit
print '<td class="liste_titre right"><input name="search_amount_cred" class="flat" type="text" size="8" value="'.$search_amount_cred.'"></td>'; if ($arrayfields['credit']['checked']) {
print '<td class="liste_titre right">';
print '<input name="search_amount_cred" class="flat" type="text" size="8" value="'.$search_amount_cred.'">';
print '</td>';
}
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0); $searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print "</tr>\n"; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "v.rowid", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "v.label", "", $param, '', $sortfield, $sortorder, 'left '); if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "v.datep,v.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'left '); if ($arrayfields['ref']['checked']) print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], 'v.rowid', '', $param, '', $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); if ($arrayfields['label']['checked']) print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], 'v.label', '', $param, '', $sortfield, $sortorder, 'left ');
if (!empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccountingShort", $_SERVER["PHP_SELF"], "v.accountancy_code", "", $param, '', $sortfield, $sortorder, 'left '); if ($arrayfields['datep']['checked']) print_liste_field_titre($arrayfields['datep']['label'], $_SERVER["PHP_SELF"], 'v.datep,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
if (!empty($conf->accounting->enabled)) print_liste_field_titre("SubledgerAccount", $_SERVER["PHP_SELF"], "v.subledger_account", "", $param, '', $sortfield, $sortorder, 'left '); if ($arrayfields['datev']['checked']) print_liste_field_titre($arrayfields['datev']['label'], $_SERVER["PHP_SELF"], 'v.datev,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right '); if ($arrayfields['type']['checked']) print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], 'type', '', $param, '', $sortfield, $sortorder, 'left ');
print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right '); if ($arrayfields['project']['checked']) print_liste_field_titre($arrayfields['project']['label'], $_SERVER["PHP_SELF"], 'fk_project', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); if ($arrayfields['bank']['checked']) print_liste_field_titre($arrayfields['bank']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
print "</tr>\n"; if ($arrayfields['entry']['checked']) print_liste_field_titre($arrayfields['entry']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
if ($arrayfields['account']['checked']) print_liste_field_titre($arrayfields['account']['label'], $_SERVER["PHP_SELF"], 'v.accountancy_code', '', $param, '', $sortfield, $sortorder, 'left ');
if ($arrayfields['subledger']['checked']) print_liste_field_titre($arrayfields['subledger']['label'], $_SERVER["PHP_SELF"], 'v.subledger_account', '', $param, '', $sortfield, $sortorder, 'left ');
if ($arrayfields['debit']['checked']) print_liste_field_titre($arrayfields['debit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right ');
if ($arrayfields['credit']['checked']) print_liste_field_titre($arrayfields['credit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right ');
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
print '</tr>';
$totalarray = array(); $totalarray = array();
@ -272,28 +381,53 @@ if ($result)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
$variousstatic->id = $obj->rowid; // No
$variousstatic->ref = $obj->rowid; if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
print '<td>'.(($offset * $limit) + $i).'</td>';
}
// Ref // Ref
print "<td>".$variousstatic->getNomUrl(1)."</td>\n"; if ($arrayfields['ref']['checked']) {
if (!$i) $totalarray['nbfield']++; $variousstatic->id = $obj->rowid;
$variousstatic->ref = $obj->rowid;
print "<td>".$variousstatic->getNomUrl(1)."</td>";
if (!$i) $totalarray['nbfield']++;
}
// Label payment // Label payment
print "<td>".dol_trunc($obj->label, 40)."</td>\n"; if ($arrayfields['label']['checked']) {
if (!$i) $totalarray['nbfield']++; print "<td>".dol_trunc($obj->label, 40)."</td>";
if (!$i) $totalarray['nbfield']++;
}
// Date payment // Date payment
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n"; if ($arrayfields['datep']['checked']) {
if (!$i) $totalarray['nbfield']++; print '<td class="center">'.dol_print_date($obj->datep, 'day')."</td>";
if (!$i) $totalarray['nbfield']++;
}
// Date value
if ($arrayfields['datev']['checked']) {
print '<td class="center">'.dol_print_date($obj->datev, 'day')."</td>";
if (!$i) $totalarray['nbfield']++;
}
// Type // Type
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>'; if ($arrayfields['type']['checked']) {
if (!$i) $totalarray['nbfield']++; print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Account // Project
if (!empty($conf->banque->enabled)) if ($arrayfields['project']['checked']) {
{ $proj->fetch($obj->fk_project);
print '<td>'.$proj->getNomUrl(1).'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Bank account
if ($arrayfields['bank']['checked']) {
print '<td>'; print '<td>';
if ($obj->bid > 0) if ($obj->bid > 0)
{ {
@ -303,22 +437,28 @@ if ($result)
if (!empty($conf->accounting->enabled)) { if (!empty($conf->accounting->enabled)) {
$accountstatic->account_number = $obj->bank_account_number; $accountstatic->account_number = $obj->bank_account_number;
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($obj->accountancy_journal); $accountingjournal->fetch($obj->accountancy_journal);
$accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
} }
$accountstatic->label = $obj->blabel; $accountstatic->label = $obj->blabel;
print $accountstatic->getNomUrl(1); print $accountstatic->getNomUrl(1);
} else print '&nbsp;'; } else {
print '</td>'; print '&nbsp;';
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
}
// Bank entry
if ($arrayfields['entry']['checked']) {
$bankline->fetch($obj->fk_bank);
print '<td>'.$bankline->getNomUrl(1).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Accounting account // Accounting account
if (!empty($conf->accounting->enabled)) { if ($arrayfields['account']['checked']) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('', $obj->accountancy_code, 1); $accountingaccount->fetch('', $obj->accountancy_code, 1);
print '<td>'.$accountingaccount->getNomUrl(0, 1, 1, '', 1).'</td>'; print '<td>'.$accountingaccount->getNomUrl(0, 1, 1, '', 1).'</td>';
@ -326,38 +466,42 @@ if ($result)
} }
// Accounting subledger account // Accounting subledger account
if (!empty($conf->accounting->enabled)) if ($arrayfields['subledger']['checked']) {
{
print '<td>'.length_accounta($obj->subledger_account).'</td>'; print '<td>'.length_accounta($obj->subledger_account).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Debit // Debit
print '<td class="nowrap right">'; if ($arrayfields['debit']['checked']) {
if ($obj->sens == 0) print '<td class="nowrap right">';
{ if ($obj->sens == 0)
print price($obj->amount); {
$totalarray['val']['total_deb'] += $obj->amount; print price($obj->amount);
$totalarray['val']['total_deb'] += $obj->amount;
}
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_deb';
print '</td>';
} }
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_deb';
print '</td>';
// Credit // Credit
print '<td class="nowrap right">'; if ($arrayfields['credit']['checked']) {
if ($obj->sens == 1) print '<td class="nowrap right">';
{ if ($obj->sens == 1)
print price($obj->amount); {
$totalarray['val']['total_cred'] += $obj->amount; print price($obj->amount);
$totalarray['val']['total_cred'] += $obj->amount;
}
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_cred';
print '</td>';
} }
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_cred';
print '</td>';
print '<td></td>'; print '<td></td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
print "</tr>\n"; print "</tr>";
$i++; $i++;
} }

View File

@ -415,7 +415,9 @@ class Invoices extends DolibarrApi
$request_data->array_options, $request_data->array_options,
$request_data->situation_percent, $request_data->situation_percent,
$request_data->fk_unit, $request_data->fk_unit,
$request_data->multicurrency_subprice $request_data->multicurrency_subprice,
0,
$request_data->ref_ext
); );
if ($updateRes > 0) { if ($updateRes > 0) {
@ -704,7 +706,9 @@ class Invoices extends DolibarrApi
$request_data->array_options, $request_data->array_options,
$request_data->situation_percent, $request_data->situation_percent,
$request_data->fk_prev_id, $request_data->fk_prev_id,
$request_data->fk_unit $request_data->fk_unit,
0,
$request_data->ref_ext
); );
if ($updateRes < 0) { if ($updateRes < 0) {

File diff suppressed because it is too large Load Diff

View File

@ -177,10 +177,10 @@ if (empty($reshook))
if ($canvas) $object->canvas = $canvas; if ($canvas) $object->canvas = $canvas;
$object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity);
$object->socid = GETPOST("socid", 'int'); $object->socid = GETPOST("socid", 'int');
$object->lastname = GETPOST("lastname", 'alpha'); $object->lastname = GETPOST("lastname", 'alpha');
$object->firstname = GETPOST("firstname", 'alpha'); $object->firstname = GETPOST("firstname", 'alpha');
$object->civility_code = GETPOST("civility_code", 'alpha'); $object->civility_code = GETPOST("civility_code", 'alpha');
$object->poste = GETPOST("poste", 'alpha'); $object->poste = GETPOST("poste", 'alpha');
$object->address = GETPOST("address", 'alpha'); $object->address = GETPOST("address", 'alpha');
$object->zip = GETPOST("zipcode", 'alpha'); $object->zip = GETPOST("zipcode", 'alpha');
@ -1355,7 +1355,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$object->fetch_thirdparty(); $object->fetch_thirdparty();
if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3)
{ {
print '<br>'; print '<br>';
@ -1368,11 +1368,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('ProspectLevel'); print $langs->trans('ProspectLevel');
print '<td>'; print '<td>';
if ($action != 'editlevel' && $user->rights->societe->contact->creer) print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editlevel&amp;id=' . $object->id . '">' . img_edit($langs->trans('Modify'), 1) . '</a></td>'; if ($action != 'editlevel' && $user->rights->societe->contact->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;id='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editlevel') { if ($action == 'editlevel') {
$formcompany->formProspectContactLevel($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_prospectlevel, 'prospect_contact_level_id', 1); $formcompany->formProspectContactLevel($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_prospectlevel, 'prospect_contact_level_id', 1);
} else { } else {
print $object->getLibProspLevel(); print $object->getLibProspLevel();
} }
@ -1381,13 +1381,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Status of prospection // Status of prospection
$object->loadCacheOfProspStatus(); $object->loadCacheOfProspStatus();
print '<tr><td>' . $langs->trans("StatusProsp") . '</td><td>' . $object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); print '<tr><td>'.$langs->trans("StatusProsp").'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
print '<div class="floatright">'; print '<div class="floatright">';
foreach ($object->cacheprospectstatus as $key => $val) { foreach ($object->cacheprospectstatus as $key => $val) {
$titlealt = 'default'; $titlealt = 'default';
if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&stcomm=' . $val['code'] . '&action=setstcomm">' . img_action($titlealt, $val['code'], $val['picto']) . '</a>'; if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
} }
print '</div></td></tr>'; print '</div></td></tr>';

View File

@ -158,8 +158,8 @@ $fieldstosearchall = array(
'p.phone_perso'=>"PhonePerso", 'p.phone_perso'=>"PhonePerso",
'p.phone_mobile'=>"PhoneMobile", 'p.phone_mobile'=>"PhoneMobile",
'p.fax'=>"Fax", 'p.fax'=>"Fax",
'p.note_public'=>"NotePublic", 'p.note_public'=>"NotePublic",
'p.note_private'=>"NotePrivate", 'p.note_private'=>"NotePrivate",
); );
// Definition of fields for list // Definition of fields for list
@ -541,7 +541,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = ''; $newcardbutton = '';
if ($user->rights->societe->contact->creer) if ($user->rights->societe->contact->creer)
{ {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create');
} }
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
@ -734,9 +734,9 @@ if (!empty($arrayfields['p.thirdparty']['checked']))
if (!empty($arrayfields['p.priv']['checked'])) if (!empty($arrayfields['p.priv']['checked']))
{ {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
$selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
print $form->selectarray('search_priv', $selectarray, $search_priv, 1); print $form->selectarray('search_priv', $selectarray, $search_priv, 1);
print '</td>'; print '</td>';
} }
// Prospect level // Prospect level
if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
@ -808,7 +808,7 @@ if (!empty($arrayfields['p.town']['checked'])) print_liste_field_
//if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); //if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
//if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder); //if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
if (!empty($arrayfields['country.code_iso']['checked'])) { if (!empty($arrayfields['country.code_iso']['checked'])) {
print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
} }
if (!empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder);
@ -831,24 +831,24 @@ if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) print_liste_field_
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields // Hook fields
$parameters = array( $parameters = array(
'arrayfields'=>$arrayfields, 'arrayfields'=>$arrayfields,
'param'=>$param, 'param'=>$param,
'sortfield'=>$sortfield, 'sortfield'=>$sortfield,
'sortorder'=>$sortorder, 'sortorder'=>$sortorder,
); );
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (!empty($arrayfields['p.datec']['checked'])) { if (!empty($arrayfields['p.datec']['checked'])) {
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
} }
if (!empty($arrayfields['p.tms']['checked'])) { if (!empty($arrayfields['p.tms']['checked'])) {
print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
} }
if (!empty($arrayfields['p.statut']['checked'])) { if (!empty($arrayfields['p.statut']['checked'])) {
print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center ');
} }
if (!empty($arrayfields['p.import_key']['checked'])) { if (!empty($arrayfields['p.import_key']['checked'])) {
print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
} }
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
@ -986,15 +986,15 @@ while ($i < min($num, $limit))
} }
} }
} }
// Company // Company
if (!empty($arrayfields['p.thirdparty']['checked'])) if (!empty($arrayfields['p.thirdparty']['checked']))
{ {
print '<td>'; print '<td>';
if ($obj->socid) if ($obj->socid)
{ {
$objsoc = new Societe($db); $objsoc = new Societe($db);
$objsoc->fetch($obj->socid); $objsoc->fetch($obj->socid);
print $objsoc->getNomUrl(1); print $objsoc->getNomUrl(1);
} else print '&nbsp;'; } else print '&nbsp;';
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;

View File

@ -170,7 +170,7 @@ class CMailFile
$this->sendmode = ''; $this->sendmode = '';
if (!empty($this->sendcontext)) { if (!empty($this->sendcontext)) {
$smtpContextKey = strtoupper($this->sendcontext); $smtpContextKey = strtoupper($this->sendcontext);
$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey;
$smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode};
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
$this->sendmode = $smtpContextSendMode; $this->sendmode = $smtpContextSendMode;
@ -443,9 +443,9 @@ class CMailFile
// Set the From address with an associative array // Set the From address with an associative array
//$this->message->setFrom(array('john@doe.com' => 'John Doe')); //$this->message->setFrom(array('john@doe.com' => 'John Doe'));
if (! empty($this->addr_from)) { if (!empty($this->addr_from)) {
try { try {
if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) { if (!empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) {
// Prevent email spoofing for smtp server with a strict configuration // Prevent email spoofing for smtp server with a strict configuration
$regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string $regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string
$emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom); $emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom);
@ -465,7 +465,7 @@ class CMailFile
} }
// Set the To addresses with an associative array // Set the To addresses with an associative array
if (! empty($this->addr_to)) { if (!empty($this->addr_to)) {
try { try {
$result = $this->message->setTo($this->getArrayAddress($this->addr_to)); $result = $this->message->setTo($this->getArrayAddress($this->addr_to));
} catch (Exception $e) { } catch (Exception $e) {
@ -473,7 +473,7 @@ class CMailFile
} }
} }
if (! empty($this->reply_to)) { if (!empty($this->reply_to)) {
try { try {
$result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to)); $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
} catch (Exception $e) { } catch (Exception $e) {
@ -529,8 +529,8 @@ class CMailFile
} }
} }
if (! empty($this->addr_cc)) $this->message->setCc($this->getArrayAddress($this->addr_cc)); if (!empty($this->addr_cc)) $this->message->setCc($this->getArrayAddress($this->addr_cc));
if (! empty($this->addr_bcc)) $this->message->setBcc($this->getArrayAddress($this->addr_bcc)); if (!empty($this->addr_bcc)) $this->message->setBcc($this->getArrayAddress($this->addr_bcc));
//if (! empty($this->errors_to)) $this->message->setErrorsTo($this->getArrayAddress($this->errors_to)); //if (! empty($this->errors_to)) $this->message->setErrorsTo($this->getArrayAddress($this->errors_to));
if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from)); if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
} else { } else {
@ -641,15 +641,15 @@ class CMailFile
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS'; $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS';
if (!empty($this->sendcontext)) { if (!empty($this->sendcontext)) {
$smtpContextKey = strtoupper($this->sendcontext); $smtpContextKey = strtoupper($this->sendcontext);
$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey;
$smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode};
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_' . $smtpContextKey; $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey;
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_' . $smtpContextKey; $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey;
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_' . $smtpContextKey; $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey;
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_' . $smtpContextKey; $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey;
$keyfortls = 'MAIN_MAIL_EMAIL_TLS_' . $smtpContextKey; $keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey;
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_' . $smtpContextKey; $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey;
} }
} }

View File

@ -3893,6 +3893,7 @@ abstract class CommonObject
{ {
// phpcs:enable // phpcs:enable
$out = ''; $out = '';
$this->label_incoterms = ''; $this->label_incoterms = '';
if (!empty($this->fk_incoterms)) if (!empty($this->fk_incoterms))
{ {
@ -3905,7 +3906,7 @@ abstract class CommonObject
} }
} }
$out .= (($res->code && $this->location_incoterms) ? ' - ' : '').$this->location_incoterms; $out .= (($out && $this->location_incoterms) ? ' - ' : '').$this->location_incoterms;
return $out; return $out;
} }
@ -4567,245 +4568,245 @@ abstract class CommonObject
if (empty($reshook)) if (empty($reshook))
{ {
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
// Increase limit for PDF build // Increase limit for PDF build
$err = error_reporting(); $err = error_reporting();
error_reporting(0); error_reporting(0);
@set_time_limit(120); @set_time_limit(120);
error_reporting($err); error_reporting($err);
// If selected model is a filename template (then $modele="modelname" or "modelname:filename") // If selected model is a filename template (then $modele="modelname" or "modelname:filename")
$tmp = explode(':', $modele, 2); $tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) if (!empty($tmp[1]))
{ {
$modele = $tmp[0]; $modele = $tmp[0];
$srctemplatepath = $tmp[1]; $srctemplatepath = $tmp[1];
} }
// Search template files // Search template files
$file = ''; $file = '';
$classname = ''; $classname = '';
$filefound = ''; $filefound = '';
$dirmodels = array('/'); $dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('doc', 'pdf') as $prefix) foreach (array('doc', 'pdf') as $prefix)
{ {
if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php
else $file = $prefix."_".$modele.".modules.php"; else $file = $prefix."_".$modele.".modules.php";
// On verifie l'emplacement du modele // On verifie l'emplacement du modele
$file = dol_buildpath($reldir.$modelspath.$file, 0); $file = dol_buildpath($reldir.$modelspath.$file, 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = $file; $filefound = $file;
$classname = $prefix.'_'.$modele; $classname = $prefix.'_'.$modele;
break; break;
} }
} }
if ($filefound) break; if ($filefound) break;
} }
// If generator was found // If generator was found
if ($filefound) if ($filefound)
{ {
global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
require_once $file; require_once $file;
$obj = new $classname($this->db); $obj = new $classname($this->db);
// If generator is ODT, we must have srctemplatepath defined, if not we set it. // If generator is ODT, we must have srctemplatepath defined, if not we set it.
if ($obj->type == 'odt' && empty($srctemplatepath)) if ($obj->type == 'odt' && empty($srctemplatepath))
{ {
$varfortemplatedir = $obj->scandir; $varfortemplatedir = $obj->scandir;
if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir)) if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir))
{ {
$dirtoscan = $conf->global->$varfortemplatedir; $dirtoscan = $conf->global->$varfortemplatedir;
$listoffiles = array(); $listoffiles = array();
// Now we add first model found in directories scanned // Now we add first model found in directories scanned
$listofdir = explode(',', $dirtoscan); $listofdir = explode(',', $dirtoscan);
foreach ($listofdir as $key => $tmpdir) foreach ($listofdir as $key => $tmpdir)
{ {
$tmpdir = trim($tmpdir); $tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) { unset($listofdir[$key]); continue; } if (!$tmpdir) { unset($listofdir[$key]); continue; }
if (is_dir($tmpdir)) if (is_dir($tmpdir))
{ {
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
} }
} }
if (count($listoffiles)) if (count($listoffiles))
{ {
foreach ($listoffiles as $record) foreach ($listoffiles as $record)
{ {
$srctemplatepath = $record['fullname']; $srctemplatepath = $record['fullname'];
break; break;
} }
} }
} }
if (empty($srctemplatepath)) if (empty($srctemplatepath))
{ {
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
return -1; return -1;
} }
} }
if ($obj->type == 'odt' && !empty($srctemplatepath)) if ($obj->type == 'odt' && !empty($srctemplatepath))
{ {
if (!dol_is_file($srctemplatepath)) if (!dol_is_file($srctemplatepath))
{ {
dol_syslog("Failed to locate template file ".$srctemplatepath, LOG_WARNING); dol_syslog("Failed to locate template file ".$srctemplatepath, LOG_WARNING);
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
return -1; return -1;
} }
} }
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.
$sav_charset_output = $outputlangs->charset_output; $sav_charset_output = $outputlangs->charset_output;
if (in_array(get_class($this), array('Adherent'))) if (in_array(get_class($this), array('Adherent')))
{ {
$arrayofrecords = array(); // The write_file of templates of adherent class need this var $arrayofrecords = array(); // The write_file of templates of adherent class need this var
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
} else { } else {
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
} }
// After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index.
if ($resultwritefile > 0) if ($resultwritefile > 0)
{ {
$outputlangs->charset_output = $sav_charset_output; $outputlangs->charset_output = $sav_charset_output;
// We delete old preview // We delete old preview
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_delete_preview($this); dol_delete_preview($this);
// Index file in database // Index file in database
if (!empty($obj->result['fullpath'])) if (!empty($obj->result['fullpath']))
{ {
$destfull = $obj->result['fullpath']; $destfull = $obj->result['fullpath'];
$upload_dir = dirname($destfull); $upload_dir = dirname($destfull);
$destfile = basename($destfull); $destfile = basename($destfull);
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
{ {
$filename = basename($destfile); $filename = basename($destfile);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile = new EcmFiles($this->db); $ecmfile = new EcmFiles($this->db);
$result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename); $result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename);
// Set the public "share" key // Set the public "share" key
$setsharekey = false; $setsharekey = false;
if ($this->element == 'propal') if ($this->element == 'propal')
{ {
$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok
if ($useonlinesignature) $setsharekey = true; if ($useonlinesignature) $setsharekey = true;
if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true; if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true;
} }
if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey = true; $setsharekey = true;
} }
if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey = true; $setsharekey = true;
} }
if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey = true; $setsharekey = true;
} }
if ($setsharekey) { if ($setsharekey) {
if (empty($ecmfile->share)) // Because object not found or share not set yet if (empty($ecmfile->share)) // Because object not found or share not set yet
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$ecmfile->share = getRandomPassword(true); $ecmfile->share = getRandomPassword(true);
} }
} }
if ($result > 0) if ($result > 0)
{ {
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
$ecmfile->fullpath_orig = ''; $ecmfile->fullpath_orig = '';
$ecmfile->gen_or_uploaded = 'generated'; $ecmfile->gen_or_uploaded = 'generated';
$ecmfile->description = ''; // indexed content $ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content $ecmfile->keyword = ''; // keyword content
$result = $ecmfile->update($user); $result = $ecmfile->update($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
} }
} else { } else {
$ecmfile->entity = $conf->entity; $ecmfile->entity = $conf->entity;
$ecmfile->filepath = $rel_dir; $ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename; $ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
$ecmfile->fullpath_orig = ''; $ecmfile->fullpath_orig = '';
$ecmfile->gen_or_uploaded = 'generated'; $ecmfile->gen_or_uploaded = 'generated';
$ecmfile->description = ''; // indexed content $ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content $ecmfile->keyword = ''; // keyword content
$ecmfile->src_object_type = $this->table_element; $ecmfile->src_object_type = $this->table_element;
$ecmfile->src_object_id = $this->id; $ecmfile->src_object_id = $this->id;
$result = $ecmfile->create($user); $result = $ecmfile->create($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
} }
} }
/*$this->result['fullname']=$destfull; /*$this->result['fullname']=$destfull;
$this->result['filepath']=$ecmfile->filepath; $this->result['filepath']=$ecmfile->filepath;
$this->result['filename']=$ecmfile->filename;*/ $this->result['filename']=$ecmfile->filename;*/
//var_dump($obj->update_main_doc_field);exit; //var_dump($obj->update_main_doc_field);exit;
// Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
$update_main_doc_field = 0; $update_main_doc_field = 0;
if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1; if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1;
if ($update_main_doc_field && !empty($this->table_element)) if ($update_main_doc_field && !empty($this->table_element))
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
dol_print_error($this->db); dol_print_error($this->db);
} else { } else {
$this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
} }
} }
} }
} else { } else {
dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
} }
// Success in building document. We build meta file. // Success in building document. We build meta file.
dol_meta_create($this); dol_meta_create($this);
return 1; return 1;
} else { } else {
$outputlangs->charset_output = $sav_charset_output; $outputlangs->charset_output = $sav_charset_output;
dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
return -1; return -1;
} }
} else { } else {
if (!$filefound) { if (!$filefound) {
$this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele; $this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele;
dol_print_error('', $this->error); dol_print_error('', $this->error);
} else { } else {
$this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound); $this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound);
dol_print_error('', $this->error); dol_print_error('', $this->error);
} }
return -1; return -1;
} }
} else return $reshook; } else return $reshook;
} }
@ -7987,46 +7988,46 @@ abstract class CommonObject
// Delete cascade first // Delete cascade first
if (is_array($this->childtablesoncascade) && !empty($this->childtablesoncascade)) { if (is_array($this->childtablesoncascade) && !empty($this->childtablesoncascade)) {
foreach ($this->childtablesoncascade as $table) foreach ($this->childtablesoncascade as $table)
{ {
$deleteFromObject = explode(':', $table); $deleteFromObject = explode(':', $table);
if (count($deleteFromObject) >= 2) { if (count($deleteFromObject) >= 2) {
$className = str_replace('@', '', $deleteFromObject[0]); $className = str_replace('@', '', $deleteFromObject[0]);
$filePath = $deleteFromObject[1]; $filePath = $deleteFromObject[1];
$columnName = $deleteFromObject[2]; $columnName = $deleteFromObject[2];
if (dol_include_once($filePath)) { if (dol_include_once($filePath)) {
$childObject = new $className($this->db); $childObject = new $className($this->db);
if (method_exists($childObject, 'deleteByParentField')) { if (method_exists($childObject, 'deleteByParentField')) {
$result = $childObject->deleteByParentField($this->id, $columnName); $result = $childObject->deleteByParentField($this->id, $columnName);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$this->errors[] = $childObject->error; $this->errors[] = $childObject->error;
break; break;
} }
} else { } else {
$error++; $error++;
$this->errors[] = "You defined a cascade delete on an object $childObject but there is no method deleteByParentField for it"; $this->errors[] = "You defined a cascade delete on an object $childObject but there is no method deleteByParentField for it";
break; break;
} }
} else { } else {
$error++;
$this->errors[] = 'Cannot include child class file '.$filePath;
break;
}
} else {
// Delete record in child table
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $error++;
$this->error = $this->db->lasterror(); $this->errors[] = 'Cannot include child class file '.$filePath;
$this->errors[] = $this->error;
break; break;
} }
} } else {
} // Delete record in child table
} $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
break;
}
}
}
}
if (!$error) { if (!$error) {
if (!$notrigger) { if (!$notrigger) {

View File

@ -31,385 +31,385 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/ */
class CoreObject extends CommonObject class CoreObject extends CommonObject
{ {
public $withChild = true; public $withChild = true;
/** /**
* @var Array $_fields Fields to synchronize with Database * @var Array $_fields Fields to synchronize with Database
*/ */
protected $fields = array(); protected $fields = array();
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct(DoliDB &$db) public function __construct(DoliDB &$db)
{ {
$this->db = $db; $this->db = $db;
} }
/** /**
* Function to init fields * Function to init fields
* *
* @return bool * @return bool
*/ */
protected function init() protected function init()
{ {
$this->id = 0; $this->id = 0;
$this->datec = 0; $this->datec = 0;
$this->tms = 0; $this->tms = 0;
if (!empty($this->fields)) if (!empty($this->fields))
{ {
foreach ($this->fields as $field=>$info) foreach ($this->fields as $field=>$info)
{ {
if ($this->isDate($info)) $this->{$field} = time(); if ($this->isDate($info)) $this->{$field} = time();
elseif ($this->isArray($info)) $this->{$field} = array(); elseif ($this->isArray($info)) $this->{$field} = array();
elseif ($this->isInt($info)) $this->{$field} = (int) 0; elseif ($this->isInt($info)) $this->{$field} = (int) 0;
elseif ($this->isFloat($info)) $this->{$field} = (double) 0; elseif ($this->isFloat($info)) $this->{$field} = (double) 0;
else $this->{$field} = ''; else $this->{$field} = '';
} }
$this->to_delete = false; $this->to_delete = false;
$this->is_clone = false; $this->is_clone = false;
return true; return true;
} else { } else {
return false; return false;
} }
} }
/** /**
* Test type of field * Test type of field
* *
* @param string $field name of field * @param string $field name of field
* @param string $type type of field to test * @param string $type type of field to test
* @return boolean value of field or false * @return boolean value of field or false
*/ */
private function checkFieldType($field, $type) private function checkFieldType($field, $type)
{ {
if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type))
{ {
return $this->{'is_'.$type}($this->fields[$field]); return $this->{'is_'.$type}($this->fields[$field]);
} else { } else {
return false; return false;
} }
} }
/** /**
* Get object and children from database * Get object and children from database
* *
* @param int $id Id of object to load * @param int $id Id of object to load
* @param bool $loadChild used to load children from database * @param bool $loadChild used to load children from database
* @return int >0 if OK, <0 if KO, 0 if not found * @return int >0 if OK, <0 if KO, 0 if not found
*/ */
public function fetch($id, $loadChild = true) public function fetch($id, $loadChild = true)
{ {
$res = $this->fetchCommon($id); $res = $this->fetchCommon($id);
if ($res > 0) { if ($res > 0) {
if ($loadChild) $this->fetchChild(); if ($loadChild) $this->fetchChild();
} }
return $res; return $res;
} }
/** /**
* Function to instantiate a new child * Function to instantiate a new child
* *
* @param string $tabName Table name of child * @param string $tabName Table name of child
* @param int $id If id is given, we try to return his key if exist or load if we try_to_load * @param int $id If id is given, we try to return his key if exist or load if we try_to_load
* @param string $key Attribute name of the object id * @param string $key Attribute name of the object id
* @param bool $try_to_load Force the fetch if an id is given * @param bool $try_to_load Force the fetch if an id is given
* @return int * @return int
*/ */
public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false) public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false)
{ {
if (!empty($id)) if (!empty($id))
{ {
foreach ($this->{$tabName} as $k=>&$object) foreach ($this->{$tabName} as $k=>&$object)
{ {
if ($object->{$key} === $id) return $k; if ($object->{$key} === $id) return $k;
} }
} }
$k = count($this->{$tabName}); $k = count($this->{$tabName});
$className = ucfirst($tabName); $className = ucfirst($tabName);
$this->{$tabName}[$k] = new $className($this->db); $this->{$tabName}[$k] = new $className($this->db);
if ($id > 0 && $key === 'id' && $try_to_load) if ($id > 0 && $key === 'id' && $try_to_load)
{ {
$this->{$tabName}[$k]->fetch($id); $this->{$tabName}[$k]->fetch($id);
} }
return $k; return $k;
} }
/** /**
* Function to set a child as to delete * Function to set a child as to delete
* *
* @param string $tabName Table name of child * @param string $tabName Table name of child
* @param int $id Id of child to set as to delete * @param int $id Id of child to set as to delete
* @param string $key Attribute name of the object id * @param string $key Attribute name of the object id
* @return bool * @return bool
*/ */
public function removeChild($tabName, $id, $key = 'id') public function removeChild($tabName, $id, $key = 'id')
{ {
foreach ($this->{$tabName} as &$object) foreach ($this->{$tabName} as &$object)
{ {
if ($object->{$key} == $id) if ($object->{$key} == $id)
{ {
$object->to_delete = true; $object->to_delete = true;
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* Function to fetch children objects * Function to fetch children objects
* *
* @return void * @return void
*/ */
public function fetchChild() public function fetchChild()
{ {
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
{ {
foreach ($this->childtables as &$childTable) foreach ($this->childtables as &$childTable)
{ {
$className = ucfirst($childTable); $className = ucfirst($childTable);
$this->{$className} = array(); $this->{$className} = array();
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id;
$res = $this->db->query($sql); $res = $this->db->query($sql);
if ($res) if ($res)
{ {
while ($obj = $this->db->fetch_object($res)) while ($obj = $this->db->fetch_object($res))
{ {
$o = new $className($this->db); $o = new $className($this->db);
$o->fetch($obj->rowid); $o->fetch($obj->rowid);
$this->{$className}[] = $o; $this->{$className}[] = $o;
} }
} else { } else {
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
} }
} }
} }
} }
/** /**
* Function to update children data * Function to update children data
* *
* @param User $user user object * @param User $user user object
* @return void * @return void
*/ */
public function saveChild(User &$user) public function saveChild(User &$user)
{ {
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
{ {
foreach ($this->childtables as &$childTable) foreach ($this->childtables as &$childTable)
{ {
$className = ucfirst($childTable); $className = ucfirst($childTable);
if (!empty($this->{$className})) if (!empty($this->{$className}))
{ {
foreach ($this->{$className} as $i => &$object) foreach ($this->{$className} as $i => &$object)
{ {
$object->{$this->fk_element} = $this->id; $object->{$this->fk_element} = $this->id;
$object->update($user); $object->update($user);
if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) unset($this->{$className}[$i]); if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) unset($this->{$className}[$i]);
} }
} }
} }
} }
} }
/** /**
* Function to update object or create or delete if needed * Function to update object or create or delete if needed
* *
* @param User $user User object * @param User $user User object
* @return int < 0 if KO, > 0 if OK * @return int < 0 if KO, > 0 if OK
*/ */
public function update(User &$user) public function update(User &$user)
{ {
if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed
elseif (isset($this->to_delete) && $this->to_delete == true) return $this->delete($user); elseif (isset($this->to_delete) && $this->to_delete == true) return $this->delete($user);
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
$res = $this->updateCommon($user); $res = $this->updateCommon($user);
if ($res) if ($res)
{ {
$result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user); $result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
else $this->saveChild($user); else $this->saveChild($user);
} else { } else {
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
} }
if (empty($error)) if (empty($error))
{ {
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
} else { } else {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
/** /**
* Function to create object in database * Function to create object in database
* *
* @param User $user user object * @param User $user User object
* @return int < 0 if KO, > 0 if OK * @return int < 0 if KO, > 0 if OK
*/ */
public function create(User &$user) public function create(User $user)
{ {
if ($this->id > 0) return $this->update($user); if ($this->id > 0) return $this->update($user);
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
$res = $this->createCommon($user); $res = $this->createCommon($user);
if ($res) if ($res)
{ {
$this->id = $this->db->last_insert_id($this->table_element); $this->id = $this->db->last_insert_id($this->table_element);
$result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user); $result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
else $this->saveChild($user); else $this->saveChild($user);
} else { } else {
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
} }
if (empty($error)) if (empty($error))
{ {
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
} else { } else {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
/** /**
* Function to delete object in database * Function to delete object in database
* *
* @param User $user user object * @param User $user user object
* @return int < 0 if KO, > 0 if OK * @return int < 0 if KO, > 0 if OK
*/ */
public function delete(User &$user) public function delete(User &$user)
{ {
if ($this->id <= 0) return 0; if ($this->id <= 0) return 0;
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
$result = $this->call_trigger(strtoupper($this->element).'_DELETE', $user); $result = $this->call_trigger(strtoupper($this->element).'_DELETE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
if (!$error) if (!$error)
{ {
$this->deleteCommon($user); $this->deleteCommon($user);
if ($this->withChild && !empty($this->childtables)) if ($this->withChild && !empty($this->childtables))
{ {
foreach ($this->childtables as &$childTable) foreach ($this->childtables as &$childTable)
{ {
$className = ucfirst($childTable); $className = ucfirst($childTable);
if (!empty($this->{$className})) if (!empty($this->{$className}))
{ {
foreach ($this->{$className} as &$object) foreach ($this->{$className} as &$object)
{ {
$object->delete($user); $object->delete($user);
} }
} }
} }
} }
} }
if (empty($error)) if (empty($error))
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
/** /**
* Function to get a formatted date * Function to get a formatted date
* *
* @param string $field Attribute to return * @param string $field Attribute to return
* @param string $format Output date format * @param string $format Output date format
* @return string * @return string
*/ */
public function getDate($field, $format = '') public function getDate($field, $format = '')
{ {
if (empty($this->{$field})) return ''; if (empty($this->{$field})) return '';
else { else {
return dol_print_date($this->{$field}, $format); return dol_print_date($this->{$field}, $format);
} }
} }
/** /**
* Function to set date in field * Function to set date in field
* *
* @param string $field field to set * @param string $field field to set
* @param string $date formatted date to convert * @param string $date formatted date to convert
* @return mixed * @return mixed
*/ */
public function setDate($field, $date) public function setDate($field, $date)
{ {
if (empty($date)) if (empty($date))
{ {
$this->{$field} = 0; $this->{$field} = 0;
} else { } else {
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$this->{$field} = dol_stringtotime($date); $this->{$field} = dol_stringtotime($date);
} }
return $this->{$field}; return $this->{$field};
} }
/** /**
* Function to update current object * Function to update current object
* *
* @param array $Tab Array of values * @param array $Tab Array of values
* @return int * @return int
*/ */
public function setValues(&$Tab) public function setValues(&$Tab)
{ {
foreach ($Tab as $key => $value) foreach ($Tab as $key => $value)
{ {
if ($this->checkFieldType($key, 'date')) if ($this->checkFieldType($key, 'date'))
{ {
$this->setDate($key, $value); $this->setDate($key, $value);
} elseif ($this->checkFieldType($key, 'float')) } elseif ($this->checkFieldType($key, 'float'))
{ {
$this->{$key} = (double) price2num($value); $this->{$key} = (double) price2num($value);
} elseif ($this->checkFieldType($key, 'int')) { } elseif ($this->checkFieldType($key, 'int')) {
$this->{$key} = (int) price2num($value); $this->{$key} = (int) price2num($value);
} else { } else {
$this->{$key} = dol_string_nohtmltag($value); $this->{$key} = dol_string_nohtmltag($value);
} }
} }
return 1; return 1;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -647,7 +647,7 @@ class Form
$disabled = 0; $disabled = 0;
$ret = '<div class="centpercent center">'; $ret = '<div class="centpercent center">';
$ret .= '<select class="flat'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' '.$name.' '.$name.'select valignmiddle alignstart" name="'.$name.'"'.($disabled ? ' disabled="disabled"' : '').'>'; $ret .= '<select class="flat'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' '.$name.' '.$name.'select valignmiddle alignstart" name="'.$name.'"'.($disabled ? ' disabled="disabled"' : '').'>';
// Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks. // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks.
$parameters = array(); $parameters = array();
@ -666,11 +666,11 @@ class Form
$ret .= '</select>'; $ret .= '</select>';
if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.'.$name.'select'); if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.'.$name.'select');
// Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button
$ret .= '<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">'; // Hidden button BEFORE so it is the one used when we submit with ENTER. $ret .= '<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">'; // Hidden button BEFORE so it is the one used when we submit with ENTER.
$ret .= '<input type="submit" disabled name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' '.$name.' '.$name.'confirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; $ret .= '<input type="submit" disabled name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' '.$name.' '.$name.'confirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
$ret .= '</div>'; $ret .= '</div>';
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax))
@ -5591,15 +5591,15 @@ class Form
{ {
if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
//$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
if ($addnowlink == 1) if ($addnowlink == 1)
{ {
$reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
} elseif ($addnowlink == 2) } elseif ($addnowlink == 2)
{ {
$reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());';
$reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
} }
if ($fullday) $reset_scripts .= ' } '; if ($fullday) $reset_scripts .= ' } ';
} }
@ -5608,15 +5608,15 @@ class Form
{ {
if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
//$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
if ($addnowlink == 1) if ($addnowlink == 1)
{ {
$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');';
$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
} elseif ($addnowlink == 2) } elseif ($addnowlink == 2)
{ {
$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());';
$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
} }
if ($fullday) $reset_scripts .= ' } '; if ($fullday) $reset_scripts .= ' } ';
} }
// If reset_scripts is not empty, print the link with the reset_scripts in the onClick // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
@ -5684,20 +5684,20 @@ class Form
{ {
global $langs; global $langs;
$TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes'));
$retstring = '<select class="flat" id="select_'.$prefix.'type_duration" name="'.$prefix.'type_duration">'; $retstring = '<select class="flat" id="select_'.$prefix.'type_duration" name="'.$prefix.'type_duration">';
foreach ($TDurationTypes as $key=>$typeduration) { foreach ($TDurationTypes as $key=>$typeduration) {
$retstring .= '<option value="'.$key.'"'; $retstring .= '<option value="'.$key.'"';
if ($key == $selected) { if ($key == $selected) {
$retstring .= " selected"; $retstring .= " selected";
} }
$retstring .= ">".$typeduration."</option>"; $retstring .= ">".$typeduration."</option>";
} }
$retstring .= "</select>"; $retstring .= "</select>";
return $retstring; return $retstring;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
@ -6545,23 +6545,23 @@ class Form
foreach ($array as $key => $val) foreach ($array as $key => $val)
{ {
/* var_dump($val); /* var_dump($val);
var_dump(array_key_exists('enabled', $val)); var_dump(array_key_exists('enabled', $val));
var_dump(!$val['enabled']);*/ var_dump(!$val['enabled']);*/
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled'])
{ {
unset($array[$key]); // We don't want this field unset($array[$key]); // We don't want this field
continue; continue;
} }
if ($val['label']) if ($val['label'])
{ {
if (!empty($val['langfile']) && is_object($langs)) { if (!empty($val['langfile']) && is_object($langs)) {
$langs->load($val['langfile']); $langs->load($val['langfile']);
} }
$lis .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.(empty($val['checked']) ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>'; $lis .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.(empty($val['checked']) ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>';
$listcheckedstring .= (empty($val['checked']) ? '' : $key.','); $listcheckedstring .= (empty($val['checked']) ? '' : $key.',');
} }
} }
$out = '<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' --> $out = '<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' -->
@ -7542,16 +7542,16 @@ class Form
* *
* @param string $cssclass CSS class * @param string $cssclass CSS class
* @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes * @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes
* @param string $massactionname Mass action button name that will launch an action on the selected items * @param string $massactionname Mass action button name that will launch an action on the selected items
* @return string * @return string
*/ */
public function showCheckAddButtons($cssclass = 'checkforaction', $calljsfunction = 0, $massactionname = "massaction") public function showCheckAddButtons($cssclass = 'checkforaction', $calljsfunction = 0, $massactionname = "massaction")
{ {
global $conf, $langs; global $conf, $langs;
$out = ''; $out = '';
$id = uniqid(); $id = uniqid();
if (!empty($conf->use_javascript_ajax)) $out .= '<div class="inline-block checkallactions"><input type="checkbox" id="'.$cssclass.'s" name="'.$cssclass.'s" class="checkallactions"></div>'; if (!empty($conf->use_javascript_ajax)) $out .= '<div class="inline-block checkallactions"><input type="checkbox" id="'.$cssclass.'s" name="'.$cssclass.'s" class="checkallactions"></div>';
$out .= '<script> $out .= '<script>
$(document).ready(function() { $(document).ready(function() {
$("#' . $cssclass.'s").click(function() { $("#' . $cssclass.'s").click(function() {
@ -7564,7 +7564,7 @@ class Form
console.log("We uncheck all"); console.log("We uncheck all");
$(".'.$cssclass.'").prop(\'checked\', false).trigger(\'change\'); $(".'.$cssclass.'").prop(\'checked\', false).trigger(\'change\');
}'."\n"; }'."\n";
if ($calljsfunction) $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "'.$massactionname.'", "'.$cssclass.'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }'; if ($calljsfunction) $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "'.$massactionname.'", "'.$cssclass.'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
$out .= ' }); $out .= ' });
$(".' . $cssclass.'").change(function() { $(".' . $cssclass.'").change(function() {
@ -7606,9 +7606,10 @@ class Form
* @param string $target htmlname of target select to bind event * @param string $target htmlname of target select to bind event
* @param int $default_selected default category to select if fk_c_type_fees change = EX_KME * @param int $default_selected default category to select if fk_c_type_fees change = EX_KME
* @param array $params param to give * @param array $params param to give
* @param int $info_admin Show the tooltip help picto to setup list
* @return string * @return string
*/ */
public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array()) public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array(), $info_admin = 1)
{ {
global $db, $langs, $user; global $db, $langs, $user;
@ -7621,7 +7622,7 @@ class Form
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">'; $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp maxwidth200">';
if ($useempty) $out .= '<option value="0">&nbsp;</option>'; if ($useempty) $out .= '<option value="0">&nbsp;</option>';
while ($obj = $db->fetch_object($resql)) while ($obj = $db->fetch_object($resql))
@ -7629,7 +7630,9 @@ class Form
$out .= '<option '.($selected == $obj->rowid ? 'selected="selected"' : '').' value="'.$obj->rowid.'">'.$langs->trans($obj->label).'</option>'; $out .= '<option '.($selected == $obj->rowid ? 'selected="selected"' : '').' value="'.$obj->rowid.'">'.$langs->trans($obj->label).'</option>';
} }
$out .= '</select>'; $out .= '</select>';
if (!empty($htmlname) && $user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); $out .= ajax_combobox('select_'.$htmlname);
if (!empty($htmlname) && $user->admin && $info_admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if (!empty($target)) if (!empty($target))
{ {
@ -7980,34 +7983,34 @@ class Form
* @param int $default 1=Show also Default mail template * @param int $default 1=Show also Default mail template
* @return string HTML select string * @return string HTML select string
*/ */
public function selectModelMail($prefix, $modelType = '', $default = 0) public function selectModelMail($prefix, $modelType = '', $default = 0)
{ {
global $langs, $db, $user; global $langs, $db, $user;
$retstring = ''; $retstring = '';
$TModels = array(); $TModels = array();
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db); $formmail = new FormMail($db);
$result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
if ($default) $TModels[0] = $langs->trans('DefaultMailModel'); if ($default) $TModels[0] = $langs->trans('DefaultMailModel');
if ($result > 0) { if ($result > 0) {
foreach ($formmail->lines_model as $model){ foreach ($formmail->lines_model as $model){
$TModels[$model->id] = $model->label; $TModels[$model->id] = $model->label;
} }
} }
$retstring .= '<select class="flat" id="select_'.$prefix.'model_mail" name="'.$prefix.'model_mail">'; $retstring .= '<select class="flat" id="select_'.$prefix.'model_mail" name="'.$prefix.'model_mail">';
foreach ($TModels as $id_model=>$label_model){ foreach ($TModels as $id_model=>$label_model){
$retstring .= '<option value="'.$id_model.'"'; $retstring .= '<option value="'.$id_model.'"';
$retstring .= ">".$label_model."</option>"; $retstring .= ">".$label_model."</option>";
} }
$retstring .= "</select>"; $retstring .= "</select>";
return $retstring; return $retstring;
} }
} }

View File

@ -855,7 +855,7 @@ class FormMail extends Form
{ {
$out .= '<div id="attachfile_'.$key.'">'; $out .= '<div id="attachfile_'.$key.'">';
// Preview of attachment // Preview of attachment
preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT)-strlen($val))), $formfile_params); preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT) - strlen($val))), $formfile_params);
$out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; $out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
$out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]); $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
if (!$this->withfilereadonly) if (!$this->withfilereadonly)
@ -956,13 +956,13 @@ class FormMail extends Form
$atleastonecomponentishtml++; $atleastonecomponentishtml++;
} }
if ($atleastonecomponentishtml) { if ($atleastonecomponentishtml) {
if (! dol_textishtml($this->substit['__USER_SIGNATURE__'])) { if (!dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
$this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']); $this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']);
} }
if (! dol_textishtml($this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'])) { if (!dol_textishtml($this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'])) {
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = dol_nl2br($this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']); $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = dol_nl2br($this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']);
} }
if (! dol_textishtml($defaultmessage)) { if (!dol_textishtml($defaultmessage)) {
$defaultmessage = dol_nl2br($defaultmessage); $defaultmessage = dol_nl2br($defaultmessage);
} }
} }

View File

@ -986,12 +986,12 @@ class FormTicket
print '</td></tr>'; print '</td></tr>';
} }
// MESSAGE // MESSAGE
$defaultmessage=""; $defaultmessage="";
if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) { if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
$defaultmessage = $arraydefaultmessage->content; $defaultmessage = $arraydefaultmessage->content;
} }
$defaultmessage = str_replace('\n', "\n", $defaultmessage); $defaultmessage = str_replace('\n', "\n", $defaultmessage);
// Deal with format differences between message and signature (text / HTML) // Deal with format differences between message and signature (text / HTML)
if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) { if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) {

File diff suppressed because it is too large Load Diff

View File

@ -517,12 +517,21 @@ class Translate
if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as loaded if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as loaded
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Marque ce cas comme non trouve (no lines found for language) if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Mark this case as not found (no lines found for language)
return 1; return 1;
} }
/**
* Get information with result of loading data for domain
*
* @param string $domain Domain to check
* @return int 0, 1, 2...
*/
public function isLoaded($domain)
{
return $this->_tab_loaded[$domain];
}
/** /**
* Return translated value of key for special keys ("Currency...", "Civility...", ...). * Return translated value of key for special keys ("Currency...", "Civility...", ...).

View File

@ -173,75 +173,75 @@ function length_accounta($accounta)
*/ */
function journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '') function journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '')
{ {
global $langs; global $langs;
print "\n\n<!-- start banner journal -->\n"; print "\n\n<!-- start banner journal -->\n";
if (!is_empty($varlink)) $varlink = '?'.$varlink; if (!is_empty($varlink)) $varlink = '?'.$varlink;
$head = array(); $head = array();
$h = 0; $h = 0;
$head[$h][0] = $_SERVER["PHP_SELF"].$varlink; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
$head[$h][1] = $langs->trans("Journalization"); $head[$h][1] = $langs->trans("Journalization");
$head[$h][2] = 'journal'; $head[$h][2] = 'journal';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
dol_fiche_head($head, 'journal'); dol_fiche_head($head, 'journal');
foreach ($moreparam as $key => $value) foreach ($moreparam as $key => $value)
{ {
print '<input type="hidden" name="'.$key.'" value="'.$value.'">'; print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
} }
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
// Ligne de titre // Ligne de titre
print '<tr>'; print '<tr>';
print '<td width="110">'.$langs->trans("Name").'</td>'; print '<td width="110">'.$langs->trans("Name").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
print $nom; print $nom;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Calculation mode // Calculation mode
if ($calcmode) if ($calcmode)
{ {
print '<tr>'; print '<tr>';
print '<td width="110">'.$langs->trans("CalculationMode").'</td>'; print '<td width="110">'.$langs->trans("CalculationMode").'</td>';
if (!$variante) print '<td colspan="3">'; if (!$variante) print '<td colspan="3">';
else print '<td>'; else print '<td>';
print $calcmode; print $calcmode;
if ($variante) print '</td><td colspan="2">'.$variante; if ($variante) print '</td><td colspan="2">'.$variante;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Ligne de la periode d'analyse du rapport // Ligne de la periode d'analyse du rapport
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("ReportPeriod").'</td>'; print '<td>'.$langs->trans("ReportPeriod").'</td>';
if (!$periodlink) print '<td colspan="3">'; if (!$periodlink) print '<td colspan="3">';
else print '<td>'; else print '<td>';
if ($period) print $period; if ($period) print $period;
if ($periodlink) print '</td><td colspan="2">'.$periodlink; if ($periodlink) print '</td><td colspan="2">'.$periodlink;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Ligne de description // Ligne de description
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("ReportDescription").'</td>'; print '<td>'.$langs->trans("ReportDescription").'</td>';
print '<td colspan="3">'.$description.'</td>'; print '<td colspan="3">'.$description.'</td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>'; print '<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>';
print '</form>'; print '</form>';
print "\n<!-- end banner journal -->\n\n"; print "\n<!-- end banner journal -->\n\n";
} }
/** /**
@ -255,7 +255,7 @@ function getDefaultDatesForTransfer()
// Period by default on transfer (0: previous month | 1: current month | 2: fiscal year) // Period by default on transfer (0: previous month | 1: current month | 2: fiscal year)
$periodbydefaultontransfer = $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER; $periodbydefaultontransfer = $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER;
isset($periodbydefaultontransfer)?$periodbydefaultontransfer:0; isset($periodbydefaultontransfer) ? $periodbydefaultontransfer : 0;
if ($periodbydefaultontransfer == 2) { if ($periodbydefaultontransfer == 2) {
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
@ -284,15 +284,15 @@ function getDefaultDatesForTransfer()
$pastmonthyear = $year_current; $pastmonthyear = $year_current;
if ($pastmonth == 0) { if ($pastmonth == 0) {
$pastmonth = 12; $pastmonth = 12;
$pastmonthyear --; $pastmonthyear--;
} }
} else { } else {
$year_current = strftime("%Y", dol_now()); $year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now())-1; $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current; $pastmonthyear = $year_current;
if ($pastmonth == 0) { if ($pastmonth == 0) {
$pastmonth = 12; $pastmonth = 12;
$pastmonthyear --; $pastmonthyear--;
} }
} }

View File

@ -1402,32 +1402,32 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
} }
} }
if (! empty($search_start) && ! empty($search_end)) { if (!empty($search_start) && !empty($search_end)) {
$sql .= " AND ((a.datep BETWEEN '$search_start' AND '$search_end') OR (a.datep2 BETWEEN '$search_start' AND '$search_end'))"; $sql .= " AND ((a.datep BETWEEN '$search_start' AND '$search_end') OR (a.datep2 BETWEEN '$search_start' AND '$search_end'))";
} }
elseif (empty($search_start) && ! empty($search_end)) { elseif (empty($search_start) && !empty($search_end)) {
$sql .= " AND ((a.datep <= '$search_end') OR (a.datep2 <= '$search_end'))"; $sql .= " AND ((a.datep <= '$search_end') OR (a.datep2 <= '$search_end'))";
} }
elseif (! empty($search_start) && empty($search_end)) { elseif (!empty($search_start) && empty($search_end)) {
$sql .= " AND ((a.datep >= '$search_start') OR (a.datep2 >= '$search_start'))"; $sql .= " AND ((a.datep >= '$search_start') OR (a.datep2 >= '$search_start'))";
} }
if (is_array($actioncode) && ! empty($actioncode)) { if (is_array($actioncode) && !empty($actioncode)) {
$sql .= ' AND ('; $sql .= ' AND (';
foreach ($actioncode as $key => $code) { foreach ($actioncode as $key => $code) {
if ($key != 0) $sql .= "OR ("; if ($key != 0) $sql .= "OR (";
if (! empty($code)) addEventTypeSQL($sql, $code, $donetodo, $now, $filters, ""); if (!empty($code)) addEventTypeSQL($sql, $code, $donetodo, $now, $filters, "");
if ($key != 0) $sql .= ")"; if ($key != 0) $sql .= ")";
} }
$sql .= ')'; $sql .= ')';
} }
elseif (! empty($actioncode)) addEventTypeSQL($sql, $actioncode, $donetodo, $now, $filters); elseif (!empty($actioncode)) addEventTypeSQL($sql, $actioncode, $donetodo, $now, $filters);
if (is_array($actioncode)) { if (is_array($actioncode)) {
foreach ($actioncode as $code) { foreach ($actioncode as $code) {
$sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj); $sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj);
if (! empty($sql2)) { if (!empty($sql2)) {
if (! empty($sql)) $sql = $sql." UNION ".$sql2; if (!empty($sql)) $sql = $sql." UNION ".$sql2;
elseif (empty($sql)) $sql = $sql2; elseif (empty($sql)) $sql = $sql2;
break; break;
} }
@ -1435,10 +1435,10 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
} }
else { else {
$sql2 = addMailingEventTypeSQL($actioncode, $objcon, $filterobj); $sql2 = addMailingEventTypeSQL($actioncode, $objcon, $filterobj);
if (! empty($sql) && ! empty($sql2)) { if (!empty($sql) && !empty($sql2)) {
$sql = $sql." UNION ".$sql2; $sql = $sql." UNION ".$sql2;
} }
elseif (empty($sql) && ! empty($sql2)) { elseif (empty($sql) && !empty($sql2)) {
$sql = $sql2; $sql = $sql2;
} }
} }
@ -1671,7 +1671,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$labeltype = $langs->trans("Message"); $labeltype = $langs->trans("Message");
} else { } else {
if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype];
if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code
} }
$out .= dol_trunc($labeltype, 28); $out .= dol_trunc($labeltype, 28);
$out .= '</td>'; $out .= '</td>';

View File

@ -615,23 +615,6 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '',
$mois = date("m", $timestampStart); $mois = date("m", $timestampStart);
$annee = date("Y", $timestampStart); $annee = date("Y", $timestampStart);
// Check into var $conf->global->HOLIDAY_MORE_DAYS MM-DD,YYYY-MM-DD, ...
// Do not use this anymore, use instead the dictionary of public holidays.
if (!empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS))
{
$arrayofdaystring = explode(',', $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS);
foreach ($arrayofdaystring as $daystring)
{
$tmp = explode('-', $daystring);
if ($tmp[2])
{
if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie = true;
} else {
if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie = true;
}
}
}
$country_id = dol_getIdFromCode($db, $country_code, 'c_country', 'code', 'rowid'); $country_id = dol_getIdFromCode($db, $country_code, 'c_country', 'code', 'rowid');
// Loop on public holiday defined into hrm_public_holiday // Loop on public holiday defined into hrm_public_holiday

View File

@ -133,14 +133,6 @@ function expensereport_admin_prepare_head()
$head[$h][2] = 'expensereport'; $head[$h][2] = 'expensereport';
$h++; $h++;
if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
{
$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
$head[$h][1] = $langs->trans("ExpenseReportsIk");
$head[$h][2] = 'expenseik';
$h++;
}
if (!empty($conf->global->MAIN_USE_EXPENSE_RULE)) if (!empty($conf->global->MAIN_USE_EXPENSE_RULE))
{ {
$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php"; $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
@ -149,6 +141,14 @@ function expensereport_admin_prepare_head()
$h++; $h++;
} }
if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
{
$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
$head[$h][1] = $langs->trans("ExpenseReportsIk");
$head[$h][2] = 'expenseik';
$h++;
}
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab

View File

@ -1063,10 +1063,10 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
if (empty($conf->syslog->enabled)) return; if (empty($conf->syslog->enabled)) return;
// Check if we are into execution of code of a website // Check if we are into execution of code of a website
if (defined('USEEXTERNALSERVER') && ! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { if (defined('USEEXTERNALSERVER') && !defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) {
global $website, $websitekey; global $website, $websitekey;
if (is_object($website) && ! empty($website->ref)) $suffixinfilename.='_website_'.$website->ref; if (is_object($website) && !empty($website->ref)) $suffixinfilename .= '_website_'.$website->ref;
elseif (! empty($websitekey)) $suffixinfilename.='_website_'.$websitekey; elseif (!empty($websitekey)) $suffixinfilename .= '_website_'.$websitekey;
} }
if ($ident < 0) if ($ident < 0)
@ -5912,7 +5912,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
// Add SIGNATURE into substitutionarray first, so, when we will make the substitution, // Add SIGNATURE into substitutionarray first, so, when we will make the substitution,
// this will include signature content first and then replace var found into content of signature // this will include signature content first and then replace var found into content of signature
$signature = $user->signature; $signature = $user->signature;
$substitutionarray = array_merge($substitutionarray, array( $substitutionarray = array_merge($substitutionarray, array(
'__USER_SIGNATURE__' => (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '') '__USER_SIGNATURE__' => (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '')
) )
); );
@ -6184,16 +6184,16 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
$substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key]; $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key];
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { if ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') {
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = dol_print_date($object->array_options['options_' . $key], 'day'); $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = dol_print_date($object->array_options['options_' . $key], 'day');
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_LOCALE__'] = dol_print_date($object->array_options['options_' . $key], 'day', 'tzserver', $outputlangs); $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_LOCALE__'] = dol_print_date($object->array_options['options_' . $key], 'day', 'tzserver', $outputlangs);
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_RFC__'] = dol_print_date($object->array_options['options_' . $key], 'dayrfc'); $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_RFC__'] = dol_print_date($object->array_options['options_' . $key], 'dayrfc');
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'datetime') { } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'datetime') {
$datetime = $object->array_options['options_'.$key]; $datetime = $object->array_options['options_'.$key];
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour') : ''); $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour') : '');
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour', 'tzserver', $outputlangs) : ''); $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour', 'tzserver', $outputlangs) : '');
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_DAY_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'day', 'tzserver', $outputlangs) : ''); $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_DAY_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'day', 'tzserver', $outputlangs) : '');
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_RFC__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : ''); $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_RFC__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : '');
} }
} }
} }
} }
@ -6239,12 +6239,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && $object->element == 'facture') $substitutionarray['__URL_INVOICE__'] = DOL_MAIN_URL_ROOT."/compta/facture/card.php?id=".$object->id; if (is_object($object) && $object->element == 'facture') $substitutionarray['__URL_INVOICE__'] = DOL_MAIN_URL_ROOT."/compta/facture/card.php?id=".$object->id;
} }
if (is_object($object) && $object->element == 'action') if (is_object($object) && $object->element == 'action')
{ {
$substitutionarray['__EVENT_LABEL__'] = $object->label; $substitutionarray['__EVENT_LABEL__'] = $object->label;
$substitutionarray['__EVENT_DATE__'] = dol_print_date($object->datep, '%A %d %b %Y'); $substitutionarray['__EVENT_DATE__'] = dol_print_date($object->datep, '%A %d %b %Y');
$substitutionarray['__EVENT_TIME__'] = dol_print_date($object->datep, '%H:%M:%S'); $substitutionarray['__EVENT_TIME__'] = dol_print_date($object->datep, '%H:%M:%S');
} }
} }
} }
if (empty($exclude) || !in_array('objectamount', $exclude)) if (empty($exclude) || !in_array('objectamount', $exclude))

View File

@ -41,8 +41,8 @@ function image_format_supported($file, $acceptsvg = 0)
global $conf; global $conf;
$regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php
if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) { if ($acceptsvg || !empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
$regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript $regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript
} }
// Case filename is not a format image // Case filename is not a format image

View File

@ -206,54 +206,54 @@ function generate_random_id($car = 16)
*/ */
function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '') function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
{ {
global $user, $conf, $langs, $mysoc; global $user, $conf, $langs, $mysoc;
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
print '<body id="mainbody" class="publicnewticketform">'; print '<body id="mainbody" class="publicnewticketform">';
print '<div class="center">'; print '<div class="center">';
// Define urllogo // Define urllogo
if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) {
// Print logo // Print logo
if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO))
{ {
$urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small); $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$mysoc->logo); $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$mysoc->logo);
} elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) { } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
$urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg'; $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
} }
} }
} }
// Output html code for logo // Output html code for logo
if ($urllogo || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) if ($urllogo || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC))
{ {
print '<div class="backgreypublicpayment">'; print '<div class="backgreypublicpayment">';
print '<div class="logopublicpayment">'; print '<div class="logopublicpayment">';
if ($urllogo) { if ($urllogo) {
print '<a href="'.($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)).'">'; print '<a href="'.($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)).'">';
print '<img id="dolpaymentlogo" src="'.$urllogo.'"'; print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
print '>'; print '>';
print '</a>'; print '</a>';
} }
if (!empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { if (!empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) {
print '<div class="clearboth"></div><strong>'.($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")).'</strong>'; print '<div class="clearboth"></div><strong>'.($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")).'</strong>';
} }
print '</div>'; print '</div>';
if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
print '<div class="poweredbypublicpayment opacitymedium right"><a href="https://www.dolibarr.org" target="dolibarr">'.$langs->trans("PoweredBy").'<br><img src="'.DOL_URL_ROOT.'/theme/dolibarr_logo.svg" width="80px"></a></div>'; print '<div class="poweredbypublicpayment opacitymedium right"><a href="https://www.dolibarr.org" target="dolibarr">'.$langs->trans("PoweredBy").'<br><img src="'.DOL_URL_ROOT.'/theme/dolibarr_logo.svg" width="80px"></a></div>';
} }
print '</div>'; print '</div>';
} }
print '</div>'; print '</div>';
print '<div class="ticketlargemargin">'; print '<div class="ticketlargemargin">';
} }

View File

@ -385,16 +385,16 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t
$nature = ''; $nature = '';
// Must match array $sourceList defined into journals_list.php // Must match array $sourceList defined into journals_list.php
if ($objp->nature == 2 && ! empty($conf->facture->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) $nature="sells"; if ($objp->nature == 2 && !empty($conf->facture->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) $nature = "sells";
if ($objp->nature == 3 if ($objp->nature == 3
&& (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled))
&& empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES))
$nature = "purchases"; $nature = "purchases";
if ($objp->nature == 4 && ! empty($conf->banque->enabled)) $nature="bank"; if ($objp->nature == 4 && !empty($conf->banque->enabled)) $nature = "bank";
if ($objp->nature == 5 && ! empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) $nature="expensereports"; if ($objp->nature == 5 && !empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) $nature = "expensereports";
if ($objp->nature == 1) $nature="various"; if ($objp->nature == 1) $nature = "various";
if ($objp->nature == 8) $nature="inventory"; if ($objp->nature == 8) $nature = "inventory";
if ($objp->nature == 9) $nature="hasnew"; if ($objp->nature == 9) $nature = "hasnew";
// To enable when page exists // To enable when page exists
if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL))

View File

@ -1087,94 +1087,88 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
} }
// Taxes and social contributions // Taxes and social contributions
if (!empty($conf->tax->enabled) || !empty($conf->salaries->enabled) || !empty($conf->loan->enabled) || !empty($conf->banque->enabled)) if (!empty($conf->tax->enabled))
{ {
global $mysoc; $newmenu->add("/compta/charges/index.php?leftmenu=tax&amp;mainmenu=billing", $langs->trans("MenuTaxesAndSpecialExpenses"), 0, $user->rights->tax->charges->lire, '', $mainmenu, 'tax');
$permtoshowmenu = ((!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) || (!empty($conf->loan->enabled) && $user->rights->loan->read) || (!empty($conf->banque->enabled) && $user->rights->banque->lire)); $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->rights->tax->charges->lire);
$newmenu->add("/compta/charges/index.php?leftmenu=tax&amp;mainmenu=billing", $langs->trans("MenuTaxesAndSpecialExpenses"), 0, $permtoshowmenu, '', $mainmenu, 'tax'); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i', $leftmenu)) {
$newmenu->add("/compta/sociales/card.php?leftmenu=tax_social&action=create", $langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer);
// Social contributions $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
if (!empty($conf->tax->enabled)) $newmenu->add("/compta/sociales/payments.php?leftmenu=tax_social&amp;mainmenu=billing&amp;mode=sconly", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire);
}
// VAT
if (empty($conf->global->TAX_DISABLE_VAT_MENUS))
{ {
$newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->rights->tax->charges->lire); global $mysoc;
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i', $leftmenu)) {
$newmenu->add("/compta/sociales/card.php?leftmenu=tax_social&action=create", $langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer); $newmenu->add("/compta/tva/list.php?leftmenu=tax_vat&amp;mainmenu=billing", $langs->transcountry("VAT", $mysoc->country_code), 1, $user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat');
$newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("List"), 2, $user->rights->tax->charges->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) {
$newmenu->add("/compta/sociales/payments.php?leftmenu=tax_social&amp;mainmenu=billing&amp;mode=sconly", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
$newmenu->add("/compta/tva/list.php?leftmenu=tax_vat", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/index.php?leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
} }
// VAT
if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) //Local Taxes 1
if ($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj == "1"))
{ {
$newmenu->add("/compta/tva/list.php?leftmenu=tax_vat&amp;mainmenu=billing", $langs->transcountry("VAT", $mysoc->country_code), 1, $user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat'); $newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&amp;mainmenu=billing&amp;localTaxType=1", $langs->transcountry("LT1", $mysoc->country_code), 1, $user->rights->tax->charges->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_1_vat/i', $leftmenu)) {
$newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->rights->tax->charges->creer); $newmenu->add("/compta/localtax/card.php?leftmenu=tax_1_vat&action=create&amp;localTaxType=1", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
$newmenu->add("/compta/tva/list.php?leftmenu=tax_vat", $langs->trans("List"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/index.php?leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/index.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
} }
global $mysoc; }
//Local Taxes 2
//Local Taxes 1 if ($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj == "1"))
if ($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj == "1")) {
{ $newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&amp;mainmenu=billing&amp;localTaxType=2", $langs->transcountry("LT2", $mysoc->country_code), 1, $user->rights->tax->charges->lire);
$newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&amp;mainmenu=billing&amp;localTaxType=1", $langs->transcountry("LT1", $mysoc->country_code), 1, $user->rights->tax->charges->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_2_vat/i', $leftmenu)) {
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_1_vat/i', $leftmenu)) { $newmenu->add("/compta/localtax/card.php?leftmenu=tax_2_vat&action=create&amp;localTaxType=2", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
$newmenu->add("/compta/localtax/card.php?leftmenu=tax_1_vat&action=create&amp;localTaxType=1", $langs->trans("New"), 2, $user->rights->tax->charges->creer); $newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("List"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/index.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/localtax/index.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/localtax/clients.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
}
}
//Local Taxes 2
if ($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj == "1"))
{
$newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&amp;mainmenu=billing&amp;localTaxType=2", $langs->transcountry("LT2", $mysoc->country_code), 1, $user->rights->tax->charges->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_2_vat/i', $leftmenu)) {
$newmenu->add("/compta/localtax/card.php?leftmenu=tax_2_vat&action=create&amp;localTaxType=2", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
$newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/localtax/index.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/localtax/clients.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
}
} }
} }
} }
}
// Salaries // Salaries
if (!empty($conf->salaries->enabled)) if (!empty($conf->salaries->enabled))
{ {
$langs->load("salaries"); $langs->load("salaries");
$newmenu->add("/salaries/list.php?leftmenu=tax_salary&amp;mainmenu=billing", $langs->trans("Salaries"), 0, $user->rights->salaries->read, '', $mainmenu, 'tax_salary'); $newmenu->add("/salaries/list.php?leftmenu=tax_salary&amp;mainmenu=billing", $langs->trans("Salaries"), 0, $user->rights->salaries->read, '', $mainmenu, 'tax_salary');
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) {
$newmenu->add("/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("NewPayment"), 1, $user->rights->salaries->write); $newmenu->add("/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("NewPayment"), 1, $user->rights->salaries->write);
$newmenu->add("/salaries/list.php?leftmenu=tax_salary", $langs->trans("Payments"), 1, $user->rights->salaries->read); $newmenu->add("/salaries/list.php?leftmenu=tax_salary", $langs->trans("Payments"), 1, $user->rights->salaries->read);
$newmenu->add("/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 1, $user->rights->salaries->read); $newmenu->add("/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 1, $user->rights->salaries->read);
}
} }
}
// Loan // Loan
if (!empty($conf->loan->enabled)) if (!empty($conf->loan->enabled))
{ {
$langs->load("loan"); $langs->load("loan");
$newmenu->add("/loan/list.php?leftmenu=tax_loan&amp;mainmenu=billing", $langs->trans("Loans"), 0, $user->rights->loan->read, '', $mainmenu, 'tax_loan'); $newmenu->add("/loan/list.php?leftmenu=tax_loan&amp;mainmenu=billing", $langs->trans("Loans"), 0, $user->rights->loan->read, '', $mainmenu, 'tax_loan');
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) {
$newmenu->add("/loan/card.php?leftmenu=tax_loan&action=create", $langs->trans("NewLoan"), 1, $user->rights->loan->write); $newmenu->add("/loan/card.php?leftmenu=tax_loan&action=create", $langs->trans("NewLoan"), 1, $user->rights->loan->write);
//$newmenu->add("/loan/payment/list.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read); //$newmenu->add("/loan/payment/list.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read);
}
} }
}
// Various payment // Various payment
if (!empty($conf->banque->enabled) && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) if (!empty($conf->banque->enabled) && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT))
{ {
$langs->load("banks"); $langs->load("banks");
$newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various&amp;mainmenu=billing", $langs->trans("MenuVariousPayment"), 0, $user->rights->banque->lire, '', $mainmenu, 'tax_various'); $newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various&amp;mainmenu=billing", $langs->trans("MenuVariousPayment"), 0, $user->rights->banque->lire, '', $mainmenu, 'tax_various');
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_various/i', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_various/i', $leftmenu)) {
$newmenu->add("/compta/bank/various_payment/card.php?leftmenu=tax_various&action=create", $langs->trans("New"), 1, $user->rights->banque->modifier); $newmenu->add("/compta/bank/various_payment/card.php?leftmenu=tax_various&action=create", $langs->trans("New"), 1, $user->rights->banque->modifier);
$newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various", $langs->trans("List"), 1, $user->rights->banque->lire); $newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various", $langs->trans("List"), 1, $user->rights->banque->lire);
}
} }
} }
} }
@ -1226,35 +1220,35 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 130); $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 130);
} }
// Transfer in accounting // Transfer in accounting
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1); $newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1);
// Binding // Binding
// $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch'); // $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch');
if (!empty($conf->facture->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) if (!empty($conf->facture->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES))
{ {
$newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&amp;mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&amp;mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer');
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) {
$newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
$newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
} }
} }
if (!empty($conf->supplier_invoice->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) if (!empty($conf->supplier_invoice->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES))
{ {
$newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&amp;mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier'); $newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&amp;mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier');
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) {
$newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
$newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
} }
} }
if (!empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) if (!empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS))
{ {
$newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&amp;mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport'); $newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&amp;mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport');
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) {
$newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
$newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); $newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
} }
} }
// Journals // Journals
if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy')
@ -1450,8 +1444,8 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); $newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type');
if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/', $leftmenu)) {
$newmenu->add("/asset/type.php?leftmenu=asset_type&amp;action=create", $langs->trans("MenuNewTypeAssets"), 2, (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->setup_advance)); $newmenu->add("/asset/type.php?leftmenu=asset_type&amp;action=create", $langs->trans("MenuNewTypeAssets"), 2, (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->setup_advance));
$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read); $newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read);
} }
} }
} }
@ -1481,7 +1475,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
{ {
$langs->load("categories"); $langs->load("categories");
$newmenu->add("/categories/index.php?type=5", $langs->trans("Rubriques"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags'); $newmenu->add("/categories/index.php?type=5", $langs->trans("Rubriques"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags');
$newmenu->add("/compta/bank/categ.php", $langs->trans("RubriquesTransactions"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags'); $newmenu->add("/compta/bank/categ.php", $langs->trans("RubriquesTransactions"), 1, $user->rights->banque->configurer, '', $mainmenu, 'tags');
} }
// Direct debit order // Direct debit order

File diff suppressed because it is too large Load Diff

View File

@ -349,57 +349,57 @@ class pdf_standard extends ModeleExpenseReport
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
// Loop on each lines // Loop on each lines
$i = 0; $i = 0;
while ($i < $nblines) { while ($i < $nblines) {
$pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
if (empty($showpricebeforepagebreak) && ($i !== ($nblines - 1))) { if (empty($showpricebeforepagebreak) && ($i !== ($nblines - 1))) {
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
} else { } else {
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
} }
$pageposbefore = $pdf->getPage(); $pageposbefore = $pdf->getPage();
$curY = $nexY; $curY = $nexY;
$pdf->startTransaction(); $pdf->startTransaction();
$this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) { if ($pageposafter > $pageposbefore) {
// There is a pagebreak // There is a pagebreak
$pdf->rollbackTransaction(true); $pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore; $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit; //print $pageposafter.'-'.$pageposbefore;exit;
if (empty($showpricebeforepagebreak)) { if (empty($showpricebeforepagebreak)) {
$pdf->AddPage('', '', true); $pdf->AddPage('', '', true);
if (!empty($tplidx)) { if (!empty($tplidx)) {
$pdf->useTemplate($tplidx); $pdf->useTemplate($tplidx);
} }
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs); $this->_pagehead($pdf, $object, 0, $outputlangs);
} }
$pdf->setPage($pageposafter + 1); $pdf->setPage($pageposafter + 1);
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
$nexY = $tab_top_newpage; $nexY = $tab_top_newpage;
$nexY += ($pdf->getFontSize() * 1.3); // Add space between lines $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
$pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
continue; continue;
} else { } else {
$pdf->setPageOrientation('', 1, $heightforfooter); $pdf->setPageOrientation('', 1, $heightforfooter);
$showpricebeforepagebreak = 0; $showpricebeforepagebreak = 0;
} }
$this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY(); $posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
// There is no space left for total+free text // There is no space left for total+free text
if ($i == ($nblines - 1)) { if ($i == ($nblines - 1)) {
// No more lines, and no space left to show total, so we create a new page // No more lines, and no space left to show total, so we create a new page
$pdf->AddPage('', '', true); $pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);

View File

@ -251,6 +251,11 @@ class pdf_standard extends CommonStickerGenerator
{ {
if ($object->country == '-') $object->country = ''; if ($object->country == '-') $object->country = '';
$now = dol_now();
$year = dol_print_date($now, '%Y');
$month = dol_print_date($now, '%m');
$day = dol_print_date($now, '%d');
// List of values to scan for a replacement // List of values to scan for a replacement
$substitutionarray = array( $substitutionarray = array(
'__ID__' => $object->id, '__ID__' => $object->id,

View File

@ -426,13 +426,13 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
$prefillDates = false; $prefillDates = false;
if (!empty($conf->global->MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE) && ! empty($object->lines)) if (!empty($conf->global->MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE) && !empty($object->lines))
{ {
for ($i = count($object->lines) - 1; $i >= 0; $i--) for ($i = count($object->lines) - 1; $i >= 0; $i--)
{ {
$lastline = $object->lines[$i]; $lastline = $object->lines[$i];
if ($lastline->product_type == Product::TYPE_SERVICE && (! empty($lastline->date_start) || ! empty($lastline->date_end))) if ($lastline->product_type == Product::TYPE_SERVICE && (!empty($lastline->date_start) || !empty($lastline->date_end)))
{ {
$date_start_prefill = $lastline->date_start; $date_start_prefill = $lastline->date_start;
$date_end_prefill = $lastline->date_end; $date_end_prefill = $lastline->date_end;
@ -459,7 +459,7 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
if ($prefillDates) if ($prefillDates)
{ {
echo ' <span class="small"><a href="#" id="prefill_service_dates">' . $langs->trans('FillWithLastServiceDates') . '</a></span>'; echo ' <span class="small"><a href="#" id="prefill_service_dates">'.$langs->trans('FillWithLastServiceDates').'</a></span>';
} }
print '<script>'; print '<script>';

View File

@ -756,64 +756,64 @@ class InterfaceActionsAuto extends DolibarrTriggers
$object->sendtoid = 0; $object->sendtoid = 0;
} elseif ($action == 'TICKET_ASSIGNED') } elseif ($action == 'TICKET_ASSIGNED')
{ {
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("agenda", "other", "projects")); $langs->loadLangs(array("agenda", "other", "projects"));
if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
$object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); $object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
if ($object->oldcopy->fk_user_assign > 0) if ($object->oldcopy->fk_user_assign > 0)
{ {
$tmpuser = new User($this->db); $tmpuser = new User($this->db);
$tmpuser->fetch($object->oldcopy->fk_user_assign); $tmpuser->fetch($object->oldcopy->fk_user_assign);
$object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs); $object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs);
} else { } else {
$object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$langs->trans("None"); $object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$langs->trans("None");
} }
if ($object->fk_user_assign > 0) if ($object->fk_user_assign > 0)
{ {
$tmpuser = new User($this->db); $tmpuser = new User($this->db);
$tmpuser->fetch($object->fk_user_assign); $tmpuser->fetch($object->fk_user_assign);
$object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$tmpuser->getFullName($langs); $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$tmpuser->getFullName($langs);
} else { } else {
$object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$langs->trans("None"); $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$langs->trans("None");
} }
$object->sendtoid = 0; $object->sendtoid = 0;
} }
// TODO Merge all previous cases into this generic one // TODO Merge all previous cases into this generic one
else // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ... else // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ...
{ {
// Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function).
// Note that these key can be set in agenda setup, only if defined into c_action_trigger // Note that these key can be set in agenda setup, only if defined into c_action_trigger
// Load translation files required by the page // Load translation files required by the page
if (empty($object->actionmsg2)) { if (empty($object->actionmsg2)) {
$langs->loadLangs(array("agenda", "other")); $langs->loadLangs(array("agenda", "other"));
if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key
$object->actionmsg2 = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref));
} else { // generic translation key } else { // generic translation key
$tmp = explode('_', $action); $tmp = explode('_', $action);
$object->actionmsg2 = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref));
} }
} }
if (empty($object->actionmsg)) { if (empty($object->actionmsg)) {
$langs->loadLangs(array("agenda", "other")); $langs->loadLangs(array("agenda", "other"));
if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key
$object->actionmsg = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->actionmsg = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref));
} else { // generic translation key } else { // generic translation key
$tmp = explode('_', $action); $tmp = explode('_', $action);
$object->actionmsg = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->actionmsg = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref));
} }
} }
if (!isset($object->sendtoid) || !is_array($object->sendtoid)) { if (!isset($object->sendtoid) || !is_array($object->sendtoid)) {
$object->sendtoid = 0; $object->sendtoid = 0;
} }
} }
$object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg; $object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg;
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
// Add entry in event table // Add entry in event table
$now = dol_now(); $now = dol_now();
if (isset($_SESSION['listofnames-'.$object->trackid])) if (isset($_SESSION['listofnames-'.$object->trackid]))
@ -821,37 +821,37 @@ class InterfaceActionsAuto extends DolibarrTriggers
$attachs = $_SESSION['listofnames-'.$object->trackid]; $attachs = $_SESSION['listofnames-'.$object->trackid];
if ($attachs && strpos($action, 'SENTBYMAIL')) if ($attachs && strpos($action, 'SENTBYMAIL'))
{ {
$object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs); $object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
} }
} }
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$contactforaction = new Contact($this->db); $contactforaction = new Contact($this->db);
$societeforaction = new Societe($this->db); $societeforaction = new Societe($this->db);
// Set contactforaction if there is only 1 contact. // Set contactforaction if there is only 1 contact.
if (is_array($object->sendtoid)) if (is_array($object->sendtoid))
{ {
if (count($object->sendtoid) == 1) $contactforaction->fetch(reset($object->sendtoid)); if (count($object->sendtoid) == 1) $contactforaction->fetch(reset($object->sendtoid));
} else { } else {
if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid); if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid);
} }
// Set societeforaction. // Set societeforaction.
if ($object->socid > 0) $societeforaction->fetch($object->socid); if ($object->socid > 0) $societeforaction->fetch($object->socid);
elseif ($object->fk_soc > 0) $societeforaction->fetch($object->fk_soc); elseif ($object->fk_soc > 0) $societeforaction->fetch($object->fk_soc);
$projectid = isset($object->fk_project) ? $object->fk_project : 0; $projectid = isset($object->fk_project) ? $object->fk_project : 0;
if ($object->element == 'project') $projectid = $object->id; if ($object->element == 'project') $projectid = $object->id;
$elementid = $object->id; // id of object $elementid = $object->id; // id of object
$elementtype = $object->element; $elementtype = $object->element;
$elementmodule = $object->module; $elementmodule = $object->module;
if ($object->element == 'subscription') if ($object->element == 'subscription')
{ {
$elementid = $object->fk_adherent; $elementid = $object->fk_adherent;
$elementtype = 'member'; $elementtype = 'member';
} }
//var_dump($societeforaction);var_dump($contactforaction);var_dump($elementid);var_dump($elementtype);exit; //var_dump($societeforaction);var_dump($contactforaction);var_dump($elementid);var_dump($elementtype);exit;
// Insertion action // Insertion action
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';

View File

@ -197,9 +197,9 @@ class InterfaceTicketEmail extends DolibarrTriggers
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin'); $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
$message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id).'<br><br>'; $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id).'<br><br>';
$message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>'; $message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_admin .= '<li>' . $langs->trans('Type') . ' : ' . $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code) . '</li>'; $message_admin .= '<li>'.$langs->trans('Type').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'</li>';
$message_admin .= '<li>' . $langs->trans('Category') . ' : ' . $langs->getLabelFromKey($this->db, 'TicketCategoryShort' . $object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code) . '</li>'; $message_admin .= '<li>'.$langs->trans('Category').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
$message_admin .= '<li>' . $langs->trans('Severity') . ' : ' . $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code) . '</li>'; $message_admin .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
$message_admin .= '<li>'.$langs->trans('From').' : '.($object->email_from ? $object->email_from : ($object->fk_user_create > 0 ? $langs->trans('Internal') : '')).'</li>'; $message_admin .= '<li>'.$langs->trans('From').' : '.($object->email_from ? $object->email_from : ($object->fk_user_create > 0 ? $langs->trans('Internal') : '')).'</li>';
// Extrafields // Extrafields
$extraFields = new ExtraFields($this->db); $extraFields = new ExtraFields($this->db);
@ -207,7 +207,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
if (is_array($object->array_options) && count($object->array_options) > 0) { if (is_array($object->array_options) && count($object->array_options) > 0) {
foreach ($object->array_options as $key => $value) { foreach ($object->array_options as $key => $value) {
$key = substr($key, 8); // remove "options_" $key = substr($key, 8); // remove "options_"
$message_admin .= '<li>' . $langs->trans($extraFields->attributes[$object->element]['label'][$key]) . ' : ' . $extraFields->showOutputField($key, $value) . '</li>'; $message_admin .= '<li>'.$langs->trans($extraFields->attributes[$object->element]['label'][$key]).' : '.$extraFields->showOutputField($key, $value).'</li>';
} }
} }
$message_admin .= '</ul>'; $message_admin .= '</ul>';
@ -267,9 +267,9 @@ class InterfaceTicketEmail extends DolibarrTriggers
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer'); $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
$message_customer = $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id).'<br><br>'; $message_customer = $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id).'<br><br>';
$message_customer .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>'; $message_customer .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_customer .= '<li>' . $langs->trans('Type') . ' : ' . $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code) . '</li>'; $message_customer .= '<li>'.$langs->trans('Type').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'</li>';
$message_customer .= '<li>' . $langs->trans('Category') . ' : ' . $langs->getLabelFromKey($this->db, 'TicketCategoryShort' . $object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code) . '</li>'; $message_customer .= '<li>'.$langs->trans('Category').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
$message_customer .= '<li>' . $langs->trans('Severity') . ' : ' . $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code) . '</li>'; $message_customer .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
// Extrafields // Extrafields
foreach ($this->attributes[$object->table_element]['label'] as $key => $value) foreach ($this->attributes[$object->table_element]['label'] as $key => $value)

View File

@ -51,10 +51,10 @@ class DolibarrDebugBar extends DebugBar
*/ */
public function getRenderer() public function getRenderer()
{ {
$renderer = parent::getJavascriptRenderer(DOL_URL_ROOT.'/includes/maximebf/debugbar/src/DebugBar/Resources'); $renderer = parent::getJavascriptRenderer(DOL_URL_ROOT.'/includes/maximebf/debugbar/src/DebugBar/Resources');
//$renderer->disableVendor('jquery'); //$renderer->disableVendor('jquery');
$renderer->disableVendor('fontawesome'); $renderer->disableVendor('fontawesome');
$renderer->disableVendor('highlightjs'); $renderer->disableVendor('highlightjs');
return $renderer; return $renderer;
} }
} }

View File

@ -6,31 +6,31 @@
spl_autoload_register(function ($class) { spl_autoload_register(function ($class) {
if (preg_match('/^DebugBar/', $class)) { if (preg_match('/^DebugBar/', $class)) {
$file = DOL_DOCUMENT_ROOT.'/includes/maximebf/debugbar/src/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; $file = DOL_DOCUMENT_ROOT.'/includes/maximebf/debugbar/src/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
//var_dump($class.' - '.file_exists($file).' - '.$file); //var_dump($class.' - '.file_exists($file).' - '.$file);
if (file_exists($file)) { if (file_exists($file)) {
require_once $file; require_once $file;
return true; return true;
} }
return false; return false;
} }
if (preg_match('/^'.preg_quote('Psr\Log', '/').'/', $class)) { if (preg_match('/^'.preg_quote('Psr\Log', '/').'/', $class)) {
$file = DOL_DOCUMENT_ROOT.'/includes/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; $file = DOL_DOCUMENT_ROOT.'/includes/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
//var_dump($class.' - '.file_exists($file).' - '.$file); //var_dump($class.' - '.file_exists($file).' - '.$file);
if (file_exists($file)) { if (file_exists($file)) {
require_once $file; require_once $file;
return true; return true;
} }
return false; return false;
} }
if (preg_match('/^'.preg_quote('Symfony\Component\VarDumper', '/').'/', $class)) { if (preg_match('/^'.preg_quote('Symfony\Component\VarDumper', '/').'/', $class)) {
$class = preg_replace('/'.preg_quote('Symfony\Component\VarDumper', '/').'/', '', $class); $class = preg_replace('/'.preg_quote('Symfony\Component\VarDumper', '/').'/', '', $class);
$file = DOL_DOCUMENT_ROOT.'/includes/symfony/var-dumper/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; $file = DOL_DOCUMENT_ROOT.'/includes/symfony/var-dumper/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
if (file_exists($file)) { if (file_exists($file)) {
require_once $file; require_once $file;
return true; return true;
} }
return false; return false;
} }
return true; return true;
}); });

File diff suppressed because it is too large Load Diff

View File

@ -1005,191 +1005,191 @@ if ($action == 'create')
} }
// Incoterms // Incoterms
if (!empty($conf->incoterm->enabled)) if (!empty($conf->incoterm->enabled))
{ {
print '<tr>'; print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->label_incoterms, 1).'</label></td>'; print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->label_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">'; print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''));
print '</td></tr>'; print '</td></tr>';
} }
// Document model // Document model
include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
$liste = ModelePdfExpedition::liste_modeles($db); $liste = ModelePdfExpedition::liste_modeles($db);
if (count($liste) > 1) if (count($liste) > 1)
{ {
print "<tr><td>".$langs->trans("DefaultModel")."</td>"; print "<tr><td>".$langs->trans("DefaultModel")."</td>";
print '<td colspan="3">'; print '<td colspan="3">';
print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF); print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF);
print "</td></tr>\n"; print "</td></tr>\n";
} }
print "</table>"; print "</table>";
dol_fiche_end(); dol_fiche_end();
// Shipment lines // Shipment lines
$numAsked = count($object->lines); $numAsked = count($object->lines);
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery("#autofill").click(function() {'; jQuery("#autofill").click(function() {';
$i = 0; $i = 0;
while ($i < $numAsked) while ($i < $numAsked)
{ {
print 'jQuery("#qtyl'.$i.'").val(jQuery("#qtyasked'.$i.'").val() - jQuery("#qtydelivered'.$i.'").val());'."\n"; print 'jQuery("#qtyl'.$i.'").val(jQuery("#qtyasked'.$i.'").val() - jQuery("#qtydelivered'.$i.'").val());'."\n";
if (!empty($conf->productbatch->enabled)) print 'jQuery("#qtyl'.$i.'_'.$i.'").val(jQuery("#qtyasked'.$i.'").val() - jQuery("#qtydelivered'.$i.'").val());'."\n"; if (!empty($conf->productbatch->enabled)) print 'jQuery("#qtyl'.$i.'_'.$i.'").val(jQuery("#qtyasked'.$i.'").val() - jQuery("#qtydelivered'.$i.'").val());'."\n";
$i++; $i++;
} }
print '}); print '});
jQuery("#autoreset").click(function() {'; jQuery("#autoreset").click(function() {';
$i = 0; $i = 0;
while ($i < $numAsked) while ($i < $numAsked)
{ {
print 'jQuery("#qtyl'.$i.'").val(0);'."\n"; print 'jQuery("#qtyl'.$i.'").val(0);'."\n";
if (!empty($conf->productbatch->enabled)) print 'jQuery("#qtyl'.$i.'_'.$i.'").val(0);'."\n"; if (!empty($conf->productbatch->enabled)) print 'jQuery("#qtyl'.$i.'_'.$i.'").val(0);'."\n";
$i++; $i++;
} }
print '}); print '});
}); });
</script>'; </script>';
print '<br>'; print '<br>';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
// Load shipments already done for same order // Load shipments already done for same order
$object->loadExpeditions(); $object->loadExpeditions();
if ($numAsked) if ($numAsked)
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td class="center">'.$langs->trans("QtyOrdered").'</td>'; print '<td class="center">'.$langs->trans("QtyOrdered").'</td>';
print '<td class="center">'.$langs->trans("QtyShipped").'</td>'; print '<td class="center">'.$langs->trans("QtyShipped").'</td>';
print '<td class="center">'.$langs->trans("QtyToShip"); print '<td class="center">'.$langs->trans("QtyToShip");
if (empty($conf->productbatch->enabled)) if (empty($conf->productbatch->enabled))
{ {
print '<br><a href="#" id="autofill">'.$langs->trans("Fill").'</a>'; print '<br><a href="#" id="autofill">'.$langs->trans("Fill").'</a>';
print ' / '; print ' / ';
} else { } else {
print '<br>'; print '<br>';
} }
print '<a href="#" id="autoreset">'.$langs->trans("Reset").'</a>'; print '<a href="#" id="autoreset">'.$langs->trans("Reset").'</a>';
print '</td>'; print '</td>';
if (!empty($conf->stock->enabled)) if (!empty($conf->stock->enabled))
{ {
if (empty($conf->productbatch->enabled)) if (empty($conf->productbatch->enabled))
{ {
print '<td class="left">'.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')</td>'; print '<td class="left">'.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')</td>';
} else { } else {
print '<td class="left">'.$langs->trans("Warehouse").' / '.$langs->trans("Batch").' ('.$langs->trans("Stock").')</td>'; print '<td class="left">'.$langs->trans("Warehouse").' / '.$langs->trans("Batch").' ('.$langs->trans("Stock").')</td>';
} }
} }
print "</tr>\n"; print "</tr>\n";
} }
$indiceAsked = 0; $indiceAsked = 0;
while ($indiceAsked < $numAsked) while ($indiceAsked < $numAsked)
{ {
$product = new Product($db); $product = new Product($db);
$line = $object->lines[$indiceAsked]; $line = $object->lines[$indiceAsked];
$parameters = array('i' => $indiceAsked, 'line' => $line, 'num' => $numAsked); $parameters = array('i' => $indiceAsked, 'line' => $line, 'num' => $numAsked);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {
// Show product and description // Show product and description
$type = $line->product_type ? $line->product_type : $line->fk_product_type; $type = $line->product_type ? $line->product_type : $line->fk_product_type;
// Try to enhance type detection using date_start and date_end for free lines where type // Try to enhance type detection using date_start and date_end for free lines where type
// was not saved. // was not saved.
if (!empty($line->date_start)) $type = 1; if (!empty($line->date_start)) $type = 1;
if (!empty($line->date_end)) $type = 1; if (!empty($line->date_end)) $type = 1;
print '<!-- line '.$line->rowid.' for product -->'."\n"; print '<!-- line '.$line->rowid.' for product -->'."\n";
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
// Product label // Product label
if ($line->fk_product > 0) // If predefined product if ($line->fk_product > 0) // If predefined product
{ {
$product->fetch($line->fk_product); $product->fetch($line->fk_product);
$product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch
//var_dump($product->stock_warehouse[1]); //var_dump($product->stock_warehouse[1]);
print '<td>'; print '<td>';
print '<a name="'.$line->rowid.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$line->rowid.'"></a>'; // ancre pour retourner sur la ligne
// Show product and description // Show product and description
$product_static->type = $line->fk_product_type; $product_static->type = $line->fk_product_type;
$product_static->id = $line->fk_product; $product_static->id = $line->fk_product;
$product_static->ref = $line->ref; $product_static->ref = $line->ref;
$product_static->status_batch = $line->product_tobatch; $product_static->status_batch = $line->product_tobatch;
$text = $product_static->getNomUrl(1); $text = $product_static->getNomUrl(1);
$text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label);
$description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc));
print $form->textwithtooltip($text, $description, 3, '', '', $i); print $form->textwithtooltip($text, $description, 3, '', '', $i);
// Show range // Show range
print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
// Add description in form // Add description in form
if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
{ {
print ($line->desc && $line->desc != $line->product_label) ? '<br>'.dol_htmlentitiesbr($line->desc) : ''; print ($line->desc && $line->desc != $line->product_label) ? '<br>'.dol_htmlentitiesbr($line->desc) : '';
} }
print '</td>'; print '</td>';
} else { } else {
print "<td>"; print "<td>";
if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); if ($type == 1) $text = img_object($langs->trans('Service'), 'service');
else $text = img_object($langs->trans('Product'), 'product'); else $text = img_object($langs->trans('Product'), 'product');
if (!empty($line->label)) { if (!empty($line->label)) {
$text .= ' <strong>'.$line->label.'</strong>'; $text .= ' <strong>'.$line->label.'</strong>';
print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); print $form->textwithtooltip($text, $line->desc, 3, '', '', $i);
} else { } else {
print $text.' '.nl2br($line->desc); print $text.' '.nl2br($line->desc);
} }
// Show range // Show range
print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
print "</td>\n"; print "</td>\n";
} }
// Qty // Qty
print '<td class="center">'.$line->qty; print '<td class="center">'.$line->qty;
print '<input name="qtyasked'.$indiceAsked.'" id="qtyasked'.$indiceAsked.'" type="hidden" value="'.$line->qty.'">'; print '<input name="qtyasked'.$indiceAsked.'" id="qtyasked'.$indiceAsked.'" type="hidden" value="'.$line->qty.'">';
print '</td>'; print '</td>';
$qtyProdCom = $line->qty; $qtyProdCom = $line->qty;
// Qty already shipped // Qty already shipped
print '<td class="center">'; print '<td class="center">';
$quantityDelivered = $object->expeditions[$line->id]; $quantityDelivered = $object->expeditions[$line->id];
print $quantityDelivered; print $quantityDelivered;
print '<input name="qtydelivered'.$indiceAsked.'" id="qtydelivered'.$indiceAsked.'" type="hidden" value="'.$quantityDelivered.'">'; print '<input name="qtydelivered'.$indiceAsked.'" id="qtydelivered'.$indiceAsked.'" type="hidden" value="'.$quantityDelivered.'">';
print '</td>'; print '</td>';
// Qty to ship // Qty to ship
$quantityAsked = $line->qty; $quantityAsked = $line->qty;
if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
$quantityToBeDelivered = 0; $quantityToBeDelivered = 0;
} else { } else {
$quantityToBeDelivered = $quantityAsked - $quantityDelivered; $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
} }
$warehouse_id = GETPOST('entrepot_id', 'int'); $warehouse_id = GETPOST('entrepot_id', 'int');
$warehouseObject = null; $warehouseObject = null;
if ($warehouse_id > 0 || !($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection if ($warehouse_id > 0 || !($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection
{ {
print '<!-- Case warehouse already known or product not a predefined product -->'; print '<!-- Case warehouse already known or product not a predefined product -->';
//ship from preselected location //ship from preselected location
$stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number
$deliverableQty = min($quantityToBeDelivered, $stock); $deliverableQty = min($quantityToBeDelivered, $stock);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -30,519 +30,519 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
*/ */
class SupplierInvoices extends DolibarrApi class SupplierInvoices extends DolibarrApi
{ {
/** /**
* *
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
'socid', 'socid',
); );
/** /**
* @var FactureFournisseur $invoice {@type FactureFournisseur} * @var FactureFournisseur $invoice {@type FactureFournisseur}
*/ */
public $invoice; public $invoice;
/** /**
* Constructor * Constructor
*/ */
public function __construct() public function __construct()
{ {
global $db; global $db;
$this->db = $db; $this->db = $db;
$this->invoice = new FactureFournisseur($this->db); $this->invoice = new FactureFournisseur($this->db);
} }
/** /**
* Get properties of a supplier invoice object * Get properties of a supplier invoice object
* *
* Return an array with supplier invoice information * Return an array with supplier invoice information
* *
* @param int $id ID of supplier invoice * @param int $id ID of supplier invoice
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
public function get($id) public function get($id)
{ {
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { if (!DolibarrApiAccess::$user->rights->fournisseur->facture->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Supplier invoice not found'); throw new RestException(404, 'Supplier invoice not found');
} }
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice);
}
/**
* List invoices
*
* Get a list of supplier invoices
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter invoices of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
* @param string $status Filter by invoice status : draft | unpaid | paid | cancelled
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of invoice objects
*
* @throws RestException
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '')
{
global $db;
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid";
// We need these fields in order to filter by sale (including the case where the user can only see his prospects)
if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t";
// We need this table joined to the select in order to filter by sale
if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')';
if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Filter by status
if ($status == 'draft') {
$sql .= " AND t.fk_statut IN (0)";
}
if ($status == 'unpaid') {
$sql .= " AND t.fk_statut IN (1)";
}
if ($status == 'paid') {
$sql .= " AND t.fk_statut IN (2)";
}
if ($status == 'cancelled') {
$sql .= " AND t.fk_statut IN (3)";
}
// Insert sale filter
if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql .= $db->plimit($limit + 1, $offset);
}
$result = $db->query($sql);
if ($result) {
$i = 0;
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
$obj = $db->fetch_object($result);
$invoice_static = new FactureFournisseur($db);
if ($invoice_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($invoice_static);
}
$i++;
}
} else {
throw new RestException(503, 'Error when retrieve supplier invoice list : '.$db->lasterror());
}
if (!count($obj_ret)) {
throw new RestException(404, 'No supplier invoice found');
}
return $obj_ret;
}
/**
* Create supplier invoice object
*
* @param array $request_data Request datas
*
* @return int ID of supplier invoice
*
* @throws RestException 401
* @throws RestException 500
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
$this->invoice->$field = $value;
}
if (!array_key_exists('date', $request_data)) {
$this->invoice->date = dol_now();
}
if ($this->invoice->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->invoice->error), $this->invoice->errors));
}
return $this->invoice->id;
}
/**
* Update supplier invoice
*
* @param int $id Id of supplier invoice to update
* @param array $request_data Datas
*
* @return int
*
* @throws RestException 401
* @throws RestException 404
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if (!$result) {
throw new RestException(404, 'Supplier invoice not found');
}
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
$this->invoice->$field = $value;
}
if ($this->invoice->update($id, DolibarrApiAccess::$user))
return $this->get($id);
return false;
}
/**
* Delete supplier invoice
*
* @param int $id Supplier invoice ID
*
* @return array
*
* @throws RestException 401
* @throws RestException 404
* @throws RestException 500
*/
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if (!$result) {
throw new RestException(404, 'Supplier invoice not found');
}
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if ($this->invoice->delete(DolibarrApiAccess::$user) < 0)
{
throw new RestException(500);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Supplier invoice deleted'
)
);
}
/**
* Validate an invoice
*
* @param int $id Invoice ID
* @param int $idwarehouse Warehouse ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
* @url POST {id}/validate
*
* @return array
*
* @throws RestException 304
* @throws RestException 401
* @throws RestException 404
* @throws RestException 405
* @throws RestException 500
*/
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if (!$result) {
throw new RestException(404, 'Invoice not found');
}
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger);
if ($result == 0) {
throw new RestException(304, 'Error nothing done. The invoice is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Invoice validated (Ref='.$this->invoice->ref.')'
)
);
}
/**
* Get list of payments of a given supplier invoice
*
* @param int $id Id of SupplierInvoice
*
* @url GET {id}/payments
*
* @return array
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
* @throws RestException 405
*/
public function getPayments($id)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->lire) {
throw new RestException(401);
}
if (empty($id)) {
throw new RestException(400, 'Invoice ID is mandatory');
}
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$result = $this->invoice->fetch($id); $this->invoice->fetchObjectLinked();
if (!$result) { return $this->_cleanObjectDatas($this->invoice);
throw new RestException(404, 'Invoice not found'); }
}
$result = $this->invoice->getListOfPayments(); /**
if ($result < 0) { * List invoices
throw new RestException(405, $this->invoice->error); *
} * Get a list of supplier invoices
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter invoices of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
* @param string $status Filter by invoice status : draft | unpaid | paid | cancelled
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of invoice objects
*
* @throws RestException
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '')
{
global $db;
return $result; $obj_ret = array();
}
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid";
// We need these fields in order to filter by sale (including the case where the user can only see his prospects)
if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t";
// We need this table joined to the select in order to filter by sale
if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')';
if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Filter by status
if ($status == 'draft') {
$sql .= " AND t.fk_statut IN (0)";
}
if ($status == 'unpaid') {
$sql .= " AND t.fk_statut IN (1)";
}
if ($status == 'paid') {
$sql .= " AND t.fk_statut IN (2)";
}
if ($status == 'cancelled') {
$sql .= " AND t.fk_statut IN (3)";
}
// Insert sale filter
if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql .= $db->plimit($limit + 1, $offset);
}
$result = $db->query($sql);
if ($result) {
$i = 0;
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
$obj = $db->fetch_object($result);
$invoice_static = new FactureFournisseur($db);
if ($invoice_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($invoice_static);
}
$i++;
}
} else {
throw new RestException(503, 'Error when retrieve supplier invoice list : '.$db->lasterror());
}
if (!count($obj_ret)) {
throw new RestException(404, 'No supplier invoice found');
}
return $obj_ret;
}
/**
* Create supplier invoice object
*
* @param array $request_data Request datas
*
* @return int ID of supplier invoice
*
* @throws RestException 401
* @throws RestException 500
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
$this->invoice->$field = $value;
}
if (!array_key_exists('date', $request_data)) {
$this->invoice->date = dol_now();
}
if ($this->invoice->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->invoice->error), $this->invoice->errors));
}
return $this->invoice->id;
}
/**
* Update supplier invoice
*
* @param int $id Id of supplier invoice to update
* @param array $request_data Datas
*
* @return int
*
* @throws RestException 401
* @throws RestException 404
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if (!$result) {
throw new RestException(404, 'Supplier invoice not found');
}
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
$this->invoice->$field = $value;
}
if ($this->invoice->update($id, DolibarrApiAccess::$user))
return $this->get($id);
return false;
}
/**
* Delete supplier invoice
*
* @param int $id Supplier invoice ID
*
* @return array
*
* @throws RestException 401
* @throws RestException 404
* @throws RestException 500
*/
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if (!$result) {
throw new RestException(404, 'Supplier invoice not found');
}
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if ($this->invoice->delete(DolibarrApiAccess::$user) < 0)
{
throw new RestException(500);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Supplier invoice deleted'
)
);
}
/**
* Validate an invoice
*
* @param int $id Invoice ID
* @param int $idwarehouse Warehouse ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
* @url POST {id}/validate
*
* @return array
*
* @throws RestException 304
* @throws RestException 401
* @throws RestException 404
* @throws RestException 405
* @throws RestException 500
*/
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if (!$result) {
throw new RestException(404, 'Invoice not found');
}
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger);
if ($result == 0) {
throw new RestException(304, 'Error nothing done. The invoice is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Invoice validated (Ref='.$this->invoice->ref.')'
)
);
}
/**
* Get list of payments of a given supplier invoice
*
* @param int $id Id of SupplierInvoice
*
* @url GET {id}/payments
*
* @return array
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
* @throws RestException 405
*/
public function getPayments($id)
{
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->lire) {
throw new RestException(401);
}
if (empty($id)) {
throw new RestException(400, 'Invoice ID is mandatory');
}
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->fetch($id);
if (!$result) {
throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->getListOfPayments();
if ($result < 0) {
throw new RestException(405, $this->invoice->error);
}
return $result;
}
/** /**
* Add payment line to a specific supplier invoice with the remain to pay as amount. * Add payment line to a specific supplier invoice with the remain to pay as amount.
* *
* @param int $id Id of invoice * @param int $id Id of invoice
* @param string $datepaye {@from body} Payment date {@type timestamp} * @param string $datepaye {@from body} Payment date {@type timestamp}
* @param int $payment_mode_id {@from body} Payment mode ID (look it up via REST GET to /setup/dictionary/payment_types) {@min 1} * @param int $payment_mode_id {@from body} Payment mode ID (look it up via REST GET to /setup/dictionary/payment_types) {@min 1}
* @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no}
* @param int $accountid {@from body} Bank account ID (look it up via REST GET to /bankaccounts) {@min 1} * @param int $accountid {@from body} Bank account ID (look it up via REST GET to /bankaccounts) {@min 1}
* @param string $num_payment {@from body} Payment number (optional) * @param string $num_payment {@from body} Payment number (optional)
* @param string $comment {@from body} Note (optional) * @param string $comment {@from body} Note (optional)
* @param string $chqemetteur {@from body} Payment issuer (mandatory if payment_mode_id corresponds to 'CHQ'-payment type) * @param string $chqemetteur {@from body} Payment issuer (mandatory if payment_mode_id corresponds to 'CHQ'-payment type)
* @param string $chqbank {@from body} Issuer bank name (optional) * @param string $chqbank {@from body} Issuer bank name (optional)
* *
* @url POST {id}/payments * @url POST {id}/payments
* *
* @return int Payment ID * @return int Payment ID
* @throws RestException 400 * @throws RestException 400
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
*/ */
public function addPayment($id, $datepaye, $payment_mode_id, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') public function addPayment($id, $datepaye, $payment_mode_id, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '')
{ {
global $conf; global $conf;
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(403); throw new RestException(403);
} }
if (empty($id)) { if (empty($id)) {
throw new RestException(400, 'Invoice ID is mandatory'); throw new RestException(400, 'Invoice ID is mandatory');
} }
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if (!empty($conf->banque->enabled)) { if (!empty($conf->banque->enabled)) {
if (empty($accountid)) { if (empty($accountid)) {
throw new RestException(400, 'Bank account ID is mandatory'); throw new RestException(400, 'Bank account ID is mandatory');
} }
} }
if (empty($payment_mode_id)) { if (empty($payment_mode_id)) {
throw new RestException(400, 'Payment mode ID is mandatory'); throw new RestException(400, 'Payment mode ID is mandatory');
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
// Calculate amount to pay // Calculate amount to pay
$totalpaye = $this->invoice->getSommePaiement(); $totalpaye = $this->invoice->getSommePaiement();
$totaldeposits = $this->invoice->getSumDepositsUsed(); $totaldeposits = $this->invoice->getSumDepositsUsed();
$resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totaldeposits, 'MT'); $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totaldeposits, 'MT');
$this->db->begin(); $this->db->begin();
$amounts = array(); $amounts = array();
$multicurrency_amounts = array(); $multicurrency_amounts = array();
$resteapayer = price2num($resteapayer, 'MT'); $resteapayer = price2num($resteapayer, 'MT');
$amounts[$id] = $resteapayer; $amounts[$id] = $resteapayer;
// Multicurrency // Multicurrency
$newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT'); $newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT');
$multicurrency_amounts[$id] = $newvalue; $multicurrency_amounts[$id] = $newvalue;
// Creation of payment line // Creation of payment line
$paiement = new PaiementFourn($this->db); $paiement = new PaiementFourn($this->db);
$paiement->datepaye = $datepaye; $paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
$paiement->paiementid = $payment_mode_id; $paiement->paiementid = $payment_mode_id;
$paiement->paiementcode = dol_getIdFromCode($this->db, $payment_mode_id, 'c_paiement', 'id', 'code', 1); $paiement->paiementcode = dol_getIdFromCode($this->db, $payment_mode_id, 'c_paiement', 'id', 'code', 1);
$paiement->oper = $paiement->paiementcode; // For backward compatibility $paiement->oper = $paiement->paiementcode; // For backward compatibility
$paiement->num_payment = $num_payment; $paiement->num_payment = $num_payment;
$paiement->note_public = $comment; $paiement->note_public = $comment;
$paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices
if ($paiement_id < 0) if ($paiement_id < 0)
{ {
$this->db->rollback(); $this->db->rollback();
throw new RestException(400, 'Payment error : '.$paiement->error); throw new RestException(400, 'Payment error : '.$paiement->error);
} }
if (!empty($conf->banque->enabled)) { if (!empty($conf->banque->enabled)) {
$result = $paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, $chqemetteur, $chqbank); $result = $paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, $chqemetteur, $chqbank);
if ($result < 0) if ($result < 0)
{ {
$this->db->rollback(); $this->db->rollback();
throw new RestException(400, 'Add payment to bank error : '.$paiement->error); throw new RestException(400, 'Add payment to bank error : '.$paiement->error);
} }
} }
$this->db->commit(); $this->db->commit();
return $paiement_id; return $paiement_id;
} }
/** /**
* Get lines of a supplier invoice * Get lines of a supplier invoice
* *
* @param int $id Id of supplier invoice * @param int $id Id of supplier invoice
* *
* @url GET {id}/lines * @url GET {id}/lines
* *
* @return array * @return array
*/ */
public function getLines($id) public function getLines($id)
{ {
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Supplier invoice not found'); throw new RestException(404, 'Supplier invoice not found');
} }
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->invoice->fetch_lines(); $this->invoice->fetch_lines();
$result = array(); $result = array();
foreach ($this->invoice->lines as $line) { foreach ($this->invoice->lines as $line) {
array_push($result, $this->_cleanObjectDatas($line)); array_push($result, $this->_cleanObjectDatas($line));
} }
return $result; return $result;
} }
/** /**
* Add a line to given supplier invoice * Add a line to given supplier invoice
* *
* @param int $id Id of supplier invoice to update * @param int $id Id of supplier invoice to update
* @param array $request_data supplier invoice line data * @param array $request_data supplier invoice line data
* *
* @url POST {id}/lines * @url POST {id}/lines
* *
* @return int|bool * @return int|bool
*/ */
public function postLine($id, $request_data = null) public function postLine($id, $request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { if (!DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Supplier invoice not found'); throw new RestException(404, 'Supplier invoice not found');
} }
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->invoice->addline( $updateRes = $this->invoice->addline(
$request_data->description, $request_data->description,
$request_data->pu_ht, $request_data->pu_ht,
$request_data->tva_tx, $request_data->tva_tx,
$request_data->localtax1_tx, $request_data->localtax1_tx,
$request_data->localtax2_tx, $request_data->localtax2_tx,
$request_data->qty, $request_data->qty,
$request_data->fk_product, $request_data->fk_product,
$request_data->remise_percent, $request_data->remise_percent,
$request_data->date_start, $request_data->date_start,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1936,53 +1936,53 @@ if ($action == 'create')
$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', null, null, '', 1); $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty'); $morehtmlref .= '<br>'.$langs->trans('ThirdParty');
if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && !empty($usercancreate) && $action == 'edit_thirdparty') { if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && !empty($usercancreate) && $action == 'edit_thirdparty') {
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="set_thirdparty">'; $morehtmlref .= '<input type="hidden" name="action" value="set_thirdparty">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $form->select_company($object->thirdparty->id, 'new_socid', 's.fournisseur=1', '', 0, 0, array(), 0, 'minwidth300'); $morehtmlref .= $form->select_company($object->thirdparty->id, 'new_socid', 's.fournisseur=1', '', 0, 0, array(), 0, 'minwidth300');
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>'; $morehtmlref .= '</form>';
} }
if (empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) || $action != 'edit_thirdparty') { if (empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) || $action != 'edit_thirdparty') {
if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $object->statut == CommandeFournisseur::STATUS_DRAFT) { if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $object->statut == CommandeFournisseur::STATUS_DRAFT) {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=edit_thirdparty&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).'</a>'; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=edit_thirdparty&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).'</a>';
} }
$morehtmlref .= ' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= ' : '.$object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
} }
// Project // Project
if (!empty($conf->projet->enabled)) { if (!empty($conf->projet->enabled)) {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($usercancreate) { if ($usercancreate) {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>'; $morehtmlref .= '</form>';
} else { } else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref; $morehtmlref .= $proj->ref;
$morehtmlref .= '</a>'; $morehtmlref .= '</a>';
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';
} }
} }
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';

View File

@ -127,7 +127,7 @@ if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions =
$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity,"; $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity, tosell, tobuy,";
$sql .= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; $sql .= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,";
$sql .= " s.rowid as socid, s.nom as name"; $sql .= " s.rowid as socid, s.nom as name";
// Add fields to SELECT from hooks // Add fields to SELECT from hooks
@ -296,6 +296,8 @@ if ($resql)
$productstatic->ref = $objp->ref; $productstatic->ref = $objp->ref;
$productstatic->type = $objp->fk_product_type; $productstatic->type = $objp->fk_product_type;
$productstatic->entity = $objp->entity; $productstatic->entity = $objp->entity;
$productstatic->status = $objp->tosell;
$productstatic->status_buy = $objp->tobuy;
print $productstatic->getNomUrl(1, 'supplier'); print $productstatic->getNomUrl(1, 'supplier');
print '</td>'; print '</td>';

View File

@ -111,152 +111,152 @@ if (empty($reshook))
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
$action = ''; $action = '';
} }
// If create a request // If create a request
if ($action == 'create') if ($action == 'create')
{ {
// If no right to create a request // If no right to create a request
if (!$cancreate) if (!$cancreate)
{ {
$error++; $error++;
setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); setEventMessages($langs->trans('CantCreateCP'), null, 'errors');
$action = 'request'; $action = 'request';
} }
if (!$error) if (!$error)
{ {
$object = new Holiday($db); $object = new Holiday($db);
$db->begin(); $db->begin();
$date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
$date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
$date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1); $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
$date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1); $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
$starthalfday = GETPOST('starthalfday'); $starthalfday = GETPOST('starthalfday');
$endhalfday = GETPOST('endhalfday'); $endhalfday = GETPOST('endhalfday');
$type = GETPOST('type'); $type = GETPOST('type');
$halfday = 0; $halfday = 0;
if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday = 2; if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday = 2;
elseif ($starthalfday == 'afternoon') $halfday = -1; elseif ($starthalfday == 'afternoon') $halfday = -1;
elseif ($endhalfday == 'morning') $halfday = 1; elseif ($endhalfday == 'morning') $halfday = 1;
$valideur = GETPOST('valideur', 'int'); $valideur = GETPOST('valideur', 'int');
$description = trim(GETPOST('description', 'none')); $description = trim(GETPOST('description', 'none'));
// If no type // If no type
if ($type <= 0) if ($type <= 0)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$error++; $error++;
$action = 'create'; $action = 'create';
} }
// If no start date // If no start date
if (empty($date_debut)) if (empty($date_debut))
{ {
setEventMessages($langs->trans("NoDateDebut"), null, 'errors'); setEventMessages($langs->trans("NoDateDebut"), null, 'errors');
$error++; $error++;
$action = 'create'; $action = 'create';
} }
// If no end date // If no end date
if (empty($date_fin)) if (empty($date_fin))
{ {
setEventMessages($langs->trans("NoDateFin"), null, 'errors'); setEventMessages($langs->trans("NoDateFin"), null, 'errors');
$error++; $error++;
$action = 'create'; $action = 'create';
} }
// If start date after end date // If start date after end date
if ($date_debut > $date_fin) if ($date_debut > $date_fin)
{ {
setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors'); setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors');
$error++; $error++;
$action = 'create'; $action = 'create';
} }
// Check if there is already holiday for this period // Check if there is already holiday for this period
$verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday); $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
if (!$verifCP) if (!$verifCP)
{ {
setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
$error++; $error++;
$action = 'create'; $action = 'create';
} }
// If there is no Business Days within request // If there is no Business Days within request
$nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
if ($nbopenedday < 0.5) if ($nbopenedday < 0.5)
{ {
setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors');
$error++; $error++;
$action = 'create'; $action = 'create';
} }
// If no validator designated // If no validator designated
if ($valideur < 1) if ($valideur < 1)
{ {
setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors'); setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors');
$error++; $error++;
} }
$result = 0; $result = 0;
if (!$error) if (!$error)
{ {
$object->fk_user = $fuserid; $object->fk_user = $fuserid;
$object->description = $description; $object->description = $description;
$object->fk_validator = $valideur; $object->fk_validator = $valideur;
$object->fk_type = $type; $object->fk_type = $type;
$object->date_debut = $date_debut; $object->date_debut = $date_debut;
$object->date_fin = $date_fin; $object->date_fin = $date_fin;
$object->halfday = $halfday; $object->halfday = $halfday;
$result = $object->create($user); $result = $object->create($user);
if ($result <= 0) if ($result <= 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} }
// If no SQL error we redirect to the request card // If no SQL error we redirect to the request card
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} else { } else {
$db->rollback(); $db->rollback();
} }
} }
} }
if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve))
{ {
$object->fetch($id); $object->fetch($id);
$object->oldcopy = dol_clone($object); $object->oldcopy = dol_clone($object);
$object->fk_validator = GETPOST('valideur', 'int'); $object->fk_validator = GETPOST('valideur', 'int');
if ($object->fk_validator != $object->oldcopy->fk_validator) if ($object->fk_validator != $object->oldcopy->fk_validator)
{ {
$verif = $object->update($user); $verif = $object->update($user);
if ($verif <= 0) if ($verif <= 0)
{ {
setEventMessages($object->error, $object->errors, 'warnings'); setEventMessages($object->error, $object->errors, 'warnings');
$action = 'editvalidator'; $action = 'editvalidator';
} else { } else {
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }
} }
$action = ''; $action = '';
} }
if ($action == 'update' && !GETPOSTISSET('savevalidator')) if ($action == 'update' && !GETPOSTISSET('savevalidator'))

View File

@ -450,14 +450,14 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) { if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) {
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board = new ExpenseReport($db); $board = new ExpenseReport($db);
$dashboardlines[$board->element . '_toapprove'] = $board->load_board($user, 'toapprove'); $dashboardlines[$board->element.'_toapprove'] = $board->load_board($user, 'toapprove');
} }
// Number of expense reports to pay // Number of expense reports to pay
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) { if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) {
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board = new ExpenseReport($db); $board = new ExpenseReport($db);
$dashboardlines[$board->element . '_topay'] = $board->load_board($user, 'topay'); $dashboardlines[$board->element.'_topay'] = $board->load_board($user, 'topay');
} }
// Number of holidays to approve // Number of holidays to approve

View File

@ -318,3 +318,5 @@ ALTER TABLE llx_facturedet ADD COLUMN ref_ext varchar(255) AFTER multicurrency_t
ALTER TABLE llx_c_ticket_category ADD COLUMN fk_parent integer DEFAULT 0 NOT NULL; ALTER TABLE llx_c_ticket_category ADD COLUMN fk_parent integer DEFAULT 0 NOT NULL;
ALTER TABLE llx_c_ticket_category ADD COLUMN force_severity varchar(32) NULL; ALTER TABLE llx_c_ticket_category ADD COLUMN force_severity varchar(32) NULL;
ALTER TABLE llx_expensereport_ik ADD COLUMN ikoffset double DEFAULT 0 NOT NULL;

View File

@ -25,6 +25,6 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik (
fk_c_exp_tax_cat integer DEFAULT 0 NOT NULL, fk_c_exp_tax_cat integer DEFAULT 0 NOT NULL,
fk_range integer DEFAULT 0 NOT NULL, fk_range integer DEFAULT 0 NOT NULL,
coef double DEFAULT 0 NOT NULL, coef double DEFAULT 0 NOT NULL,
ikoffset double DEFAULT 0 NOT NULL, ikoffset double DEFAULT 0 NOT NULL,
active integer DEFAULT 1 active integer DEFAULT 1
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -23,5 +23,5 @@ ALTER TABLE llx_recruitment_recruitmentcandidature ADD INDEX idx_recruitment_rec
ALTER TABLE llx_recruitment_recruitmentcandidature ADD UNIQUE INDEX uk_recruitmentcandidature_email_msgid(email_msgid); ALTER TABLE llx_recruitment_recruitmentcandidature ADD UNIQUE INDEX uk_recruitmentcandidature_email_msgid(email_msgid);
--ALTER TABLE llx_recruitment_recruitmentcandidature ADD CONSTRAINT llx_mymodule_myobject_fk_field FOREIGN KEY (fk_field) REFERENCES llx_mymodule_myotherobject(rowid); -- ALTER TABLE llx_recruitment_recruitmentcandidature ADD CONSTRAINT llx_mymodule_myobject_fk_field FOREIGN KEY (fk_field) REFERENCES llx_mymodule_myotherobject(rowid);

View File

@ -671,7 +671,7 @@ Module63000Name=Resources
Module63000Desc=Manage resources (printers, cars, rooms, ...) for allocating to events Module63000Desc=Manage resources (printers, cars, rooms, ...) for allocating to events
Permission11=Read customer invoices Permission11=Read customer invoices
Permission12=Create/modify customer invoices Permission12=Create/modify customer invoices
Permission13=Unvalidate customer invoices Permission13=Invalidate customer invoices
Permission14=Validate customer invoices Permission14=Validate customer invoices
Permission15=Send customer invoices by email Permission15=Send customer invoices by email
Permission16=Create payments for customer invoices Permission16=Create payments for customer invoices
@ -688,6 +688,7 @@ Permission32=Create/modify products
Permission34=Delete products Permission34=Delete products
Permission36=See/manage hidden products Permission36=See/manage hidden products
Permission38=Export products Permission38=Export products
Permission39=Ignore minimum price
Permission41=Read projects and tasks (shared project and projects I'm contact for). Can also enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) Permission41=Read projects and tasks (shared project and projects I'm contact for). Can also enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet)
Permission42=Create/modify projects (shared project and projects I'm contact for). Can also create tasks and assign users to project and tasks Permission42=Create/modify projects (shared project and projects I'm contact for). Can also create tasks and assign users to project and tasks
Permission44=Delete projects (shared project and projects I'm contact for) Permission44=Delete projects (shared project and projects I'm contact for)
@ -696,6 +697,9 @@ Permission61=Read interventions
Permission62=Create/modify interventions Permission62=Create/modify interventions
Permission64=Delete interventions Permission64=Delete interventions
Permission67=Export interventions Permission67=Export interventions
Permission68=Send interventions by email
Permission69=Validate interventions
Permission70=Invalidate interventions
Permission71=Read members Permission71=Read members
Permission72=Create/modify members Permission72=Create/modify members
Permission74=Delete members Permission74=Delete members
@ -718,6 +722,7 @@ Permission95=Read reports
Permission101=Read sendings Permission101=Read sendings
Permission102=Create/modify sendings Permission102=Create/modify sendings
Permission104=Validate sendings Permission104=Validate sendings
Permission105=Send sendings by email
Permission106=Export sendings Permission106=Export sendings
Permission109=Delete sendings Permission109=Delete sendings
Permission111=Read financial accounts Permission111=Read financial accounts
@ -843,6 +848,9 @@ Permission561=Read payment orders by credit transfer
Permission562=Create/modify payment order by credit transfer Permission562=Create/modify payment order by credit transfer
Permission563=Send/Transmit payment order by credit transfer Permission563=Send/Transmit payment order by credit transfer
Permission564=Record Debits/Rejections of credit transfer Permission564=Record Debits/Rejections of credit transfer
Permission601=Read stickers
Permission602=Create/modify stickers
Permission609=Delete stickers
Permission650=Read Bills of Materials Permission650=Read Bills of Materials
Permission651=Create/Update Bills of Materials Permission651=Create/Update Bills of Materials
Permission652=Delete Bills of Materials Permission652=Delete Bills of Materials
@ -884,7 +892,9 @@ Permission1185=Approve purchase orders
Permission1186=Order purchase orders Permission1186=Order purchase orders
Permission1187=Acknowledge receipt of purchase orders Permission1187=Acknowledge receipt of purchase orders
Permission1188=Delete purchase orders Permission1188=Delete purchase orders
Permission1189=Check/Uncheck a supplier order reception
Permission1190=Approve (second approval) purchase orders Permission1190=Approve (second approval) purchase orders
Permission1191=Export supplier orders and their attributes
Permission1201=Get result of an export Permission1201=Get result of an export
Permission1202=Create/Modify an export Permission1202=Create/Modify an export
Permission1231=Read vendor invoices Permission1231=Read vendor invoices
@ -898,6 +908,8 @@ Permission1251=Run mass imports of external data into database (data load)
Permission1321=Export customer invoices, attributes and payments Permission1321=Export customer invoices, attributes and payments
Permission1322=Reopen a paid bill Permission1322=Reopen a paid bill
Permission1421=Export sales orders and attributes Permission1421=Export sales orders and attributes
Permission1521=Read documents
Permission1522=Delete documents
Permission2401=Read actions (events or tasks) linked to his user account (if owner of event or just assigned to) Permission2401=Read actions (events or tasks) linked to his user account (if owner of event or just assigned to)
Permission2402=Create/modify actions (events or tasks) linked to his user account (if owner of event) Permission2402=Create/modify actions (events or tasks) linked to his user account (if owner of event)
Permission2403=Delete actions (events or tasks) linked to his user account (if owner of event) Permission2403=Delete actions (events or tasks) linked to his user account (if owner of event)
@ -932,9 +944,13 @@ Permission23001=Read Scheduled job
Permission23002=Create/update Scheduled job Permission23002=Create/update Scheduled job
Permission23003=Delete Scheduled job Permission23003=Delete Scheduled job
Permission23004=Execute Scheduled job Permission23004=Execute Scheduled job
Permission50101=Use Point of Sale Permission50101=Use Point of Sale (SimplePOS)
Permission50151=Use Point of Sale (TakePOS)
Permission50201=Read transactions Permission50201=Read transactions
Permission50202=Import transactions Permission50202=Import transactions
Permission50330=Read objects of Zapier
Permission50331=Create/Update objects of Zapier
Permission50332=Delete objects of Zapier
Permission50401=Bind products and invoices with accounting accounts Permission50401=Bind products and invoices with accounting accounts
Permission50411=Read operations in ledger Permission50411=Read operations in ledger
Permission50412=Write/Edit operations in ledger Permission50412=Write/Edit operations in ledger
@ -958,6 +974,14 @@ Permission63001=Read resources
Permission63002=Create/modify resources Permission63002=Create/modify resources
Permission63003=Delete resources Permission63003=Delete resources
Permission63004=Link resources to agenda events Permission63004=Link resources to agenda events
Permission64001=Allow direct printing
Permission67000=Allow printing of receipts
Permission941601=Read receipts
Permission941602=Create and modify receipts
Permission941603=Validate receipts
Permission941604=Send receipts by email
Permission941605=Export receipts
Permission941606=Delete receipts
DictionaryCompanyType=Third-party types DictionaryCompanyType=Third-party types
DictionaryCompanyJuridicalType=Third-party legal entities DictionaryCompanyJuridicalType=Third-party legal entities
DictionaryProspectLevel=Prospect potential level for companies DictionaryProspectLevel=Prospect potential level for companies
@ -1794,7 +1818,6 @@ TypePaymentDesc=0:Customer payment type, 1:Vendor payment type, 2:Both customers
IncludePath=Include path (defined into variable %s) IncludePath=Include path (defined into variable %s)
ExpenseReportsSetup=Setup of module Expense Reports ExpenseReportsSetup=Setup of module Expense Reports
TemplatePDFExpenseReports=Document templates to generate expense report document TemplatePDFExpenseReports=Document templates to generate expense report document
ExpenseReportsIkSetup=Setup of module Expense Reports - Milles index
ExpenseReportsRulesSetup=Setup of module Expense Reports - Rules ExpenseReportsRulesSetup=Setup of module Expense Reports - Rules
ExpenseReportNumberingModules=Expense reports numbering module ExpenseReportNumberingModules=Expense reports numbering module
NoModueToManageStockIncrease=No module able to manage automatic stock increase has been activated. Stock increase will be done on manual input only. NoModueToManageStockIncrease=No module able to manage automatic stock increase has been activated. Stock increase will be done on manual input only.

View File

@ -110,7 +110,7 @@ ExpenseReportPayment=Expense report payment
ExpenseReportsToApprove=Expense reports to approve ExpenseReportsToApprove=Expense reports to approve
ExpenseReportsToPay=Expense reports to pay ExpenseReportsToPay=Expense reports to pay
ConfirmCloneExpenseReport=Are you sure you want to clone this expense report ? ConfirmCloneExpenseReport=Are you sure you want to clone this expense report ?
ExpenseReportsIk=Expense report milles index ExpenseReportsIk=Configuration of mileage charges
ExpenseReportsRules=Expense report rules ExpenseReportsRules=Expense report rules
ExpenseReportIkDesc=You can modify the calculation of kilometers expense by category and range who they are previously defined. <b>d</b> is the distance in kilometers ExpenseReportIkDesc=You can modify the calculation of kilometers expense by category and range who they are previously defined. <b>d</b> is the distance in kilometers
ExpenseReportRulesDesc=You can create or update any rules of calculation. This part will be used when user will create a new expense report ExpenseReportRulesDesc=You can create or update any rules of calculation. This part will be used when user will create a new expense report
@ -145,7 +145,7 @@ nolimitbyEX_DAY=by day (no limitation)
nolimitbyEX_MON=by month (no limitation) nolimitbyEX_MON=by month (no limitation)
nolimitbyEX_YEA=by year (no limitation) nolimitbyEX_YEA=by year (no limitation)
nolimitbyEX_EXP=by line (no limitation) nolimitbyEX_EXP=by line (no limitation)
CarCategory=Category of car CarCategory=Vehicle category
ExpenseRangeOffset=Offset amount: %s ExpenseRangeOffset=Offset amount: %s
RangeIk=Mileage range RangeIk=Mileage range
AttachTheNewLineToTheDocument=Attach the line to an uploaded document AttachTheNewLineToTheDocument=Attach the line to an uploaded document

View File

@ -41,63 +41,63 @@ class PaymentLoan extends CommonObject
*/ */
public $table_element = 'payment_loan'; public $table_element = 'payment_loan';
/** /**
* @var string String with name of icon for PaymentLoan * @var string String with name of icon for PaymentLoan
*/ */
public $picto = 'money-bill-alt'; public $picto = 'money-bill-alt';
/** /**
* @var int Loan ID * @var int Loan ID
*/ */
public $fk_loan; public $fk_loan;
/** /**
* @var string Create date * @var string Create date
*/ */
public $datec = ''; public $datec = '';
public $tms = ''; public $tms = '';
/** /**
* @var string Payment date * @var string Payment date
*/ */
public $datep = ''; public $datep = '';
public $amounts = array(); // Array of amounts public $amounts = array(); // Array of amounts
public $amount_capital; // Total amount of payment public $amount_capital; // Total amount of payment
public $amount_insurance; public $amount_insurance;
public $amount_interest; public $amount_interest;
/** /**
* @var int Payment mode ID * @var int Payment mode ID
*/ */
public $fk_typepayment; public $fk_typepayment;
/** /**
* @var int Payment ID * @var int Payment ID
*/ */
public $num_payment; public $num_payment;
/** /**
* @var int Bank ID * @var int Bank ID
*/ */
public $fk_bank; public $fk_bank;
/** /**
* @var int User ID * @var int User ID
*/ */
public $fk_user_creat; public $fk_user_creat;
/** /**
* @var int user ID * @var int user ID
*/ */
public $fk_user_modif; public $fk_user_modif;
public $type_code; public $type_code;
public $type_label; public $type_label;
/** /**
@ -367,23 +367,23 @@ class PaymentLoan extends CommonObject
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
} }
// Set loan unpaid if loan has no other payment // Set loan unpaid if loan has no other payment
if (!$error) if (!$error)
{ {
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
$loan = new Loan($this->db); $loan = new Loan($this->db);
$loan->fetch($this->fk_loan); $loan->fetch($this->fk_loan);
$sum_payment = $loan->getSumPayment(); $sum_payment = $loan->getSumPayment();
if ($sum_payment == 0) if ($sum_payment == 0)
{ {
dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG); dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG);
if ($loan->set_unpaid($user) < 1) if ($loan->set_unpaid($user) < 1)
{ {
$error++; $error++;
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
} }
//if (! $error) //if (! $error)
//{ //{
@ -435,7 +435,7 @@ class PaymentLoan extends CommonObject
global $conf; global $conf;
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled))
{ {
@ -448,9 +448,9 @@ class PaymentLoan extends CommonObject
if ($mode == 'payment_loan') $total = -$total; if ($mode == 'payment_loan') $total = -$total;
// Insert payment into llx_bank // Insert payment into llx_bank
$bank_line_id = $acc->addline( $bank_line_id = $acc->addline(
$this->datep, $this->datep,
$this->fk_typepayment, // Payment mode ID or code ("CHQ or VIR for example") $this->fk_typepayment, // Payment mode ID or code ("CHQ or VIR for example")
$label, $label,
$total, $total,
$this->num_payment, $this->num_payment,
@ -498,36 +498,36 @@ class PaymentLoan extends CommonObject
} }
// Set loan payment started if no set // Set loan payment started if no set
if (!$error) if (!$error)
{ {
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
$loan = new Loan($this->db); $loan = new Loan($this->db);
$loan->fetch($fk_loan); $loan->fetch($fk_loan);
if ($loan->paid == $loan::STATUS_UNPAID) if ($loan->paid == $loan::STATUS_UNPAID)
{ {
dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG); dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG);
if ($loan->set_started($user) < 1) if ($loan->set_started($user) < 1)
{ {
$error++; $error++;
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
} }
if (!$error) if (!$error)
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else { else {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Update link between loan's payment and the line generate in llx_bank * Update link between loan's payment and the line generate in llx_bank
* *
@ -536,14 +536,14 @@ class PaymentLoan extends CommonObject
*/ */
public function update_fk_bank($id_bank) public function update_fk_bank($id_bank)
{ {
// phpcs:enable // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$this->fk_bank = $id_bank; $this->fk_bank = $id_bank;
return 1; return 1;
} else { } else {
$this->error = $this->db->error(); $this->error = $this->db->error();
@ -556,9 +556,9 @@ class PaymentLoan extends CommonObject
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=No picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=No picto
* @param int $maxlen Max length label * @param int $maxlen Max length label
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param string $moretitle Add more text to title tooltip * @param string $moretitle Add more text to title tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $moretitle = '', $save_lastsearch_value = -1) public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $moretitle = '', $save_lastsearch_value = -1)

View File

@ -49,8 +49,8 @@ $object = new Opensurveysondage($db);
$result = $object->fetch(0, $numsondage); $result = $object->fetch(0, $numsondage);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
exit; exit;
} }
$expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); $expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear'));
@ -67,112 +67,112 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
if ($cancel) $action = ''; if ($cancel) $action = '';
// Delete // Delete
if ($action == 'delete_confirm') if ($action == 'delete_confirm')
{ {
// Security check // Security check
if (!$user->rights->opensurvey->write) accessforbidden(); if (!$user->rights->opensurvey->write) accessforbidden();
$result = $object->delete($user, '', $numsondage); $result = $object->delete($user, '', $numsondage);
header('Location: '.dol_buildpath('/opensurvey/list.php', 1)); header('Location: '.dol_buildpath('/opensurvey/list.php', 1));
exit(); exit();
} }
// Close // Close
if ($action == 'close') if ($action == 'close')
{ {
$object->status = Opensurveysondage::STATUS_CLOSED; $object->status = Opensurveysondage::STATUS_CLOSED;
$object->update($user); $object->update($user);
} }
// Reopend // Reopend
if ($action == 'reopen') if ($action == 'reopen')
{ {
$object->status = Opensurveysondage::STATUS_VALIDATED; $object->status = Opensurveysondage::STATUS_VALIDATED;
$object->update($user); $object->update($user);
} }
// Update // Update
if ($action == 'update') if ($action == 'update')
{ {
// Security check // Security check
if (!$user->rights->opensurvey->write) accessforbidden(); if (!$user->rights->opensurvey->write) accessforbidden();
$error = 0; $error = 0;
if (!GETPOST('nouveautitre')) if (!GETPOST('nouveautitre'))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
$error++; $error++;
$action = 'edit'; $action = 'edit';
} }
if (!$error) if (!$error)
{ {
$object->title = GETPOST('nouveautitre', 'nohtml'); $object->title = GETPOST('nouveautitre', 'nohtml');
$object->description = GETPOST('nouveauxcommentaires', 'restricthtml'); $object->description = GETPOST('nouveauxcommentaires', 'restricthtml');
$object->mail_admin = GETPOST('nouvelleadresse', 'alpha'); $object->mail_admin = GETPOST('nouvelleadresse', 'alpha');
$object->date_fin = $expiredate; $object->date_fin = $expiredate;
$object->allow_comments = GETPOST('cancomment', 'alpha') == 'on' ? 1 : 0; $object->allow_comments = GETPOST('cancomment', 'alpha') == 'on' ? 1 : 0;
$object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? 1 : 0; $object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? 1 : 0;
$object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false; $object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false;
$res = $object->update($user); $res = $object->update($user);
if ($res < 0) if ($res < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'edit'; $action = 'edit';
} }
} }
} }
// Add comment // Add comment
if (GETPOST('ajoutcomment')) if (GETPOST('ajoutcomment'))
{ {
$error = 0; $error = 0;
if (!GETPOST('comment')) if (!GETPOST('comment'))
{ {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors');
} }
if (!GETPOST('commentuser')) if (!GETPOST('commentuser'))
{ {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors');
} }
if (!$error) if (!$error)
{ {
$comment = GETPOST("comment"); $comment = GETPOST("comment");
$comment_user = GETPOST('commentuser'); $comment_user = GETPOST('commentuser');
$resql = $object->addComment($comment, $comment_user); $resql = $object->addComment($comment, $comment_user);
if (!$resql) if (!$resql)
{ {
setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors');
} }
} }
} }
// Delete comment // Delete comment
$idcomment = GETPOST('deletecomment', 'int'); $idcomment = GETPOST('deletecomment', 'int');
if ($idcomment) if ($idcomment)
{ {
// Security check // Security check
if (!$user->rights->opensurvey->write) accessforbidden(); if (!$user->rights->opensurvey->write) accessforbidden();
$resql = $object->deleteComment($idcomment); $resql = $object->deleteComment($idcomment);
} }
if ($action == 'edit') { if ($action == 'edit') {
// Security check // Security check
if (!$user->rights->opensurvey->write) accessforbidden(); if (!$user->rights->opensurvey->write) accessforbidden();
} }
} }
@ -302,8 +302,8 @@ print '</td></tr>';
print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">';
if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0);
else { else {
print dol_print_date($object->date_fin, 'day'); print dol_print_date($object->date_fin, 'day');
if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired"));
} }
print '</td></tr>'; print '</td></tr>';
@ -356,19 +356,19 @@ print '</form>'."\n";
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($action != 'edit' && $user->rights->opensurvey->write) { if ($action != 'edit' && $user->rights->opensurvey->write) {
//Modify button //Modify button
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$numsondage.'">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$numsondage.'">'.$langs->trans("Modify").'</a>';
if ($object->status == Opensurveysondage::STATUS_VALIDATED) if ($object->status == Opensurveysondage::STATUS_VALIDATED)
{ {
//Close button //Close button
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=close&id='.$numsondage.'">'.$langs->trans("Close").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=close&id='.$numsondage.'">'.$langs->trans("Close").'</a>';
} }
if ($object->status == Opensurveysondage::STATUS_CLOSED) if ($object->status == Opensurveysondage::STATUS_CLOSED)
{ {
//Opened button //Opened button
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=reopen&id='.$numsondage.'">'.$langs->trans("ReOpen").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=reopen&id='.$numsondage.'">'.$langs->trans("ReOpen").'</a>';
} }
//Delete button //Delete button
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?suppressionsondage=1&id='.$numsondage.'&amp;action=delete">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?suppressionsondage=1&id='.$numsondage.'&amp;action=delete">'.$langs->trans('Delete').'</a>';

File diff suppressed because it is too large Load Diff

View File

@ -2210,7 +2210,7 @@ class Product extends CommonObject
} }
}*/ }*/
} else { } else {
$this->error=$this->db->lasterror; $this->error = $this->db->lasterror;
return -1; return -1;
} }
} }
@ -2255,12 +2255,12 @@ class Product extends CommonObject
} }
$this->prices_by_qty_list[0] = $resultat; $this->prices_by_qty_list[0] = $resultat;
} else { } else {
$this->error=$this->db->lasterror; $this->error = $this->db->lasterror;
return -1; return -1;
} }
} }
} else { } else {
$this->error=$this->db->lasterror; $this->error = $this->db->lasterror;
return -1; return -1;
} }
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES) && empty($ignore_price_load)) // prices per customer and quantity } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES) && empty($ignore_price_load)) // prices per customer and quantity
@ -2314,12 +2314,12 @@ class Product extends CommonObject
} }
$this->prices_by_qty_list[$i] = $resultat; $this->prices_by_qty_list[$i] = $resultat;
} else { } else {
$this->error=$this->db->lasterror; $this->error = $this->db->lasterror;
return -1; return -1;
} }
} }
} else { } else {
$this->error=$this->db->lasterror; $this->error = $this->db->lasterror;
return -1; return -1;
} }
} }
@ -2346,7 +2346,7 @@ class Product extends CommonObject
return 0; return 0;
} }
} else { } else {
$this->error=$this->db->lasterror; $this->error = $this->db->lasterror;
return -1; return -1;
} }
} }
@ -4769,7 +4769,7 @@ class Product extends CommonObject
if ($result < 0) dol_print_error($this->db, $this->error); if ($result < 0) dol_print_error($this->db, $this->error);
$stock_sending_client = $this->stats_expedition['qty']; $stock_sending_client = $this->stats_expedition['qty'];
} }
if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled)) if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled))
{ {
$filterStatus = '1,2,3,4'; $filterStatus = '1,2,3,4';
if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus; if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus;

View File

@ -858,6 +858,52 @@ SCRIPT;
print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1); print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1);
// Definition of fields for lists
// Some fields are missing because they are not included in the database query
$arrayfields = array(
'pfp.datec'=>array('label'=>$langs->trans("AppliedPricesFrom"), 'checked'=>1, 'position'=>1),
's.nom'=>array('label'=>$langs->trans("Suppliers"), 'checked'=>1, 'position'=>2),
'pfp.fk_availability'=>array('label'=>$langs->trans("Availability"), 'enabled' => !empty($conf->global->FOURN_PRODUCT_AVAILABILITY), 'checked'=>0, 'position'=>4),
'pfp.quantity'=>array('label'=>$langs->trans("QtyMin"), 'checked'=>1, 'position'=>5),
'pfp.unitprice'=>array('label'=>$langs->trans("UnitPriceHT"), 'checked'=>1, 'position'=>9),
'pfp.multicurrency_unitprice'=>array('label'=>$langs->trans("UnitPriceHTCurrency"), 'enabled' => $conf->multicurrency->enabled, 'checked'=>0, 'position'=>10),
'pfp.delivery_time_days'=>array('label'=>$langs->trans("NbDaysToDelivery"), 'checked'=>1, 'position'=>13),
'pfp.supplier_reputation'=>array('label'=>$langs->trans("ReputationForThisProduct"), 'checked'=>1, 'position'=>14),
'pfp.barcode'=>array('label'=>$langs->trans("BarcodeValue"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>15),
'pfp.fk_barcode_type'=>array('label'=>$langs->trans("BarcodeType"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>16),
'pfp.packaging'=>array('label'=>$langs->trans("PackagingForThisProduct"), 'enabled' => !empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING), 'checked'=>0, 'position'=>17),
'pfp.tms'=>array('label'=>$langs->trans("DateModification"), 'enabled' => $conf->barcode->enabled, 'checked'=>1, 'position'=>18),
);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label("product_fournisseur_price");
$extralabels = $extrafields->attributes["product_fournisseur_price"]['label'];
if (!empty($extralabels)) {
foreach ($extralabels as $key => $value) {
// Show field if not hidden
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
else $extratitle = $langs->trans($value);
$arrayfields['ef.'.$key] = array('label'=>$extratitle, 'checked'=>0, 'position'=>(end($arrayfields)['position']+1));
}
}
}
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formulaire">';
print '<input type="hidden" name="token" value="'. newToken() . '">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
// Suppliers list title // Suppliers list title
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="liste centpercent">'; print '<table class="liste centpercent">';
@ -865,42 +911,37 @@ SCRIPT;
$param = "&id=".$object->id; $param = "&id=".$object->id;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['pfp.datec']['checked'])) print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("SupplierRef", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("SupplierRef", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['pfp.fk_availability']['checked'])) print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['pfp.quantity']['checked'])) print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("PriceQtyMinHT", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("PriceQtyMinHT", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
if ($conf->multicurrency->enabled) { if ($conf->multicurrency->enabled) print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['pfp.unitprice']['checked'])) print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
} if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right '); if ($conf->multicurrency->enabled) print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
if ($conf->multicurrency->enabled) {
print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
}
print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center ');
if ($conf->barcode->enabled) { if (!empty($arrayfields['pfp.barcode']['checked'])) print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['pfp.packaging']['checked'])) print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder);
} if (!empty($arrayfields['pfp.tms']['checked'])) print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ');
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label("product_fournisseur_price"); $extrafields->fetch_name_optionals_label("product_fournisseur_price");
$extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; $extralabels = $extrafields->attributes["product_fournisseur_price"]['label'];
if (!empty($extralabels)) { if (!empty($extralabels)) {
foreach ($extralabels as $key => $value) { foreach ($extralabels as $key => $value) {
// Show field if not hidden // Show field if not hidden
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
else $extratitle = $langs->trans($value); else $extratitle = $langs->trans($value);
print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['ef.'.$key]['checked'])) print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right ');
} }
} }
} }
@ -910,7 +951,7 @@ SCRIPT;
$parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action);
} }
print_liste_field_titre(''); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
if (is_array($product_fourn_list)) if (is_array($product_fourn_list))
@ -920,10 +961,14 @@ SCRIPT;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Date from // Date from
print '<td>'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation), 'dayhour').'</td>'; if (!empty($arrayfields['pfp.datec']['checked'])) {
print '<td>'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation), 'dayhour').'</td>';
}
// Supplier // Supplier
print '<td>'.$productfourn->getSocNomUrl(1, 'supplier').'</td>'; if (!empty($arrayfields['s.nom']['checked'])) {
print '<td>'.$productfourn->getSocNomUrl(1, 'supplier').'</td>';
}
// Supplier ref // Supplier ref
if ($usercancreate) // change required right here if ($usercancreate) // change required right here
@ -934,7 +979,7 @@ SCRIPT;
} }
// Availability // Availability
if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) if (!empty($arrayfields['pfp.fk_availability']['checked']))
{ {
$form->load_cache_availability(); $form->load_cache_availability();
$availability = $form->cache_availability[$productfourn->fk_availability]['label']; $availability = $form->cache_availability[$productfourn->fk_availability]['label'];
@ -942,16 +987,18 @@ SCRIPT;
} }
// Quantity // Quantity
print '<td class="right">'; if (!empty($arrayfields['pfp.quantity']['checked'])) {
print $productfourn->fourn_qty; print '<td class="right">';
// Units print $productfourn->fourn_qty;
if ($conf->global->PRODUCT_USE_UNITS) { // Units
$unit = $object->getLabelOfUnit(); if ($conf->global->PRODUCT_USE_UNITS) {
if ($unit !== '') { $unit = $object->getLabelOfUnit();
print '&nbsp;&nbsp;'.$langs->trans($unit); if ($unit !== '') {
} print '&nbsp;&nbsp;'.$langs->trans($unit);
} }
print '</td>'; }
print '</td>';
}
// VAT rate // VAT rate
print '<td class="right">'; print '<td class="right">';
@ -971,18 +1018,21 @@ SCRIPT;
} }
// Unit price // Unit price
print '<td class="right">'; if (!empty($arrayfields['pfp.unitprice']['checked'])) {
print price($productfourn->fourn_unitprice); print '<td class="right">';
//print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):"&nbsp;"); print price($productfourn->fourn_unitprice);
print '</td>'; //print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):"&nbsp;");
print '</td>';
}
if ($conf->multicurrency->enabled) { // Unit price in currency
// Unit price in currency if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) {
print '<td class="right">'; print '<td class="right">';
print price($productfourn->fourn_multicurrency_unitprice); print price($productfourn->fourn_multicurrency_unitprice);
print '</td>'; print '</td>';}
// Currency // Currency
if ($conf->multicurrency->enabled) {
print '<td class="right">'; print '<td class="right">';
print $productfourn->fourn_multicurrency_code ? currency_name($productfourn->fourn_multicurrency_code) : ''; print $productfourn->fourn_multicurrency_code ? currency_name($productfourn->fourn_multicurrency_code) : '';
print '</td>'; print '</td>';
@ -994,24 +1044,30 @@ SCRIPT;
print '</td>'; print '</td>';
// Delivery delay // Delivery delay
print '<td class="right">'; if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) {
print $productfourn->delivery_time_days; print '<td class="right">';
print '</td>'; print $productfourn->delivery_time_days;
print '</td>';
}
// Reputation // Reputation
print '<td class="center">'; if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) {
if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) { print '<td class="center">';
print $object->reputations[$productfourn->supplier_reputation]; if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) {
print $object->reputations[$productfourn->supplier_reputation];
}
print'</td>';
} }
print'</td>';
if ($conf->barcode->enabled) { // Barcode
// Barcode if (!empty($arrayfields['pfp.barcode']['checked'])) {
print '<td align="right">'; print '<td align="right">';
print $productfourn->barcode; print $productfourn->barcode;
print '</td>'; print '</td>';
}
// Barcode type // Barcode type
if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) {
print '<td class="center">'; print '<td class="center">';
$productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type : 0; $productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type : 0;
$productfourn->fetch_barcode(); $productfourn->fetch_barcode();
@ -1020,17 +1076,18 @@ SCRIPT;
} }
// Packaging // Packaging
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) if (!empty($arrayfields['pfp.packaging']['checked'])) {
{
print '<td align="center">'; print '<td align="center">';
print price2num($productfourn->packaging); print price2num($productfourn->packaging);
print '</td>'; print '</td>';
} }
// Date // Date
print '<td align="right">'; if (!empty($arrayfields['pfp.tms']['checked'])) {
print dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification), "dayhour"); print '<td align="right">';
print '</td>'; print dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification), "dayhour");
print '</td>';
}
// Extrafields // Extrafields
if (!empty($extralabels)) { if (!empty($extralabels)) {
@ -1045,14 +1102,14 @@ SCRIPT;
if ($resql) { if ($resql) {
if ($db->num_rows($resql) != 1) { if ($db->num_rows($resql) != 1) {
foreach ($extralabels as $key => $value) { foreach ($extralabels as $key => $value) {
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
print "<td></td>"; print "<td></td>";
} }
} }
} else { } else {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
foreach ($extralabels as $key => $value) { foreach ($extralabels as $key => $value) {
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
print '<td align="right">'.$extrafields->showOutputField($key, $obj->{$key})."</td>"; print '<td align="right">'.$extrafields->showOutputField($key, $obj->{$key})."</td>";
} }
} }
@ -1087,6 +1144,7 @@ SCRIPT;
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '</form>';
} }
} }
} }

View File

@ -447,11 +447,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Documents // Documents
if ($includedocgeneration) { if ($includedocgeneration) {
$objref = dol_sanitizeFileName($object->ref); $objref = dol_sanitizeFileName($object->ref);
$relativepath = $objref . '/' . $objref . '.pdf'; $relativepath = $objref.'/'.$objref.'.pdf';
$filedir = $conf->mymodule->dir_output.'/'.$object->element.'/'.$objref; $filedir = $conf->mymodule->dir_output.'/'.$object->element.'/'.$objref;
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content $genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->mymodule->myobject->write; // If you can create/edit, you can remove a file on card $delallowed = $user->rights->mymodule->myobject->write; // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('mymodule:MyObject', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); print $formfile->showdocuments('mymodule:MyObject', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
} }

View File

@ -133,7 +133,7 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors');
} }
if (! $error && ! empty($conf->productbatch->enabled)) { if (!$error && !empty($conf->productbatch->enabled)) {
$tmpproduct = new Product($db); $tmpproduct = new Product($db);
$result = $tmpproduct->fetch($fk_product); $result = $tmpproduct->fetch($fk_product);
@ -320,53 +320,53 @@ if ($object->id > 0)
print '<br>'; print '<br>';
print '</form>'; print '</form>';
} else { } else {
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {
if ($object->status == Inventory::STATUS_DRAFT) if ($object->status == Inventory::STATUS_DRAFT)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").' ('.$langs->trans("Start").')</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").' ('.$langs->trans("Start").')</a>'."\n";
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Validate').' ('.$langs->trans("Start").')</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Validate').' ('.$langs->trans("Start").')</a>'."\n";
} }
} }
if ($object->status == Inventory::STATUS_VALIDATED) if ($object->status == Inventory::STATUS_VALIDATED)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
/* /*
if ($conf->barcode->enabled) { if ($conf->barcode->enabled) {
print '<a href="#" class="butAction">'.$langs->trans("UpdateByScaningProductBarcode").'</a>'; print '<a href="#" class="butAction">'.$langs->trans("UpdateByScaningProductBarcode").'</a>';
} }
if ($conf->productbatch->enabled) { if ($conf->productbatch->enabled) {
print '<a href="#" class="butAction">'.$langs->trans('UpdateByScaningLot').'</a>'; print '<a href="#" class="butAction">'.$langs->trans('UpdateByScaningLot').'</a>';
}*/ }*/
if ($conf->barcode->enabled || $conf->productbatch->enabled) { if ($conf->barcode->enabled || $conf->productbatch->enabled) {
print '<a href="#" class="butAction">'.$langs->trans("UpdateByScaning").'</a>'; print '<a href="#" class="butAction">'.$langs->trans("UpdateByScaning").'</a>';
} }
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Save').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Save').'</a>'."\n";
} }
} }
if ($object->status == Inventory::STATUS_VALIDATED) if ($object->status == Inventory::STATUS_VALIDATED)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=record">'.$langs->trans("Finish").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=record">'.$langs->trans("Finish").'</a>'."\n";
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Finish').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Finish').'</a>'."\n";
} }
} }
/*if ($object->status == Inventory::STATUS_VALIDATED) /*if ($object->status == Inventory::STATUS_VALIDATED)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {

View File

@ -219,7 +219,7 @@ $arrayfields = array(
); );
// MultiPrices // MultiPrices
if ($conf->global->PRODUIT_MULTIPRICES){ if ($conf->global->PRODUIT_MULTIPRICES) {
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{ {
$keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i; $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
@ -753,7 +753,7 @@ if ($resql)
} }
// Multiprice // Multiprice
if ($conf->global->PRODUIT_MULTIPRICES){ if ($conf->global->PRODUIT_MULTIPRICES) {
foreach ($arraypricelevel as $key => $value) foreach ($arraypricelevel as $key => $value)
{ {
if (!empty($arrayfields['p.sellprice'.$key]['checked'])) if (!empty($arrayfields['p.sellprice'.$key]['checked']))
@ -905,7 +905,7 @@ if ($resql)
} }
// Multiprices // Multiprices
if ($conf->global->PRODUIT_MULTIPRICES){ if ($conf->global->PRODUIT_MULTIPRICES) {
foreach ($arraypricelevel as $key => $value) foreach ($arraypricelevel as $key => $value)
{ {
if (!empty($arrayfields['p.sellprice'.$key]['checked'])) if (!empty($arrayfields['p.sellprice'.$key]['checked']))
@ -1265,7 +1265,7 @@ if ($resql)
// Multiprices // Multiprices
if ($conf->global->PRODUIT_MULTIPRICES){ if ($conf->global->PRODUIT_MULTIPRICES) {
foreach ($arraypricelevel as $key => $value) foreach ($arraypricelevel as $key => $value)
{ {
if (!empty($arrayfields['p.sellprice'.$key]['checked'])) if (!empty($arrayfields['p.sellprice'.$key]['checked']))

View File

@ -736,7 +736,7 @@ class Entrepot extends CommonObject
$result .= $linkstart; $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) $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 .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : (empty($this->label)?$this->libelle:$this->label)); if ($withpicto != 2) $result .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : (empty($this->label) ? $this->libelle : $this->label));
$result .= $linkend; $result .= $linkend;
global $action; global $action;

View File

@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productstockentrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productstockentrepot.class.php';
if (!empty($conf->productbatch->enabled)) { if (!empty($conf->productbatch->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
} }
if (!empty($conf->projet->enabled)) { if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
@ -88,7 +88,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref))
{ {
$result = $object->fetch($id, $ref); $result = $object->fetch($id, $ref);
} }
if (empty($id) && !empty($object->id)) $id = $object->id; if (empty($id) && !empty($object->id)) $id = $object->id;
@ -100,9 +100,9 @@ $canvas = !empty($object->canvas) ? $object->canvas : GETPOST("canvas");
$objcanvas = null; $objcanvas = null;
if (!empty($canvas)) if (!empty($canvas))
{ {
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action); $objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('stockproduct', 'card', $canvas); $objcanvas->getCanvas('stockproduct', 'card', $canvas);
} }
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@ -168,27 +168,27 @@ if ($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->
// Set stock limit // Set stock limit
if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer)) if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer))
{ {
$object = new Product($db); $object = new Product($db);
$result = $object->fetch($id); $result = $object->fetch($id);
$object->seuil_stock_alerte = $stocklimit; $object->seuil_stock_alerte = $stocklimit;
$result = $object->update($object->id, $user, 0, 'update'); $result = $object->update($object->id, $user, 0, 'update');
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
//else //else
// setEventMessages($lans->trans("SavedRecordSuccessfully"), null, 'mesgs'); // setEventMessages($lans->trans("SavedRecordSuccessfully"), null, 'mesgs');
$action = ''; $action = '';
} }
// Set desired stock // Set desired stock
if ($action == 'setdesiredstock' && !empty($user->rights->produit->creer)) if ($action == 'setdesiredstock' && !empty($user->rights->produit->creer))
{ {
$object = new Product($db); $object = new Product($db);
$result = $object->fetch($id); $result = $object->fetch($id);
$object->desiredstock = $desiredstock; $object->desiredstock = $desiredstock;
$result = $object->update($object->id, $user, 0, 'update'); $result = $object->update($object->id, $user, 0, 'update');
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = ''; $action = '';
} }
@ -258,12 +258,12 @@ if ($action == "correct_stock" && !$cancel)
); // We do not change value of stock for a correction ); // We do not change value of stock for a correction
} else { } else {
$result = $object->correct_stock( $result = $object->correct_stock(
$user, $user,
GETPOST("id_entrepot", 'int'), GETPOST("id_entrepot", 'int'),
$nbpiece, $nbpiece,
GETPOST("mouvement", 'int'), GETPOST("mouvement", 'int'),
GETPOST("label", 'alphanohtml'), GETPOST("label", 'alphanohtml'),
$priceunit, $priceunit,
GETPOST('inventorycode', 'alphanohtml'), GETPOST('inventorycode', 'alphanohtml'),
$origin_element, $origin_element,
$origin_id $origin_id
@ -277,12 +277,12 @@ if ($action == "correct_stock" && !$cancel)
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} else { } else {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
exit; exit;
} }
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'correction'; $action = 'correction';
} }
} }
} }
@ -311,15 +311,15 @@ if ($action == "transfert_stock" && !$cancel)
} }
if (!empty($conf->productbatch->enabled)) if (!empty($conf->productbatch->enabled))
{ {
$object = new Product($db); $object = new Product($db);
$result = $object->fetch($id); $result = $object->fetch($id);
if ($object->hasbatch() && !$batchnumber) if ($object->hasbatch() && !$batchnumber)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors');
$error++; $error++;
$action = 'transfert'; $action = 'transfert';
} }
} }
if (!$error) if (!$error)
@ -399,31 +399,31 @@ if ($action == "transfert_stock" && !$cancel)
} else { } else {
if (!$error) if (!$error)
{ {
// Remove stock // Remove stock
$result1 = $object->correct_stock( $result1 = $object->correct_stock(
$user, $user,
GETPOST("id_entrepot", 'int'), GETPOST("id_entrepot", 'int'),
$nbpiece, $nbpiece,
1, 1,
GETPOST("label", 'alphanohtml'), GETPOST("label", 'alphanohtml'),
$pricesrc, $pricesrc,
GETPOST('inventorycode', 'alphanohtml') GETPOST('inventorycode', 'alphanohtml')
); );
if ($result1 < 0) $error++; if ($result1 < 0) $error++;
} }
if (!$error) if (!$error)
{ {
// Add stock // Add stock
$result2 = $object->correct_stock( $result2 = $object->correct_stock(
$user, $user,
GETPOST("id_entrepot_destination", 'int'), GETPOST("id_entrepot_destination", 'int'),
$nbpiece, $nbpiece,
0, 0,
GETPOST("label", 'alphanohtml'), GETPOST("label", 'alphanohtml'),
$pricedest, $pricedest,
GETPOST('inventorycode', 'alphanohtml') GETPOST('inventorycode', 'alphanohtml')
); );
if ($result2 < 0) $error++; if ($result2 < 0) $error++;
} }
} }
@ -452,35 +452,35 @@ if ($action == "transfert_stock" && !$cancel)
// Update batch information // Update batch information
if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save'))
{ {
$pdluo = new Productbatch($db); $pdluo = new Productbatch($db);
$result = $pdluo->fetch(GETPOST('pdluoid', 'int')); $result = $pdluo->fetch(GETPOST('pdluoid', 'int'));
if ($result > 0) if ($result > 0)
{ {
if ($pdluo->id) if ($pdluo->id)
{ {
if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) { if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors');
} else { } else {
$d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); $d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']);
$d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); $d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']);
$pdluo->batch = $batchnumber; $pdluo->batch = $batchnumber;
$pdluo->eatby = $d_eatby; $pdluo->eatby = $d_eatby;
$pdluo->sellby = $d_sellby; $pdluo->sellby = $d_sellby;
$result = $pdluo->update($user); $result = $pdluo->update($user);
if ($result < 0) if ($result < 0)
{ {
setEventMessages($pdluo->error, $pdluo->errors, 'errors'); setEventMessages($pdluo->error, $pdluo->errors, 'errors');
} }
} }
} else { } else {
setEventMessages($langs->trans('BatchInformationNotfound'), null, 'errors'); setEventMessages($langs->trans('BatchInformationNotfound'), null, 'errors');
} }
} else { } else {
setEventMessages($pdluo->error, null, 'errors'); setEventMessages($pdluo->error, null, 'errors');
} }
header("Location: product.php?id=".$id); header("Location: product.php?id=".$id);
exit; exit;
} }
@ -528,17 +528,17 @@ if ($id > 0 || $ref)
dol_htmloutput_events(); dol_htmloutput_events();
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$shownav = 1; $shownav = 1;
if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
if (!$variants) { if (!$variants) {
if ($conf->productbatch->enabled) { if ($conf->productbatch->enabled) {
@ -629,7 +629,7 @@ if ($id > 0 || $ref)
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill").'<br>' : ''); $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder").'<br>' : ''); $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder").'<br>' : ''); $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? $langs->trans("StockOnReception").'<br>' : ''); $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? $langs->trans("StockOnReception").'<br>' : '');
print '<tr><td>'; print '<tr><td>';
print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1);
@ -656,13 +656,13 @@ if ($id > 0 || $ref)
// Number of product from customer order already sent (partial shipping) // Number of product from customer order already sent (partial shipping)
if (!empty($conf->expedition->enabled)) { if (!empty($conf->expedition->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
$filterShipmentStatus = ''; $filterShipmentStatus = '';
if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
$filterShipmentStatus = Expedition::STATUS_VALIDATED.','.Expedition::STATUS_CLOSED; $filterShipmentStatus = Expedition::STATUS_VALIDATED.','.Expedition::STATUS_CLOSED;
} elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
$filterShipmentStatus = Expedition::STATUS_CLOSED; $filterShipmentStatus = Expedition::STATUS_CLOSED;
} }
if ($found) $helpondiff .= '<br>'; else $found = 1; if ($found) $helpondiff .= '<br>'; else $found = 1;
$result = $object->load_stats_sending(0, '2', 1, $filterShipmentStatus); $result = $object->load_stats_sending(0, '2', 1, $filterShipmentStatus);
$helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty'];
@ -730,8 +730,8 @@ if ($id > 0 || $ref)
} }
print "</table>"; print "</table>";
print '</div>'; print '</div>';
print '<div style="clear:both"></div>'; print '<div style="clear:both"></div>';
dol_fiche_end(); dol_fiche_end();
} }
@ -763,7 +763,7 @@ if (empty($reshook))
{ {
if (empty($action) && $object->id) if (empty($action) && $object->id)
{ {
print "<div class=\"tabsAction\">\n"; print "<div class=\"tabsAction\">\n";
if ($user->rights->stock->mouvement->creer) if ($user->rights->stock->mouvement->creer)
{ {

View File

@ -492,7 +492,7 @@ class Project extends CommonObject
$sql .= " WHERE entity IN (".getEntity('project').")"; $sql .= " WHERE entity IN (".getEntity('project').")";
if (!empty($ref)) { if (!empty($ref)) {
$sql .= " AND ref = '".$this->db->escape($ref)."'"; $sql .= " AND ref = '".$this->db->escape($ref)."'";
} elseif (! empty($ref_ext)) { } elseif (!empty($ref_ext)) {
$sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; $sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'";
} else { } else {
$sql .= " AND email_msgid = '".$this->db->escape($email_msgid)."'"; $sql .= " AND email_msgid = '".$this->db->escape($email_msgid)."'";

View File

@ -321,14 +321,14 @@ $NBMAX = 3;
$max = 3; $max = 3;
// Last modified job position // Last modified job position
if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
{ {
$sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status"; $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status";
$sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s"; $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; $sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql.= " AND s.fk_soc = $socid"; if ($socid) $sql .= " AND s.fk_soc = $socid";
$sql .= " ORDER BY s.tms DESC"; $sql .= " ORDER BY s.tms DESC";
$sql .= $db->plimit($max, 0); $sql .= $db->plimit($max, 0);
@ -379,15 +379,15 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitm
} }
// Last modified job position // Last modified job position
if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
{ {
$sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status"; $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
$sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql.= " AND s.fk_soc = $socid"; if ($socid) $sql .= " AND s.fk_soc = $socid";
$sql .= " ORDER BY rc.tms DESC"; $sql .= " ORDER BY rc.tms DESC";
$sql .= $db->plimit($max, 0); $sql .= $db->plimit($max, 0);
@ -409,9 +409,9 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitm
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$staticrecruitmentcandidature->id=$objp->rowid; $staticrecruitmentcandidature->id = $objp->rowid;
$staticrecruitmentcandidature->ref=$objp->ref; $staticrecruitmentcandidature->ref = $objp->ref;
$staticrecruitmentcandidature->email=$objp->email; $staticrecruitmentcandidature->email = $objp->email;
$staticrecruitmentcandidature->status = $objp->status; $staticrecruitmentcandidature->status = $objp->status;
$staticrecruitmentcandidature->date_creation = $objp->date_creation; $staticrecruitmentcandidature->date_creation = $objp->date_creation;
$staticrecruitmentcandidature->firstname = $objp->firstname; $staticrecruitmentcandidature->firstname = $objp->firstname;

View File

@ -36,11 +36,11 @@ class Stripe extends CommonObject
/** /**
* @var int Thirdparty ID * @var int Thirdparty ID
*/ */
public $fk_soc; public $fk_soc;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_key; public $fk_key;
/** /**
@ -62,9 +62,9 @@ class Stripe extends CommonObject
public $code; public $code;
public $declinecode; public $declinecode;
/** /**
* @var string Message * @var string Message
*/ */
public $message; public $message;
/** /**
@ -102,21 +102,21 @@ class Stripe extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
if ($this->db->num_rows($result)) { if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$tokenstring = $obj->tokenstring; $tokenstring = $obj->tokenstring;
$tmparray = dol_json_decode($tokenstring); $tmparray = dol_json_decode($tokenstring);
$key = $tmparray->stripe_user_id; $key = $tmparray->stripe_user_id;
} else { } else {
$tokenstring = ''; $tokenstring = '';
} }
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }
dol_syslog("No dedicated Stripe Connect account available for entity ".$conf->entity); dol_syslog("No dedicated Stripe Connect account available for entity ".$conf->entity);
return $key; return $key;
} }
@ -194,7 +194,7 @@ class Stripe extends CommonObject
} }
} elseif ($createifnotlinkedtostripe) } elseif ($createifnotlinkedtostripe)
{ {
$ipaddress = getUserRemoteIP(); $ipaddress = getUserRemoteIP();
$dataforcustomer = array( $dataforcustomer = array(
"email" => $object->email, "email" => $object->email,
@ -291,9 +291,9 @@ class Stripe extends CommonObject
return $stripepaymentmethod; return $stripepaymentmethod;
} }
/** /**
* Get the Stripe payment intent. Create it with confirmnow=false * Get the Stripe payment intent. Create it with confirmnow=false
* Warning. If a payment was tried and failed, a payment intent was created. * Warning. If a payment was tried and failed, a payment intent was created.
* But if we change something on object to pay (amount or other), reusing same payment intent is not allowed by Stripe. * But if we change something on object to pay (amount or other), reusing same payment intent is not allowed by Stripe.
* Recommended solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), * Recommended solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay),
* that's why i comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) * that's why i comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used)
@ -333,9 +333,9 @@ class Stripe extends CommonObject
$fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE; $fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE;
if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
$fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL; $fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL;
} elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
$fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL;
} }
if (!in_array($currency_code, $arrayzerounitcurrency)) { if (!in_array($currency_code, $arrayzerounitcurrency)) {
$stripefee = round($fee * 100); $stripefee = round($fee * 100);
@ -345,7 +345,7 @@ class Stripe extends CommonObject
$paymentintent = null; $paymentintent = null;
if (is_object($object) && ! empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND)) if (is_object($object) && !empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND))
{ {
// Warning. If a payment was tried and failed, a payment intent was created. // Warning. If a payment was tried and failed, a payment intent was created.
// But if we change something on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed by Stripe. // But if we change something on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed by Stripe.
@ -354,167 +354,167 @@ class Stripe extends CommonObject
// That's why we can comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) // That's why we can comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used)
$sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site"; $sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site";
$sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi"; $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi";
$sql.= " WHERE pi.fk_facture = " . $object->id; $sql.= " WHERE pi.fk_facture = " . $object->id;
$sql.= " AND pi.sourcetype = '" . $object->element . "'"; $sql.= " AND pi.sourcetype = '" . $object->element . "'";
$sql.= " AND pi.entity IN (".getEntity('societe').")"; $sql.= " AND pi.entity IN (".getEntity('societe').")";
$sql.= " AND pi.ext_payment_site = '" . $service . "'"; $sql.= " AND pi.ext_payment_site = '" . $service . "'";
dol_syslog(get_class($this) . "::getPaymentIntent search stripe payment intent for object id = ".$object->id, LOG_DEBUG); dol_syslog(get_class($this) . "::getPaymentIntent search stripe payment intent for object id = ".$object->id, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$intent = $obj->ext_payment_id; $intent = $obj->ext_payment_id;
dol_syslog(get_class($this) . "::getPaymentIntent found existing payment intent record"); dol_syslog(get_class($this) . "::getPaymentIntent found existing payment intent record");
// Force to use the correct API key // Force to use the correct API key
global $stripearrayofkeysbyenv; global $stripearrayofkeysbyenv;
\Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']);
try { try {
if (empty($key)) { // If the Stripe connect account not set, we use common API usage if (empty($key)) { // If the Stripe connect account not set, we use common API usage
$paymentintent = \Stripe\PaymentIntent::retrieve($intent); $paymentintent = \Stripe\PaymentIntent::retrieve($intent);
} else { } else {
$paymentintent = \Stripe\PaymentIntent::retrieve($intent, array("stripe_account" => $key)); $paymentintent = \Stripe\PaymentIntent::retrieve($intent, array("stripe_account" => $key));
} }
} }
catch (Exception $e) { catch (Exception $e) {
$error++; $error++;
$this->error = $e->getMessage(); $this->error = $e->getMessage();
} }
} }
} }
} }
if (empty($paymentintent)) if (empty($paymentintent))
{ {
$ipaddress = getUserRemoteIP(); $ipaddress = getUserRemoteIP();
$metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress); $metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress);
if (is_object($object)) if (is_object($object))
{ {
$metadata['dol_type'] = $object->element; $metadata['dol_type'] = $object->element;
$metadata['dol_id'] = $object->id; $metadata['dol_id'] = $object->id;
if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id; if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id;
} }
// list of payment method types // list of payment method types
$paymentmethodtypes = array("card"); $paymentmethodtypes = array("card");
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
if (!empty($conf->global->STRIPE_IDEAL) ) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC()) if (!empty($conf->global->STRIPE_IDEAL) ) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC())
$dataforintent = array( $dataforintent = array(
"confirm" => $confirmnow, // Do not confirm immediatly during creation of intent "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent
"confirmation_method" => $mode, "confirmation_method" => $mode,
"amount" => $stripeamount, "amount" => $stripeamount,
"currency" => $currency_code, "currency" => $currency_code,
"payment_method_types" => $paymentmethodtypes, "payment_method_types" => $paymentmethodtypes,
"description" => $description, "description" => $description,
"statement_descriptor_suffix" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "statement_descriptor_suffix" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description)
//"save_payment_method" => true, //"save_payment_method" => true,
"setup_future_usage" => "on_session", "setup_future_usage" => "on_session",
"metadata" => $metadata "metadata" => $metadata
); );
if (!is_null($customer)) $dataforintent["customer"] = $customer; if (!is_null($customer)) $dataforintent["customer"] = $customer;
// payment_method = // payment_method =
// payment_method_types = array('card') // payment_method_types = array('card')
//var_dump($dataforintent); //var_dump($dataforintent);
if ($off_session) if ($off_session)
{ {
unset($dataforintent['setup_future_usage']); unset($dataforintent['setup_future_usage']);
$dataforintent["off_session"] = true; $dataforintent["off_session"] = true;
} }
if (!is_null($payment_method)) if (!is_null($payment_method))
{ {
$dataforintent["payment_method"] = $payment_method; $dataforintent["payment_method"] = $payment_method;
$description .= ' - '.$payment_method; $description .= ' - '.$payment_method;
} }
if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0)
{ {
$dataforintent["application_fee_amount"] = $stripefee; $dataforintent["application_fee_amount"] = $stripefee;
} }
if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email)
{ {
$dataforintent["receipt_email"] = $object->thirdparty->email; $dataforintent["receipt_email"] = $object->thirdparty->email;
} }
try { try {
// Force to use the correct API key // Force to use the correct API key
global $stripearrayofkeysbyenv; global $stripearrayofkeysbyenv;
\Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']);
$arrayofoptions = array(); $arrayofoptions = array();
if (empty($noidempotency_key)) { if (empty($noidempotency_key)) {
$arrayofoptions["idempotency_key"] = $description; $arrayofoptions["idempotency_key"] = $description;
} }
// Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent. // Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent.
if (!empty($key)) { // If the Stripe connect account not set, we use common API usage if (!empty($key)) { // If the Stripe connect account not set, we use common API usage
$arrayofoptions["stripe_account"] = $key; $arrayofoptions["stripe_account"] = $key;
} }
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions); $paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions);
// Store the payment intent // Store the payment intent
if (is_object($object)) if (is_object($object))
{ {
$paymentintentalreadyexists = 0; $paymentintentalreadyexists = 0;
// Check that payment intent $paymentintent->id is not already recorded. // Check that payment intent $paymentintent->id is not already recorded.
$sql = "SELECT pi.rowid"; $sql = "SELECT pi.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi";
$sql .= " WHERE pi.entity IN (".getEntity('societe').")"; $sql .= " WHERE pi.entity IN (".getEntity('societe').")";
$sql .= " AND pi.ext_payment_site = '".$service."'"; $sql .= " AND pi.ext_payment_site = '".$service."'";
$sql .= " AND pi.ext_payment_id = '".$this->db->escape($paymentintent->id)."'"; $sql .= " AND pi.ext_payment_id = '".$this->db->escape($paymentintent->id)."'";
dol_syslog(get_class($this)."::getPaymentIntent search if payment intent already in prelevement_facture_demande", LOG_DEBUG); dol_syslog(get_class($this)."::getPaymentIntent search if payment intent already in prelevement_facture_demande", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) $paymentintentalreadyexists++; if ($obj) $paymentintentalreadyexists++;
} }
} else dol_print_error($this->db); } else dol_print_error($this->db);
// If not, we create it. // If not, we create it.
if (!$paymentintentalreadyexists) if (!$paymentintentalreadyexists)
{ {
$now = dol_now(); $now = dol_now();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)";
$sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", '".$this->db->escape($paymentintent->id)."', ".$object->id.", '".$this->db->escape($object->element)."', ".$conf->entity.", '".$service."', ".$amount.")"; $sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", '".$this->db->escape($paymentintent->id)."', ".$object->id.", '".$this->db->escape($object->element)."', ".$conf->entity.", '".$service."', ".$amount.")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) if (!$resql)
{ {
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database."); dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database.");
} }
} }
} else { } else {
$_SESSION["stripe_payment_intent"] = $paymentintent; $_SESSION["stripe_payment_intent"] = $paymentintent;
} }
} catch (Stripe\Error\Card $e) } catch (Stripe\Error\Card $e)
{ {
$error++; $error++;
$this->error = $e->getMessage(); $this->error = $e->getMessage();
$this->code = $e->getStripeCode(); $this->code = $e->getStripeCode();
$this->declinecode = $e->getDeclineCode(); $this->declinecode = $e->getDeclineCode();
} catch (Exception $e) } catch (Exception $e)
{ {
/*var_dump($dataforintent); /*var_dump($dataforintent);
var_dump($description); var_dump($description);
var_dump($key); var_dump($key);
var_dump($paymentintent); var_dump($paymentintent);
var_dump($e->getMessage()); var_dump($e->getMessage());
var_dump($e);*/ var_dump($e);*/
$error++; $error++;
$this->error = $e->getMessage(); $this->error = $e->getMessage();
$this->code = ''; $this->code = '';
$this->declinecode = ''; $this->declinecode = '';
} }
} }
dol_syslog("getPaymentIntent return error=".$error." this->error=".$this->error, LOG_INFO, -1); dol_syslog("getPaymentIntent return error=".$error." this->error=".$this->error, LOG_INFO, -1);
@ -572,7 +572,7 @@ class Stripe extends CommonObject
// list of payment method types // list of payment method types
$paymentmethodtypes = array("card"); $paymentmethodtypes = array("card");
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
// iDEAL not supported with setupIntent // iDEAL not supported with setupIntent
$dataforintent = array( $dataforintent = array(
@ -933,10 +933,10 @@ class Stripe extends CommonObject
} }
} elseif (preg_match('/acct_/i', $source)) } elseif (preg_match('/acct_/i', $source))
{ {
$charge = \Stripe\Charge::create(array( $charge = \Stripe\Charge::create(array(
"amount" => "$stripeamount", "amount" => "$stripeamount",
"currency" => "$currency", "currency" => "$currency",
"statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description)
"description" => "Stripe payment: ".$description, "description" => "Stripe payment: ".$description,
"capture" => $capture, "capture" => $capture,
"metadata" => $metadata, "metadata" => $metadata,
@ -946,7 +946,7 @@ class Stripe extends CommonObject
$paymentarray = array( $paymentarray = array(
"amount" => "$stripeamount", "amount" => "$stripeamount",
"currency" => "$currency", "currency" => "$currency",
"statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description)
"description" => "Stripe payment: ".$description, "description" => "Stripe payment: ".$description,
"capture" => $capture, "capture" => $capture,
"metadata" => $metadata, "metadata" => $metadata,
@ -965,9 +965,9 @@ class Stripe extends CommonObject
// With Stripe Connect // With Stripe Connect
$fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE; $fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE;
if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
$fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL; $fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL;
} elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
$fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL;
} }
if (!in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100); if (!in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100);

File diff suppressed because it is too large Load Diff

View File

@ -369,38 +369,38 @@ if ($action == "freezone") {
$tva_tx = get_default_tva($mysoc, $customer); $tva_tx = get_default_tva($mysoc, $customer);
} }
// Local Taxes // Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
$invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0);
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
if ($action == "addnote") { if ($action == "addnote") {
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line)
{ {
if ($line->id == $number) if ($line->id == $number)
{ {
$line->array_options['order_notes'] = $desc; $line->array_options['order_notes'] = $desc;
$result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
} }
} }
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
if ($action == "deleteline") { if ($action == "deleteline") {
if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected.
$invoice->deleteline($idline); $invoice->deleteline($idline);
$invoice->fetch($placeid); $invoice->fetch($placeid);
} elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line.
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture='".$placeid."' order by rowid DESC"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture='".$placeid."' order by rowid DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
$row = $db->fetch_array($resql); $row = $db->fetch_array($resql);
$deletelineid = $row[0]; $deletelineid = $row[0];
$invoice->deleteline($deletelineid); $invoice->deleteline($deletelineid);
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
if (count($invoice->lines) == 0) $invoice->delete($user); if (count($invoice->lines) == 0) $invoice->delete($user);
} }
@ -830,7 +830,7 @@ $( document ).ready(function() {
$s .= '<br>'.$langs->trans("SubscriptionNotReceived"); $s .= '<br>'.$langs->trans("SubscriptionNotReceived");
if ($adh->statut > 0) $s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated if ($adh->statut > 0) $s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
} }
if (empty($adh->statut)) { $s .= "</s>"; } if (empty($adh->statut)) { $s .= "</s>"; }
} else { } else {
$s .= '<br>'.$langs->trans("ThirdpartyNotLinkedToMember"); $s .= '<br>'.$langs->trans("ThirdpartyNotLinkedToMember");
} }
@ -1011,47 +1011,47 @@ if ($placeid > 0)
$htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n"; $htmlsupplements[$line->fk_parent_line] .= '</tr>'."\n";
continue; continue;
} }
$htmlforlines = ''; $htmlforlines = '';
$htmlforlines .= '<tr class="drag drop oddeven posinvoiceline'; $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
if ($line->special_code == "4") { if ($line->special_code == "4") {
$htmlforlines .= ' order'; $htmlforlines .= ' order';
} }
$htmlforlines .= '" id="'.$line->id.'">'; $htmlforlines .= '" id="'.$line->id.'">';
$htmlforlines .= '<td class="left">'; $htmlforlines .= '<td class="left">';
if ($_SESSION["basiclayout"] == 1) $htmlforlines .= '<span class="phoneqty">'.$line->qty."</span> x "; if ($_SESSION["basiclayout"] == 1) $htmlforlines .= '<span class="phoneqty">'.$line->qty."</span> x ";
if (isset($line->product_type)) if (isset($line->product_type))
{ {
if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' '; if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' ';
else $htmlforlines .= img_object('', 'service').' '; else $htmlforlines .= img_object('', 'service').' ';
} }
if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) { if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) {
$tooltiptext = ''; $tooltiptext = '';
if ($line->product_ref) { if ($line->product_ref) {
$tooltiptext .= '<b>'.$langs->trans("Ref").'</b> : '.$line->product_ref.'<br>'; $tooltiptext .= '<b>'.$langs->trans("Ref").'</b> : '.$line->product_ref.'<br>';
$tooltiptext .= '<b>'.$langs->trans("Label").'</b> : '.$line->product_label.'<br>'; $tooltiptext .= '<b>'.$langs->trans("Label").'</b> : '.$line->product_label.'<br>';
if ($line->product_label != $line->desc) { if ($line->product_label != $line->desc) {
if ($line->desc) $tooltiptext .= '<br>'; if ($line->desc) $tooltiptext .= '<br>';
$tooltiptext .= $line->desc; $tooltiptext .= $line->desc;
} }
} }
$htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
} else { } else {
if ($line->product_label) $htmlforlines .= $line->product_label; if ($line->product_label) $htmlforlines .= $line->product_label;
if ($line->product_label != $line->desc) if ($line->product_label != $line->desc)
{ {
if ($line->product_label && $line->desc) $htmlforlines .= '<br>'; if ($line->product_label && $line->desc) $htmlforlines .= '<br>';
$firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES); $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES);
if ($firstline != $line->desc) if ($firstline != $line->desc)
{ {
$htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
} else { } else {
$htmlforlines .= $line->desc; $htmlforlines .= $line->desc;
} }
} }
} }
if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "<br>(".$line->array_options['options_order_notes'].")"; if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "<br>(".$line->array_options['options_order_notes'].")";
if ($_SESSION["basiclayout"] == 1) $htmlforlines .= '</td><td class="right phonetable"><button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty - 1).');" class="publicphonebutton2 phonered">-</button>&nbsp;&nbsp;<button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty + 1).');" class="publicphonebutton2 phonegreen">+</button>'; if ($_SESSION["basiclayout"] == 1) $htmlforlines .= '</td><td class="right phonetable"><button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty - 1).');" class="publicphonebutton2 phonered">-</button>&nbsp;&nbsp;<button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty + 1).');" class="publicphonebutton2 phonegreen">+</button>';
if ($_SESSION["basiclayout"] != 1) if ($_SESSION["basiclayout"] != 1)
{ {
$moreinfo = ''; $moreinfo = '';

View File

@ -138,7 +138,7 @@ if (empty($reshook)) {
if ($cancel) { if ($cancel) {
if (!empty($backtopage)) { if (!empty($backtopage)) {
header("Location: " . $backtopage); header("Location: ".$backtopage);
exit; exit;
} }
@ -254,10 +254,10 @@ if (empty($reshook)) {
if (!empty($backtopage)) { if (!empty($backtopage)) {
$url = $backtopage; $url = $backtopage;
} else { } else {
$url = 'card.php?track_id=' . $object->track_id; $url = 'card.php?track_id='.$object->track_id;
} }
header("Location: " . $url); header("Location: ".$url);
exit; exit;
} else { } else {
$db->rollback(); $db->rollback();
@ -268,53 +268,55 @@ if (empty($reshook)) {
} }
} }
if ($action == 'edit' && $user->rights->ticket->write) { if ($action == 'update' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) {
$error = 0; $error = 0;
if ($object->fetch(GETPOST('id', 'int')) < 0) { $ret = $object->fetch(GETPOST('id', 'int'), GETPOST('ref', 'alpha'), GETPOST('track_id', 'alpha'));
$error++;
array_push($object->errors, $langs->trans("ErrorTicketIsNotValid"));
$_GET["action"] = $_POST["action"] = '';
}
}
if (GETPOST('update', 'alpha') && GETPOST('id', 'int') && $user->rights->ticket->write) {
$error = 0;
$ret = $object->fetch(GETPOST('id', 'int'));
if ($ret < 0) { if ($ret < 0) {
$error++; $error++;
array_push($object->errors, $langs->trans("ErrorTicketIsNotValid")); array_push($object->errors, $langs->trans('ErrorTicketIsNotValid'));
$action = ''; }
} elseif (!GETPOST("label")) {
$error++; // check fields
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"))); if (!$error) {
$action = 'edit'; if (!GETPOST('subject', 'alpha')) {
} elseif (!GETPOST("subject", 'alphanohtml')) { $error++;
$error++; array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject')));
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"))); }
$action = 'edit'; $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
} }
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$object->label = GETPOST("label", 'alphanohtml'); $object->subject = GETPOST('subject', 'alpha');
$object->description = GETPOST("description", 'restricthtml'); $object->type_code = GETPOST('type_code', 'alpha');
$object->category_code = GETPOST('category_code', 'alpha');
$object->severity_code = GETPOST('severity_code', 'alpha');
//...
$ret = $object->update($user); $ret = $object->update($user);
if ($ret <= 0) { if ($ret <= 0) $error++;
$error++;
setEventMessages($object->error, $object->errors, 'errors'); if ($error) {
$action = 'edit'; $db->rollback();
} else {
$db->commit();
}
}
if ($error) {
setEventMessages($object->error, $object->errors, 'errors');
$action = 'edit';
} else {
if (!empty($backtopage)) {
$url = $backtopage;
} else {
$url = 'card.php?track_id=' . $object->track_id;
} }
if (!$error && $ret > 0) { header('Location: ' . $url);
$db->commit(); exit();
} else {
$db->rollback();
}
} }
} }
@ -325,7 +327,7 @@ if (empty($reshook)) {
if ($object->markAsRead($user) > 0) { if ($object->markAsRead($user) > 0) {
setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
header("Location: card.php?track_id=" . $object->track_id . "&action=view"); header("Location: card.php?track_id=".$object->track_id."&action=view");
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -376,7 +378,7 @@ if (empty($reshook)) {
setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
header("Location: card.php?track_id=" . $object->track_id . "&action=view"); header("Location: card.php?track_id=".$object->track_id."&action=view");
exit; exit;
} else { } else {
array_push($object->errors, $object->error); array_push($object->errors, $object->error);
@ -392,10 +394,10 @@ if (empty($reshook)) {
if (!empty($backtopage)) { if (!empty($backtopage)) {
$url = $backtopage; $url = $backtopage;
} else { } else {
$url = 'card.php?action=view&track_id=' . $object->track_id; $url = 'card.php?action=view&track_id='.$object->track_id;
} }
header("Location: " . $url); header("Location: ".$url);
exit; exit;
} else { } else {
setEventMessages($object->error, null, 'errors'); setEventMessages($object->error, null, 'errors');
@ -409,8 +411,8 @@ if (empty($reshook)) {
if ($object->close($user)) { if ($object->close($user)) {
setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
$url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
header("Location: " . $url); header("Location: ".$url);
} else { } else {
$action = ''; $action = '';
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -425,10 +427,10 @@ if (empty($reshook)) {
// Log action in ticket logs table // Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
setEventMessages('<div class="confirm">' . $langs->trans('TicketMarkedAsClosed') . '</div>', null, 'mesgs'); setEventMessages('<div class="confirm">'.$langs->trans('TicketMarkedAsClosed').'</div>', null, 'mesgs');
$url = 'card.php?action=view_ticket&track_id=' . GETPOST('track_id', 'alpha'); $url = 'card.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha');
header("Location: " . $url); header("Location: ".$url);
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = ''; $action = '';
@ -438,12 +440,12 @@ if (empty($reshook)) {
if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) { if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
if ($object->delete($user) > 0) { if ($object->delete($user) > 0) {
setEventMessages('<div class="confirm">' . $langs->trans('TicketDeletedSuccess') . '</div>', null, 'mesgs'); setEventMessages('<div class="confirm">'.$langs->trans('TicketDeletedSuccess').'</div>', null, 'mesgs');
Header("Location: " . DOL_URL_ROOT . "/ticket/list.php"); Header("Location: ".DOL_URL_ROOT."/ticket/list.php");
exit; exit;
} else { } else {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">' . $langs->trans($object->error) . '</div>'; $mesg = '<div class="error">'.$langs->trans($object->error).'</div>';
$action = ''; $action = '';
} }
} }
@ -453,8 +455,8 @@ if (empty($reshook)) {
if ($action == 'set_thirdparty' && $user->rights->societe->creer) { if ($action == 'set_thirdparty' && $user->rights->societe->creer) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$result = $object->setCustomer(GETPOST('editcustomer', 'int')); $result = $object->setCustomer(GETPOST('editcustomer', 'int'));
$url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
header("Location: " . $url); header("Location: ".$url);
exit(); exit();
} }
} }
@ -463,8 +465,8 @@ if (empty($reshook)) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$result = $object->setProgression(GETPOST('progress', 'alpha')); $result = $object->setProgression(GETPOST('progress', 'alpha'));
$url = 'card.php?action=view&track_id=' . $object->track_id; $url = 'card.php?action=view&track_id='.$object->track_id;
header("Location: " . $url); header("Location: ".$url);
exit(); exit();
} }
} }
@ -476,12 +478,12 @@ if (empty($reshook)) {
} }
if ($action == 'setsubject' && empty($object->subject)) { if ($action == 'setsubject' && empty($object->subject)) {
$mesg .= ($mesg ? '<br>' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); $mesg .= ($mesg ? '<br>' : '').$langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"));
} }
if (!$mesg) { if (!$mesg) {
if ($object->update($user) >= 0) { if ($object->update($user) >= 0) {
header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id); header("Location: ".$_SERVER['PHP_SELF']."?track_id=".$object->track_id);
exit; exit;
} }
$mesg = $object->error; $mesg = $object->error;
@ -498,8 +500,8 @@ if (empty($reshook)) {
// Log action in ticket logs table // Log action in ticket logs table
$log_action = $langs->trans('TicketLogReopen'); $log_action = $langs->trans('TicketLogReopen');
$url = 'card.php?action=view&track_id=' . $object->track_id; $url = 'card.php?action=view&track_id='.$object->track_id;
header("Location: " . $url); header("Location: ".$url);
exit(); exit();
} }
} }
@ -508,16 +510,16 @@ if (empty($reshook)) {
elseif ($action == 'classin' && $user->rights->ticket->write) { elseif ($action == 'classin' && $user->rights->ticket->write) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$object->setProject(GETPOST('projectid', 'int')); $object->setProject(GETPOST('projectid', 'int'));
$url = 'card.php?action=view&track_id=' . $object->track_id; $url = 'card.php?action=view&track_id='.$object->track_id;
header("Location: " . $url); header("Location: ".$url);
exit(); exit();
} }
} // Categorisation dans contrat } // Categorisation dans contrat
elseif ($action == 'setcontract' && $user->rights->ticket->write) { elseif ($action == 'setcontract' && $user->rights->ticket->write) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$object->setContract(GETPOST('contractid', 'int')); $object->setContract(GETPOST('contractid', 'int'));
$url = 'card.php?action=view&track_id=' . $object->track_id; $url = 'card.php?action=view&track_id='.$object->track_id;
header("Location: " . $url); header("Location: ".$url);
exit(); exit();
} }
} elseif ($action == "set_message" && $user->rights->ticket->manage) { } elseif ($action == "set_message" && $user->rights->ticket->manage) {
@ -530,7 +532,7 @@ if (empty($reshook)) {
$object->message = $fieldtomodify; $object->message = $fieldtomodify;
$ret = $object->update($user); $ret = $object->update($user);
if ($ret > 0) { if ($ret > 0) {
$log_action = $langs->trans('TicketInitialMessageModified') . " \n"; $log_action = $langs->trans('TicketInitialMessageModified')." \n";
// include the Diff class // include the Diff class
dol_include_once('/ticket/class/utils_diff.class.php'); dol_include_once('/ticket/class/utils_diff.class.php');
// output the result of comparing two files as plain text // output the result of comparing two files as plain text
@ -551,8 +553,8 @@ if (empty($reshook)) {
// Log action in ticket logs table // Log action in ticket logs table
$log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status]));
$url = 'card.php?action=view&track_id=' . $object->track_id; $url = 'card.php?action=view&track_id='.$object->track_id;
header("Location: " . $url); header("Location: ".$url);
exit(); exit();
} }
} }
@ -597,19 +599,19 @@ if (empty($reshook)) {
$permissiondellink = $user->rights->ticket->write; $permissiondellink = $user->rights->ticket->write;
include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
// Actions to build doc // Actions to build doc
$upload_dir = $conf->ticket->dir_output; $upload_dir = $conf->ticket->dir_output;
$permissiontoadd = $user->rights->ticket->write; $permissiontoadd = $user->rights->ticket->write;
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails // Actions to send emails
$triggersendname = 'TICKET_SENTBYMAIL'; $triggersendname = 'TICKET_SENTBYMAIL';
$paramname = 'id'; $paramname = 'id';
$autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add $autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add
$trackid = 'tic' . $object->id; $trackid = 'tic'.$object->id;
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
// Set $action to correct value for the case we used presend action to add a message // Set $action to correct value for the case we used presend action to add a message
if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage';
@ -650,9 +652,63 @@ if ($action == 'create' || $action == 'presend')
} }
$formticket->showForm(1, 'create'); $formticket->showForm(1, 'create');
} } elseif ($action == 'edit' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) {
$formticket = new FormTicket($db);
if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' $head = ticket_prepare_head($object);
print '<form method="POST" name="form_ticket" id="form_edit_ticket" action="' . $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="tack_id" value="' . $object->track_id . '">';
dol_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket');
print '<div class="fichecenter2">';
print '<table class="border" width="100%">';
// Type
print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">' . $langs->trans("TicketTypeRequest") . '</span></label></td><td>';
$formticket->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2');
print '</td></tr>';
// Severity
print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">' . $langs->trans("TicketSeverity") . '</span></label></td><td>';
$formticket->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2');
print '</td></tr>';
// Group
print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">' . $langs->trans("TicketGroup") . '</span></label></td><td>';
$formticket->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2');
print '</td></tr>';
// Subject
print '<tr><td><label for="subject"><span class="fieldrequired">' . $langs->trans("Subject") . '</span></label></td><td>';
print '<input class="text" size="50" id="subject" name="subject" value="' . (GETPOST('subject', 'alpha') ? GETPOST('subject', 'alpha') : $object->subject) . '" />';
print '</td></tr>';
// Other attributes
$parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit');
}
print '</table>';
print '</div>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" name="save" value="' . $langs->trans('Save') . '">';
print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '">';
print '</div>';
print '</form>';
}
elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen'
|| $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink')
{ {
if ($res > 0) if ($res > 0)
@ -1027,15 +1083,15 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
} else { } else {
// Type // Type
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>';
print $langs->getLabelFromKey($db, 'TicketTypeShort' . $object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); print $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code);
print '</td></tr>'; print '</td></tr>';
// Group // Group
print '<tr><td>'.$langs->trans("TicketCategory").'</td><td>'; print '<tr><td>'.$langs->trans("TicketCategory").'</td><td>';
print $langs->getLabelFromKey($db, 'TicketCategoryShort' . $object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); print $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code);
print '</td></tr>'; print '</td></tr>';
// Severity // Severity
print '<tr><td>'.$langs->trans("TicketSeverity").'</td><td>'; print '<tr><td>'.$langs->trans("TicketSeverity").'</td><td>';
print $langs->getLabelFromKey($db, 'TicketSeverityShort' . $object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); print $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code);
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; // End table actions print '</table>'; // End table actions
@ -1193,6 +1249,10 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
print '<div class="inline-block divButAction"><a class="butAction" href="'.dol_buildpath('/fichinter/card.php', 1).'?action=create&socid='.$object->fk_soc.'&origin=ticket_ticket&originid='.$object->id.'">'.$langs->trans('TicketAddIntervention').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.dol_buildpath('/fichinter/card.php', 1).'?action=create&socid='.$object->fk_soc.'&origin=ticket_ticket&originid='.$object->id.'">'.$langs->trans('TicketAddIntervention').'</a></div>';
} }
if ($user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?track_id=' . $object->track_id . '&action=edit">' . $langs->trans('Modify') . '</a></div>';
}
// Close ticket if statut is read // Close ticket if statut is read
if ($object->fk_statut > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ticket->write) { if ($object->fk_statut > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ticket->write) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id='.$object->track_id.'&action=close">'.$langs->trans('CloseTicket').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id='.$object->track_id.'&action=close">'.$langs->trans('CloseTicket').'</a></div>';
@ -1299,7 +1359,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
} }
// Show messages on card (Note: this is a duplicate of the view Events/Agenda but on the main tab) // Show messages on card (Note: this is a duplicate of the view Events/Agenda but on the main tab)
if (! empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) { if (!empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) {
$param = '&id='.$object->id; $param = '&id='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
@ -1308,17 +1368,17 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
$morehtmlright = ''; $morehtmlright = '';
$messagingUrl = DOL_URL_ROOT . '/ticket/agenda.php?track_id=' . $object->track_id; $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id;
$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fal fa-list-alt imgforviewmode', $messagingUrl, '', 1); $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fal fa-list-alt imgforviewmode', $messagingUrl, '', 1);
// Show link to add a message (if read and not closed) // Show link to add a message (if read and not closed)
$btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message";
$url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init'; $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init';
$morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fal fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fal fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus);
// Show link to add event (if read and not closed) // Show link to add event (if read and not closed)
$btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message";; $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; ;
$url = dol_buildpath('/comm/action/card.php', 1) . '?action=create&datep=' . date('YmdHi') . '&origin=ticket&originid=' . $object->id . '&projectid=' . $object->fk_project . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?track_id=' . $object->track_id); $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id);
$morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fal fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus); $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fal fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus);
print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
@ -1352,7 +1412,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
$morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/ticket/agenda.php?id='.$object->id); $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/ticket/agenda.php?id='.$object->id);
// List of actions on element // List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'ticket', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlcenter); $somethingshown = $formactions->showactions($object, 'ticket', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlcenter);

View File

@ -1701,7 +1701,7 @@ class Ticket extends CommonObject
$error = 0; $error = 0;
// Valid and close fichinter linked // Valid and close fichinter linked
if (!empty($conf->ficheinter->enabled) && ! empty($conf->global->WORKFLOW_TICKET_CLOSE_INTERVENTION)) { if (!empty($conf->ficheinter->enabled) && !empty($conf->global->WORKFLOW_TICKET_CLOSE_INTERVENTION)) {
dol_syslog("We have closed the ticket, so we close all linked interventions"); dol_syslog("We have closed the ticket, so we close all linked interventions");
$this->fetchObjectLinked($this->id, $this->element, null, 'fichinter'); $this->fetchObjectLinked($this->id, $this->element, null, 'fichinter');
if ($this->linkedObjectsIds) if ($this->linkedObjectsIds)
@ -2549,23 +2549,23 @@ class Ticket extends CommonObject
// Customer company infos // Customer company infos
$message .= '<br><br>'; $message .= '<br><br>';
$message .= "=============================================="; $message .= "==============================================";
$message .= !empty($object->thirdparty->name) ? '<br>' . $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : ''; $message .= !empty($object->thirdparty->name) ? '<br>'.$langs->trans('Thirdparty')." : ".$object->thirdparty->name : '';
$message .= !empty($object->thirdparty->town) ? '<br>' . $langs->trans('Town') . " : " . $object->thirdparty->town : ''; $message .= !empty($object->thirdparty->town) ? '<br>'.$langs->trans('Town')." : ".$object->thirdparty->town : '';
$message .= !empty($object->thirdparty->phone) ? '<br>' . $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; $message .= !empty($object->thirdparty->phone) ? '<br>'.$langs->trans('Phone')." : ".$object->thirdparty->phone : '';
// Email send to // Email send to
$message .= '<br><br>'; $message .= '<br><br>';
if (!empty($assigned_user_dont_have_email)) { if (!empty($assigned_user_dont_have_email)) {
$message .= '<br>' . $langs->trans('NoEMail') . ' : ' . $assigned_user_dont_have_email; $message .= '<br>'.$langs->trans('NoEMail').' : '.$assigned_user_dont_have_email;
} }
foreach ($sendto as $val) { foreach ($sendto as $val) {
$message .= '<br>' . $langs->trans('TicketNotificationRecipient') . ' : ' . $val; $message .= '<br>'.$langs->trans('TicketNotificationRecipient').' : '.$val;
} }
// URL ticket // URL ticket
$url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id; $url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id;
$message .= '<br><br>'; $message .= '<br><br>';
$message .= $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : <a href="' . $url_internal_ticket . '">' . $object->track_id . '</a>'; $message .= $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : <a href="'.$url_internal_ticket.'">'.$object->track_id.'</a>';
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames); $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
} }
@ -2602,9 +2602,9 @@ class Ticket extends CommonObject
// Coordonnées client // Coordonnées client
$message .= '<br><br>'; $message .= '<br><br>';
$message .= "==============================================<br>"; $message .= "==============================================<br>";
$message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : ''; $message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty')." : ".$object->thirdparty->name : '';
$message .= !empty($object->thirdparty->town) ? '<br>' . $langs->trans('Town') . " : " . $object->thirdparty->town : ''; $message .= !empty($object->thirdparty->town) ? '<br>'.$langs->trans('Town')." : ".$object->thirdparty->town : '';
$message .= !empty($object->thirdparty->phone) ? '<br>' . $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; $message .= !empty($object->thirdparty->phone) ? '<br>'.$langs->trans('Phone')." : ".$object->thirdparty->phone : '';
// Build array to display recipient list // Build array to display recipient list
foreach ($internal_contacts as $key => $info_sendto) { foreach ($internal_contacts as $key => $info_sendto) {
@ -2614,19 +2614,19 @@ class Ticket extends CommonObject
} }
if ($info_sendto['email'] != '') { if ($info_sendto['email'] != '') {
if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
//Contact type //Contact type
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . '<br>' : ''); $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'<br>' : '');
} }
} }
$message .= '<br>'; $message .= '<br>';
// URL ticket // URL ticket
$url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id; $url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id;
// altairis: make html link on url // altairis: make html link on url
$message .= '<br>' . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : <a href="' . $url_internal_ticket . '">' . $object->track_id . '</a><br>'; $message .= '<br>'.$langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : <a href="'.$url_internal_ticket.'">'.$object->track_id.'</a><br>';
// Add global email address recipient // Add global email address recipient
if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) {
@ -2688,23 +2688,23 @@ class Ticket extends CommonObject
} }
if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) { if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) {
if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . '<br>' : ''); $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'<br>' : '');
} }
} }
// If public interface is not enable, use link to internal page into mail // If public interface is not enable, use link to internal page into mail
$url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ?
(!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/public/ticket/view.php', 2)) : dol_buildpath('/ticket/card.php', 2)) . '?track_id=' . $object->track_id; (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/view.php' : dol_buildpath('/public/ticket/view.php', 2)) : dol_buildpath('/ticket/card.php', 2)).'?track_id='.$object->track_id;
$message .= '<br>' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : <a href="' . $url_public_ticket . '">' . $object->track_id . '</a><br>'; $message .= '<br>'.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : <a href="'.$url_public_ticket.'">'.$object->track_id.'</a><br>';
// Build final message // Build final message
$message = $message_intro . '<br><br>' . $message; $message = $message_intro.'<br><br>'.$message;
// Add signature // Add signature
$message .= '<br>' . $message_signature; $message .= '<br>'.$message_signature;
if (!empty($object->origin_email)) { if (!empty($object->origin_email)) {
$sendto[] = $object->origin_email; $sendto[] = $object->origin_email;

View File

@ -100,9 +100,9 @@ foreach ($object->fields as $key => $val)
{ {
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
} }
$fieldstosearchall['s.name_alias']="AliasNameShort"; $fieldstosearchall['s.name_alias'] = "AliasNameShort";
$fieldstosearchall['s.zip']="Zip"; $fieldstosearchall['s.zip'] = "Zip";
$fieldstosearchall['s.town']="Town"; $fieldstosearchall['s.town'] = "Town";
// Definition of fields for list // Definition of fields for list
$arrayfields = array(); $arrayfields = array();
@ -755,13 +755,13 @@ while ($i < min($num, $limit))
print '>'; print '>';
if ($key == 'fk_statut') print $object->getLibStatut(5); if ($key == 'fk_statut') print $object->getLibStatut(5);
elseif ($key == 'type_code') { elseif ($key == 'type_code') {
$s = $langs->getLabelFromKey($db, 'TicketTypeShort' . $object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); $s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code);
print '<span title="'.$s.'">'; print '<span title="'.$s.'">';
print $s; print $s;
print '</span>'; print '</span>';
} }
elseif ($key == 'category_code') print $langs->getLabelFromKey($db, 'TicketCategoryShort' . $object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); elseif ($key == 'category_code') print $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code);
elseif ($key == 'severity_code') print $langs->getLabelFromKey($db, 'TicketSeverityShort' . $object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); elseif ($key == 'severity_code') print $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code);
elseif ($key == 'tms') print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); elseif ($key == 'tms') print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser');
elseif ($key == 'fk_user_create') { elseif ($key == 'fk_user_create') {
if ($object->fk_user_create > 0) { if ($object->fk_user_create > 0) {

View File

@ -3233,9 +3233,9 @@ class User extends CommonObject
} }
return $num; return $num;
} else { } else {
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
return -1; return -1;
} }
} }
/** /**

View File

@ -303,7 +303,7 @@ if ($object->id > 0)
print '<td colspan="2">&nbsp;</td>'; print '<td colspan="2">&nbsp;</td>';
// Module id // Module id
if ($user->admin) print '<td class="right">'. $objMod->numero.'</td>'; if ($user->admin) print '<td class="right">'.$objMod->numero.'</td>';
print '</tr>'; print '</tr>';
} }

View File

@ -365,7 +365,7 @@ if ($result)
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
// Module Id // Module Id
if ($user->admin) print '<td class="right">'. $objMod->numero.'</td>'; if ($user->admin) print '<td class="right">'.$objMod->numero.'</td>';
print '</tr>'."\n"; print '</tr>'."\n";
} }

View File

@ -165,11 +165,11 @@ class ProductCombination
/** /**
* for auto retrocompatibility with last behavior * for auto retrocompatibility with last behavior
*/ */
if ($fk_price_level>0){ if ($fk_price_level > 0) {
$combination_price_levels[$fk_price_level] = ProductCombinationLevel::createFromParent($this->db, $this, $fk_price_level); $combination_price_levels[$fk_price_level] = ProductCombinationLevel::createFromParent($this->db, $this, $fk_price_level);
} }
else { else {
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$combination_price_levels[$i] = ProductCombinationLevel::createFromParent($this->db, $this, $i); $combination_price_levels[$i] = ProductCombinationLevel::createFromParent($this->db, $this, $i);
} }
} }
@ -783,16 +783,16 @@ class ProductCombination
$newcomb->variation_weight = $weight_impact; $newcomb->variation_weight = $weight_impact;
// Init price level // Init price level
if ($conf->global->PRODUIT_MULTIPRICES){ if ($conf->global->PRODUIT_MULTIPRICES) {
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$productCombinationLevel = new ProductCombinationLevel($this->db); $productCombinationLevel = new ProductCombinationLevel($this->db);
$productCombinationLevel->fk_product_attribute_combination = $newcomb->id; $productCombinationLevel->fk_product_attribute_combination = $newcomb->id;
$productCombinationLevel->fk_price_level = $i; $productCombinationLevel->fk_price_level = $i;
$productCombinationLevel->variation_price = $price_impact[$i]; $productCombinationLevel->variation_price = $price_impact[$i];
if (is_array($price_var_percent)){ if (is_array($price_var_percent)) {
$productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]); $productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]);
}else { } else {
$productCombinationLevel->variation_price_percentage = $price_var_percent; $productCombinationLevel->variation_price_percentage = $price_var_percent;
} }

View File

@ -242,29 +242,6 @@ class DateLibTest extends PHPUnit\Framework\TestCase
$result=num_public_holiday($date1, $date2, 'XX', 1); $result=num_public_holiday($date1, $date2, 'XX', 1);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertEquals(2, $result, 'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown) $this->assertEquals(2, $result, 'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown)
// Add more holiday with constant HOLIDAY_MORE_PUBLIC_HOLIDAYS
$conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS='12-13,2019-12-14';
$date1=dol_mktime(0, 0, 0, 12, 13, 2018);
$date2=dol_mktime(0, 0, 0, 12, 13, 2018);
$result=num_public_holiday($date1, $date2, 'YY', 1);
print __METHOD__." result=".$result."\n";
$this->assertEquals(1, $result, 'NumPublicHoliday for YY the 2018-12-13'); // 0 opened day, 1 closed days (even if country unknown)
$date1=dol_mktime(0, 0, 0, 12, 14, 2018);
$date2=dol_mktime(0, 0, 0, 12, 14, 2018);
$result=num_public_holiday($date1, $date2, 'YY', 1);
print __METHOD__." result=".$result."\n";
$this->assertEquals(0, $result, 'NumPublicHoliday for YY the 2018-12-14'); // 1 opened day, 0 closed days (even if country unknown)
$date1=dol_mktime(0, 0, 0, 12, 14, 2019);
$date2=dol_mktime(0, 0, 0, 12, 14, 2019);
$result=num_public_holiday($date1, $date2, 'YY', 1);
print __METHOD__." result=".$result."\n";
$this->assertEquals(1, $result, 'NumPublicHoliday for YY the 2019-12-14'); // 0 opened day, 1 closed days (even if country unknown)
} }
/** /**

View File

@ -1,4 +1,6 @@
<?php <?php
use Sabre\VObject\Property\Boolean;
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* *
@ -130,7 +132,7 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
/** /**
* testDolBasename * testDolBasename
* *
* @return int * @return void
*/ */
public function testDolBasename() public function testDolBasename()
{ {
@ -239,7 +241,7 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
/** /**
* testDolMimeType * testDolMimeType
* *
* @return string * @return void
*/ */
public function testDolMimeType() public function testDolMimeType()
{ {
@ -285,7 +287,7 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
/** /**
* testDolDeleteDir * testDolDeleteDir
* *
* @return int * @return void
*/ */
public function testDolDeleteDir() public function testDolDeleteDir()
{ {
@ -323,10 +325,7 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
/** /**
* testDolCopyMoveDelete * testDolCopyMoveDelete
* *
* @return int * @return void
*
* @depends testDolDeleteDir
* The depends says test is run only if previous is ok
*/ */
public function testDolCopyMoveDelete() public function testDolCopyMoveDelete()
{ {
@ -362,14 +361,17 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
$this->assertTrue($result, 'move with default mask'); $this->assertTrue($result, 'move with default mask');
// To test a move that should work with forced mask // To test a move that should work with forced mask
$result=dol_move($conf->admin->dir_temp.'/file2.csv', $conf->admin->dir_temp.'/file3.csv', '0754', 1); // file shoutld be rwxr-wr-- $result=dol_move($conf->admin->dir_temp.'/file2.csv', $conf->admin->dir_temp.'/file3.csv', '0754', 1); // file should be rwxr-wr--
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertTrue($result, 'move with forced mask'); $this->assertTrue($result, 'move with forced mask');
$conf->global->MAIN_ENABLE_LOG_TO_HTML=1; $conf->syslog->enabled=1; $_REQUEST['logtohtml']=1;
$conf->logbuffer=array();
// To test a delete that should success // To test a delete that should success
$result=dol_delete_file($conf->admin->dir_temp.'/file3.csv'); $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv');
print __METHOD__." result=".$result."\n"; print __METHOD__." result delete=".var_export($result, true)."\n";
$this->assertTrue($result, 'delete file'); $this->assertTrue($result, 'delete file '.join("\n", $conf->logbuffer));
// Again to test there is error when deleting a non existing file with option disableglob // Again to test there is error when deleting a non existing file with option disableglob
$result=dol_delete_file($conf->admin->dir_temp.'/file3.csv', 1, 1); $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv', 1, 1);
@ -395,10 +397,8 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
/** /**
* testDolCompressUnCompress * testDolCompressUnCompress
* *
* @return string * @return void
*
* @depends testDolCopyMoveDelete * @depends testDolCopyMoveDelete
* The depends says test is run only if previous is ok
*/ */
public function testDolCompressUnCompress() public function testDolCompressUnCompress()
{ {
@ -431,7 +431,7 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
/** /**
* testDolDirList * testDolDirList
* *
* @return string * @return void
* *
* @depends testDolCompressUnCompress * @depends testDolCompressUnCompress
* The depends says test is run only if previous is ok * The depends says test is run only if previous is ok