Merge remote-tracking branch 'upstream/develop' into patch-10

This commit is contained in:
Frédéric FRANCE 2020-11-27 11:18:04 +01:00
commit 1704de39bb
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
95 changed files with 1431 additions and 968 deletions

View File

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

View File

@ -9,12 +9,12 @@ For users:
----------
NEW: Add module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files.
NEW: Module Reception (for a more accurate management of your receptions) moved from experimental to stable.
NEW: Module Recruitment to manage Job position and applications.
NEW: Several security issues after a private bug bounty campaign.
NEW: #15065 Put the product label in bold in the PDF templates if configured
NEW: Accountancy - add chart of sub accounts
NEW: Accountancy - add options to disable binding on sales, purchases & expense reports independently of the modules
NEW: Accountancy balance - add a menu entry to show subtotal by group
NEW: Accountancy - move to real ledger, real journals, menu disposition
NEW: Accountancy - change menu disposition
NEW: Accountancy - on transfers, select the periodicity by default
NEW: Accountancy - Add export for Gestinum (v3 & v5)
NEW: new currency rate editor
@ -29,25 +29,20 @@ NEW: Support documents generation for ticket edition (PDF or ODT)
NEW: add column payment term into list of supplier invoices
NEW: add column quantity in product margin page
NEW: add column vat rate in page to define accounting account on product/service
NEW: add common list function for available app/module page
NEW: add costprice in fields of products list
NEW: added an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE
NEW: added incoterms data into the substitution array
NEW: add employee link in expense report binding page
NEW: add EORI No. as ProfID5
NEW: add export for various payment
NEW: add export for various payments
NEW: add Extrafields labels and values in mail on create ticket
NEW: add Extrafields support on ECM module
NEW: add filter rules "is answer" and "is not answer" in email collector
NEW: add focus when editing on product/stock/product.php Close #14548
NEW: add formConfirm hook on product page
NEW: add free text on each terminal of cash desk
NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open
NEW: add global search for customer payments and vendor payments
NEW: add global search for miscellaneous payments
NEW: add helper function for table headers with numbers
NEW: add hooks on stats pages
NEW: add link to edit property from search result of website pages
NEW: add link to edit property from the search result of website pages
NEW: add link to reset qty on supplier dispatch page
NEW: add MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const to remove header stored by email collector
NEW: add Manufacturing Orders attached files into the automatic ECM view
@ -55,9 +50,6 @@ NEW: add margin info in invoice list
NEW: add mass action to set category on a list of website pages
NEW: add mass deletion for events
NEW: add mass deletion for draft invoices
NEW: add __MEMBER_TYPE__ substitution key
NEW: add a message in error_log after detection of SQL or script injection
NEW: add module Credit transfer SEPA to manage payment of supplier using
NEW: add more filters on monthly statement list
NEW: add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT
NEW: add option to define a default warehouse at user level
@ -65,35 +57,27 @@ NEW: add option to include products without alert in replenish
NEW: add order by lastname and firstname by default in get sales representatives
NEW: add param to not show links when output tags
NEW: add PDF document templates for warehouses (list of stock)
NEW: add property cssview when declaring fields of an object
NEW: add prospect status managment for the contact with managment of custom icon
NEW: add a prospect status for the contact with managment of custom icon
NEW: add public note on products ; this also partially fix the #14342
NEW: add quick dropdown menu in top right menu (MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN)
NEW: add quick dropdown menu in top right menu (experimental with MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN)
NEW: add region in export companies and contacts
NEW: add rights on margin info on invoice list
NEW: add search param for close date on order list
NEW: add send context for ticket
NEW: add show preview for mail attachement on form mail
NEW: add state origin for product
NEW: add State/Province origin for products
NEW: add the workflow interaction close intervention on closing ticket
NEW: add third order printer to TakePOS
NEW: add tracking number in list and search_all items
NEW: add two hooks printFieldListFrom and printFieldSearchParam
NEW: add __TYPE__ substitution key
NEW: add validation of MX domain for emails
NEW: add vcard for adherent and user
NEW: add week number for month view in agenda
NEW: Algeria data (TVA and forme_juridique)
NEW: Algeria data (VAT and forme_juridique)
NEW: allow click on all header numbers on commerce area
NEW: allow to reopen interventions (green button)
NEW: allow zero quality on supplier/vendor order line
NEW: allow zero quantity on supplier/vendor order line
NEW: appearance tab in TakePOS with more visual parameters
NEW: better currency rate editor
NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') )
NEW: can add event to log into blockedlog module with a constant
NEW: can build vendor invoice from vendor orders
NEW: can change a product in line of recurring invoice or contract
NEW: can change a product in lines of a recurring invoice or contract
NEW: can change size of logo on PDF documents
NEW: can change VAT rate of all lines of a draft object in one step
NEW: can define date range of validity of a login during creation
@ -102,47 +86,34 @@ NEW: can edit and set sales representatives directly on thirdparty card
NEW: can edit the list of sending email profiles
NEW: can enable/disable users in bulk actions
NEW: can filter on accounting system ref in export of chart of account
NEW: can filter on container type, language and tags in the list of pages
NEW: can force the antivirus from conf file or autoprepend ini setup
NEW: can filter on container type, language and tags in the list of web pages
NEW: can hide eatby, sellby dates with option PRODUCT_DISABLE_SELLBY and PRODUCT_DISABLE_EATBY
NEW: can import proposals, sales orders, supplier invoices
NEW: can set a dedicated SMTP config for sending email from public ticket interface
NEW: can set tags/categories to website pages
NEW: can set type of price without tax per default for new sale price creation
NEW: can use desired stock of a given warehouse for replenishment
NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
NEW: change thirdparty with barcode scan in TakePOS
NEW: common behavior for monthly leave list view
NEW: conf to allow show full arbo in warehouse getnomurl
NEW: convert all subscription in datetime
NEW: create thirdparty customer from TakePOS
NEW: can create a thirdparty customer from TakePOS
NEW: date shipment from order accepts hours
NEW: declinaison price level compatibility
NEW: price level compatibility for variant
NEW: delayed payment in TakePOS
NEW: development of module Recruitment
NEW: display date range if exist in TakePOS
NEW: display resiliate status in TakePOS for member
NEW: display stat for BOM on "object referent"/linked Object product tab
NEW: edit and update a ticket
NEW: edit or delete dispatched lines
NEW: Email configuration - allow auto signed certificat when smtp ssl activated
NEW: Email configuration - allow auto signed certificate when smtp ssl activated
NEW: enable free emails input with select2
NEW: endpoint getContacts and Clean results
NEW: Events in agenda for contact
NEW: Field to link website page to an other object
NEW: fill ECM src object fields in dol_add_file_process
NEW: filter on progress column in task list
NEW: filter product list by country and/or state/province
NEW: format tickets sent by mail in public interface
NEW: add juridical status for Algeria
NEW: form to add customer/supplier into categories
NEW: Framework is ready for CSRF token protection on explicit GET URLs
NEW: get all child recursively
NEW: get contacts list of a given order
NEW: helper functions for export with phpspreadsheet
NEW: hide closed contract lines
NEW: hide label in PDF for variants
NEW: Hook on propal card
NEW: if specific help page is available, we change color of icon
NEW: include the tag editor of page as a popup into website editor
NEW: introduce constant FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM
@ -168,21 +139,17 @@ NEW: rate editor for multicurrency
NEW: ref_ext field for Commande lines, order lines, Attributes and Combinations, Invoice lines, payments, order lines
NEW: remove new lines in mail on add ticket message
NEW: restrict thirdparty to customer in TakePOS
NEW: allow to edit "demand reason" field though API
NEW: Rule "email to" accept wildcard *
NEW: Save filter of the project homepage
NEW: select-able columns on customer invoice paymnet list
NEW: select-able columns on customer and supplier invoice paymnet list
NEW: select-able columns on miscellaneous payments + more data columns
NEW: select-able columns on social taxes list
NEW: select-able columns on supplier invoice payment list
NEW: send context and remove new lines on create ticket
NEW: set entity when creating invoice on takepos
NEW: show available stock in TakePOS
NEW: show category filter on lists only when user have rights to read categories
NEW: show header number and make it clickable in warehouse arean, payment area, shipment area
NEW: show header number and make it clickable in warehouse area, payment area, shipment area
NEW: show image of user in the combo select of users
NEW: show label on batch card
NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER)
NEW: show links for select and multi-select in category extra field
NEW: show module and permission ids on user/group rights (only admin)
NEW: show place from events on import calender
@ -200,19 +167,33 @@ NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding am
NEW: ticket classification on create from email collector
NEW: Ticket message notifications when edited from public interface
NEW: translate classification labels in ticket
NEW: triggers create, modify, delete
NEW: VAT for Algeria
NEW: Use preselect third-party from list on new card
NEW: VAT report - Invert constant to show by default zero vat in reports
NEW: Add VAT and juridical status for Algeria
NEW: VAT report - Invert constant to show by default zero VAT in reports
NEW: website page fields selection
NEW: Weighing Scale compatibility with TakePOS connector
NEW: when creating a user from a member linked to a thirdparty, you can choose to create if as external or internal user
NEW: add clone functionality on miscellaneous payment
NEW: when creating a user from a member linked to a thirdparty, you can choose to create it as external or internal user
NEW: add clone button on miscellaneous payment
NEW: #15065 Add option to put the product label in bold in the PDF templates if configured
For developers:
---------------
NEW: Hook on propal card
NEW: add __MEMBER_TYPE__ substitution key
NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open page into a popup
NEW: add hooks on stats pages
NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER)
NEW: API get contacts list of a given order
NEW: API endpoint getContacts and Clean results
NEW: Add some fields to link website page to an other object
NEW: fill ECM src object fields in dol_add_file_process
NEW: conf to allow to show the full tree in warehouse popup
NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
NEW: can force the antivirus from conf file or autoprepend ini setup
NEW: can add event to log into blockedlog module with a constant
NEW: add property cssview when declaring fields of an object
NEW: Can use dynamic code into the 'enabled' property of DAO fields
NEW: allow to edit "demand reason" field though API
NEW: API can update a payment
NEW: API get member by thirdparty
NEW: API get thirdparty by barcode
@ -230,6 +211,14 @@ NEW: Thirdparty REST API: endpoint to set price level
NEW: use new category API for project list view
NEW: Triggers Attributes and Attributes values
NEW: add hooks on newpayment page to allow external payment modules
NEW: added incoterms data into the substitution array
NEW: add formConfirm hook on product page
NEW: add send context for ticket
NEW: add a message in error_log after detection of SQL or script injection
NEW: add two hooks printFieldListFrom and printFieldSearchParam
NEW: add __TYPE__ substitution key
NEW: add validation of MX domain for emails
NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') )
WARNING:

View File

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

View File

@ -21,8 +21,8 @@
* \ingroup dev
* \brief This script uses google language ajax api as the translator engine
* The main translator function can be found at:
* http://code.google.com/intl/fr/apis/language/translate/overview.html
* http://translate.google.com/translate_tools
* defunct -http://code.google.com/intl/fr/apis/language/translate/overview.html-
* defunct -http://translate.google.com/translate_tools-
* https://code.google.com/apis/console
*/
@ -58,7 +58,7 @@ $dir=DOL_DOCUMENT_ROOT."/langs";
if (! isset($argv[3])) {
print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n";
print "Example: ".$script_file." en_US pt_PT 123456\n";
print "Rem: lang_code to use can be found on http://www.google.com/language_tools\n";
print "Rem: lang_code to use can be found on https://translate.google.com\n";
exit;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -133,7 +133,7 @@ if (empty($reshook))
$error = 0;
// Set if we used free entry or predefined product
$idprod = GETPOST('idprod', 'int');
$idprod = (int) GETPOST('idprod', 'int');
$qty = GETPOST('qty', 'int');
$qty_frozen = GETPOST('qty_frozen', 'int');
$disable_stock_change = GETPOST('disable_stock_change', 'int');
@ -172,8 +172,7 @@ if (empty($reshook))
$bomline->position = ($ranktouse + 1);
$result = $bomline->create($user);
if ($result <= 0)
{
if ($result <= 0) {
setEventMessages($bomline->error, $bomline->errors, 'errors');
$action = '';
} else {
@ -640,12 +639,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
}
// Close / Cancel
if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
}
// Re-open
if ($permissiontoadd && $object->status == $object::STATUS_CANCELED)
{
@ -667,6 +660,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&object=bom">'.$langs->trans("ToClone").'</a>';
}
// Close / Cancel
if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
}
/*
if ($user->rights->bom->write)
{

View File

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

View File

@ -60,7 +60,7 @@ if ($nolinesbefore) {
print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
print '</td>';
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<td class="linecoluseunit left">';
print '<span id="title_units">';
@ -109,7 +109,7 @@ $coldisplay++;
print '<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(GETPOSTISSET("qty") ? GETPOST("qty", 'alpha', 2) : 1).'">';
print '</td>';
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$coldisplay++;
print '<td class="nobottom linecoluseunit left">';

View File

@ -108,7 +108,7 @@ if (($line->info_bits & 2) != 2) {
}
print '</td>';
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$coldisplay++;
print '<td class="nobottom linecoluseunit left">';

View File

@ -54,7 +54,7 @@ print '<td class="linecoldescription">'.$langs->trans('Description').'</td>';
// Qty
print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('Qty'), $langs->trans("QtyRequiredIfNoLoss")).'</td>';
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<td class="linecoluseunit left">'.$langs->trans('Unit').'</td>';
}

View File

@ -79,7 +79,7 @@ $coldisplay++;
echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price
print '</td>';
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<td class="linecoluseunit nowrap left">';
$label = $tmpproduct->getLabelOfUnit('long');

View File

@ -37,8 +37,8 @@ if (!$user->rights->bookmark->lire) {
$id = GETPOST("id", 'int');
$action = GETPOST("action", "alpha");
$title = GETPOST("title", "alpha");
$url = GETPOST("url", "alpha");
$title = (string) GETPOST("title", "alpha");
$url = (string) GETPOST("url", "alpha");
$urlsource = GETPOST("urlsource", "alpha");
$target = GETPOST("target", "alpha");
$userid = GETPOST("userid", "int");
@ -71,8 +71,9 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update')
if ($action == 'update') $object->fetch(GETPOST("id", 'int'));
// Check if null because user not admin can't set an user and send empty value here.
if (!empty($userid))
if (!empty($userid)) {
$object->fk_user = $userid;
}
$object->title = $title;
$object->url = $url;
$object->target = $target;

View File

@ -1,20 +1,20 @@
<?php
/* Advance Targeting Emailling for mass emailing module
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file comm/mailing/class/advtargetemailing.class.php
@ -33,16 +33,6 @@ class AdvanceTargetingMailing extends CommonObject
*/
public $db;
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
/**
* @var string ID to identify managed object
*/
@ -58,17 +48,54 @@ class AdvanceTargetingMailing extends CommonObject
*/
public $id;
/**
* @var string name
*/
public $name;
public $entity;
/**
* @var int element id
*/
public $fk_element;
/**
* @var string type element
*/
public $type_element;
/**
* @var string filter value
*/
public $filtervalue;
/**
* @var int user author id
*/
public $fk_user_author;
/**
* @var int|string datec
*/
public $datec = '';
/**
* @var int user mod id
*/
public $fk_user_mod;
/**
* @var int|string tms
*/
public $tms = '';
/**
* @var array select target type
*/
public $select_target_type = array();
/**
* @var array type status comm prospect
*/
public $type_statuscommprospect = array();
public $thirdparty_lines;
public $contact_lines;
@ -87,17 +114,17 @@ class AdvanceTargetingMailing extends CommonObject
$this->db = $db;
$this->select_target_type = array(
'2' => $langs->trans('Contacts'),
'1' => $langs->trans('Contacts').'+'.$langs->trans('ThirdParty'),
'3' => $langs->trans('ThirdParty'),
'4' => $langs->trans('ContactsWithThirdpartyFilter')
'2' => $langs->trans('Contacts'),
'1' => $langs->trans('Contacts').'+'.$langs->trans('ThirdParty'),
'3' => $langs->trans('ThirdParty'),
'4' => $langs->trans('ContactsWithThirdpartyFilter')
);
$this->type_statuscommprospect = array(
-1 => $langs->trans("StatusProspect-1"),
0 => $langs->trans("StatusProspect0"),
1 => $langs->trans("StatusProspect1"),
2 => $langs->trans("StatusProspect2"),
3 => $langs->trans("StatusProspect3")
-1 => $langs->trans("StatusProspect-1"),
0 => $langs->trans("StatusProspect0"),
1 => $langs->trans("StatusProspect1"),
2 => $langs->trans("StatusProspect2"),
3 => $langs->trans("StatusProspect3")
);
}
@ -114,11 +141,19 @@ class AdvanceTargetingMailing extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->fk_element)) $this->fk_element = (int) $this->fk_element;
if (isset($this->type_element)) $this->type_element = trim($this->type_element);
if (isset($this->fk_element)) {
$this->fk_element = (int) $this->fk_element;
}
if (isset($this->type_element)) {
$this->type_element = trim($this->type_element);
}
if (isset($this->name)) $this->name = trim($this->name);
if (isset($this->filtervalue)) $this->filtervalue = trim($this->filtervalue);
if (isset($this->name)) {
$this->name = trim($this->name);
}
if (isset($this->filtervalue)) {
$this->filtervalue = trim($this->filtervalue);
}
// Check parameters
// Put here code to add control on parameters values
@ -148,18 +183,17 @@ class AdvanceTargetingMailing extends CommonObject
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."advtargetemailing");
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -198,10 +232,8 @@ class AdvanceTargetingMailing extends CommonObject
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -259,10 +291,8 @@ class AdvanceTargetingMailing extends CommonObject
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -324,10 +354,8 @@ class AdvanceTargetingMailing extends CommonObject
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -365,10 +393,18 @@ class AdvanceTargetingMailing extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->fk_element)) $this->fk_element = (int) $this->fk_element;
if (isset($this->type_element)) $this->type_element = trim($this->type_element);
if (isset($this->name)) $this->name = trim($this->name);
if (isset($this->filtervalue)) $this->filtervalue = trim($this->filtervalue);
if (isset($this->fk_element)) {
$this->fk_element = (int) $this->fk_element;
}
if (isset($this->type_element)) {
$this->type_element = trim($this->type_element);
}
if (isset($this->name)) {
$this->name = trim($this->name);
}
if (isset($this->filtervalue)) {
$this->filtervalue = trim($this->filtervalue);
}
// Check parameters
// Put here code to add a control on parameters values
@ -394,10 +430,8 @@ class AdvanceTargetingMailing extends CommonObject
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -423,21 +457,20 @@ class AdvanceTargetingMailing extends CommonObject
$this->db->begin();
if (!$error)
{
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."advtargetemailing";
$sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -563,7 +596,7 @@ class AdvanceTargetingMailing extends CommonObject
$extrafields->fetch_name_optionals_label($elementtype);
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$val) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key])) {
@ -593,7 +626,9 @@ class AdvanceTargetingMailing extends CommonObject
}
}
if (count($sqlwhere) > 0) $sql .= " WHERE ".implode(" AND ", $sqlwhere);
if (count($sqlwhere) > 0) {
$sql .= " WHERE ".implode(" AND ", $sqlwhere);
}
}
@ -604,10 +639,8 @@ class AdvanceTargetingMailing extends CommonObject
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$this->thirdparty_lines[$i] = $obj->rowid;
@ -674,8 +707,7 @@ class AdvanceTargetingMailing extends CommonObject
}
if ($arrayquery['contact_no_email'] != '') {
$tmpwhere = '';
if (!empty($arrayquery['contact_no_email']))
{
if (!empty($arrayquery['contact_no_email'])) {
$tmpwhere .= "(t.email IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))";
} else {
$tmpwhere .= "(t.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))";
@ -704,7 +736,7 @@ class AdvanceTargetingMailing extends CommonObject
$extrafields->fetch_name_optionals_label($elementtype);
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$val) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key.'_cnct'])) {
@ -806,7 +838,7 @@ class AdvanceTargetingMailing extends CommonObject
$extrafields->fetch_name_optionals_label($elementtype);
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$val) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key])) {
@ -837,7 +869,9 @@ class AdvanceTargetingMailing extends CommonObject
}
}
}
if (count($sqlwhere) > 0) $sql .= " WHERE ".implode(" AND ", $sqlwhere);
if (count($sqlwhere) > 0) {
$sql .= " WHERE ".implode(" AND ", $sqlwhere);
}
}
dol_syslog(get_class($this)."::query_contact sql=".$sql, LOG_DEBUG);
@ -847,10 +881,8 @@ class AdvanceTargetingMailing extends CommonObject
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$this->contact_lines[$i] = $obj->rowid;

View File

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

View File

@ -357,7 +357,7 @@ class Propal extends CommonObject
$this->products = array();
$this->duree_validite = $conf->global->PROPALE_VALIDITY_DURATION;
$this->duree_validite = ((int) $conf->global->PROPALE_VALIDITY_DURATION);
}
@ -1615,7 +1615,7 @@ class Propal extends CommonObject
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf);
if (isset($this->import_key)) $this->import_key = trim($this->import_key);
if (!empty($this->duree_validite)) $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
if (!empty($this->duree_validite) && is_numeric($this->duree_validite)) $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
// Check parameters
// Put here code to add control on parameters values
@ -2921,7 +2921,7 @@ class Propal extends CommonObject
*
* @param User $user Object user that delete
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int 1 if ok, otherwise if error
* @return int >0 if OK, <=0 if KO
*/
public function delete($user, $notrigger = 0)
{
@ -2932,102 +2932,99 @@ class Propal extends CommonObject
$this->db->begin();
if (!$notrigger)
{
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('PROPAL_DELETE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (!$error)
{
$main = MAIN_DB_PREFIX.'propaldet';
$ef = $main."_extrafields";
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = ".$this->id.")";
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
if ($this->db->query($sqlef) && $this->db->query($sql))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
if ($this->db->query($sql))
{
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
// Delete extrafields of lines and lines
if (!$error && !empty($this->table_element_line)) {
$tabletodelete = $this->table_element_line;
$sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")";
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id;
if (! $this->db->query($sqlef) || ! $this->db->query($sql)) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) $error++;
if (!$error) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
}
if (!$error)
{
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
$this->deleteEcmFiles();
if (!$error) {
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) $error++;
}
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref))
{
$dir = $conf->propal->multidir_output[$this->entity]."/".$ref;
$file = $dir."/".$ref.".pdf";
if (file_exists($file))
{
dol_delete_preview($this);
// Removed extrafields of object
if (!$error) {
$result = $this->deleteExtraFields();
if ($result < 0) {
$error++;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers
{
$this->error = 'ErrorFailToDeleteFile';
$this->errors = array('ErrorFailToDeleteFile');
$this->db->rollback();
return 0;
}
}
if (file_exists($dir))
{
$res = @dol_delete_dir_recursive($dir);
if (!$res)
{
$this->error = 'ErrorFailToDeleteDir';
$this->errors = array('ErrorFailToDeleteDir');
$this->db->rollback();
return 0;
}
}
}
}
// Delete main record
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id;
$res = $this->db->query($sql);
if (! $res) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
// Removed extrafields
if (!$error)
{
$result = $this->deleteExtraFields();
if ($result < 0)
{
$error++;
$errorflag = -4;
dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
}
// Delete record into ECM index and physically
if (!$error) {
$res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive
if (! $res) {
$error++;
}
}
if (!$error)
{
dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG);
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
if (!$error) {
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) {
$dir = $conf->propal->multidir_output[$this->entity]."/".$ref;
$file = $dir."/".$ref.".pdf";
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = 'ErrorFailToDeleteFile';
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
}
if (file_exists($dir)) {
$res = @dol_delete_dir_recursive($dir);
if (!$res) {
$this->error = 'ErrorFailToDeleteDir';
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -3;
}
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -2;
}
}
if (!$error) {
dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG);
$this->db->commit();
return 1;
} else {
$this->db->rollback();
return -1;

View File

@ -1575,7 +1575,7 @@ if ($action == 'create' && $usercancreate)
print '</td>';
} else {
print '<td>';
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx');
// reload page to retrieve customer informations
if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED))
{
@ -1663,7 +1663,7 @@ if ($action == 'create' && $usercancreate)
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
print '<tr><td>'.$langs->trans('Warehouse').'</td><td>';
print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1);
print img_picto('', 'stock').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth175 maxwidth500 widthcentpercentminusxx');
print '</td></tr>';
}
@ -1680,7 +1680,8 @@ if ($action == 'create' && $usercancreate)
$langs->load("projects");
print '<tr>';
print '<td>'.$langs->trans("Project").'</td><td>';
$numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500');
print img_picto('', 'project');
$numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth175 maxwidth500 widthcentpercentminusxx');
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
print '</td>';
print '</tr>';

View File

@ -3342,106 +3342,95 @@ class Commande extends CommonOrder
$this->db->begin();
if (!$error && !$notrigger)
{
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('ORDER_DELETE', $user);
if ($result < 0) $error++;
if ($result < 0) { $error++; }
// End call triggers
}
// Test we can delete
if ($this->nb_expedition() != 0)
{
$this->errors[] = $langs->trans('SomeShipmentExists');
$error++;
}
if (!$error)
{
// Delete extrafields of order details
$main = MAIN_DB_PREFIX.'commandedet';
$ef = $main."_extrafields";
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")";
if (!$this->db->query($sql))
{
// Delete extrafields of lines and lines
if (!$error && !empty($this->table_element_line)) {
$tabletodelete = $this->table_element_line;
$sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")";
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id;
if (! $this->db->query($sqlef) || ! $this->db->query($sql)) {
$error++;
$this->errors[] = $this->db->lasterror();
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (!$error)
{
// Delete order details
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = ".$this->id;
if (!$this->db->query($sql))
{
$error++;
$this->errors[] = $this->db->lasterror();
}
}
if (!$error)
{
if (!$error) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
}
if (!$error)
{
if (!$error) {
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) $error++;
}
if (!$error)
{
// Remove extrafields
// Removed extrafields of object
if (!$error) {
$result = $this->deleteExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (!$error)
{
// Delete object
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
if (!$this->db->query($sql))
{
// Delete main record
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id;
$res = $this->db->query($sql);
if (! $res) {
$error++;
$this->errors[] = $this->db->lasterror();
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (!$error)
{
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
$this->deleteEcmFiles();
// Delete record into ECM index and physically
if (!$error) {
$res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive
if (! $res) {
$error++;
}
}
// Remove directory with files
$comref = dol_sanitizeFileName($this->ref);
if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref))
{
$dir = $conf->commande->multidir_output[$this->entity]."/".$comref;
$file = $conf->commande->multidir_output[$this->entity]."/".$comref."/".$comref.".pdf";
if (file_exists($file)) // We must delete all files before deleting directory
{
if (!$error) {
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref)) {
$dir = $conf->commande->multidir_output[$this->entity]."/".$ref;
$file = $dir."/".$ref.".pdf";
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers
{
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = 'ErrorFailToDeleteFile';
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
}
if (file_exists($dir))
{
if (!dol_delete_dir_recursive($dir))
{
$this->error = $langs->trans("ErrorCanNotDeleteDir", $dir);
if (file_exists($dir)) {
$res = @dol_delete_dir_recursive($dir);
if (!$res) {
$this->error = 'ErrorFailToDeleteDir';
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
@ -3449,17 +3438,13 @@ class Commande extends CommonOrder
}
}
if (!$error)
{
if (!$error) {
dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG);
$this->db->commit();
return 1;
} else {
foreach ($this->errors as $errmsg)
{
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
return -1;
}
}
@ -4036,11 +4021,22 @@ class OrderLine extends CommonOrderLine
public $commande_id;
public $fk_parent_line;
/**
* @var int Id of invoice
*/
public $fk_facture;
/**
* @var string External ref
*/
public $ref_ext;
public $fk_remise_except;
/**
* @var int line rank
*/
public $rang = 0;
public $fk_fournprice;

View File

@ -2184,6 +2184,7 @@ class Facture extends CommonInvoice
if (!$this->db->query($sql))
{
$this->error = $this->db->error()." sql=".$sql;
$this->errors[] = $this->error;
$this->db->rollback();
return -5;
}
@ -2244,6 +2245,7 @@ class Facture extends CommonInvoice
{
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteFile", $file);
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
@ -2254,6 +2256,7 @@ class Facture extends CommonInvoice
{
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteDir", $dir);
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
@ -2264,11 +2267,13 @@ class Facture extends CommonInvoice
return 1;
} else {
$this->error = $this->db->lasterror()." sql=".$sql;
$this->errors[] = $this->error;
$this->db->rollback();
return -6;
}
} else {
$this->error = $this->db->lasterror()." sql=".$sql;
$this->errors[] = $this->error;
$this->db->rollback();
return -4;
}

View File

@ -164,10 +164,12 @@ class BonPrelevement extends CommonObject
$result = 0;
} else {
$result = -1;
$this->errors[] = get_class($this)."::AddFacture " . $this->db->lasterror;
dol_syslog(get_class($this)."::AddFacture Error $result");
}
} else {
$result = -2;
$this->errors[]=get_class($this)."::AddFacture linedid Empty";
dol_syslog(get_class($this)."::AddFacture Error $result");
}
} else {
@ -245,6 +247,7 @@ class BonPrelevement extends CommonObject
$line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes");
$result = 0;
} else {
$this->errors[]=get_class($this)."::addline Error -2 " .$this->db->lasterror;
dol_syslog(get_class($this)."::addline Error -2");
$result = -2;
}
@ -1121,7 +1124,8 @@ class BonPrelevement extends CommonObject
if (!$resql)
{
$error++;
dol_syslog(__METHOD__."::Update Error=".$this->db->error(), LOG_ERR);
$this->errors[]=$this->db->lasterror();
dol_syslog(__METHOD__."::Update Error=".$this->db->lasterror(), LOG_ERR);
}
}
}
@ -1316,7 +1320,7 @@ class BonPrelevement extends CommonObject
$url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id;
if ($this->type == 'bank-transfer') {
$url = DOL_URL_ROOT.'/compta/paymentbybanktransfer/card.php?id='.$this->id;
$url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id;
}
if ($option != 'nolink')

View File

@ -1477,7 +1477,7 @@ if ($action == 'create')
// print '<td width="80" class="right">'.$langs->trans("PriceUHTCurrency").'</td>';
//}
print '<td width="30" class="center">'.$langs->trans("Qty").'</td>';
if ($conf->global->PRODUCT_USE_UNITS) print '<td width="30" class="left">'.$langs->trans("Unit").'</td>';
if (!empty($conf->global->PRODUCT_USE_UNITS)) print '<td width="30" class="left">'.$langs->trans("Unit").'</td>';
print '<td width="50" class="right">'.$langs->trans("ReductionShort").'</td>';
if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print '<td width="50" class="right">'.$langs->trans("BuyingPrice").'</td>';
print '<td width="30">&nbsp;</td>';
@ -1538,7 +1538,7 @@ if ($action == 'create')
// Quantity
print '<td class="center">'.$objp->qty.'</td>';
// Unit
if ($conf->global->PRODUCT_USE_UNITS) print '<td class="left">'.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).'</td>';
if (!empty($conf->global->PRODUCT_USE_UNITS)) print '<td class="left">'.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).'</td>';
// Discount
if ($objp->remise_percent > 0)
{
@ -1682,7 +1682,7 @@ if ($action == 'create')
print '<td class="center"><input size="2" type="text" name="elqty" value="'.$objp->qty.'"></td>';
// Unit
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<td class="left">';
print $form->selectUnits($objp->fk_unit, "unit");
@ -1706,7 +1706,7 @@ if ($action == 'create')
$colspan = 6;
if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) $colspan++;
if ($conf->global->PRODUCT_USE_UNITS) $colspan++;
if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
// Ligne dates prevues
print '<tr class="oddeven">';

View File

@ -301,7 +301,7 @@ class Contracts extends DolibarrApi
*
* @url PUT {id}/lines/{lineid}
*
* @return array|bool
* @return Object|bool
*/
public function putLine($id, $lineid, $request_data = null)
{
@ -361,7 +361,7 @@ class Contracts extends DolibarrApi
*
* @url PUT {id}/lines/{lineid}/activate
*
* @return array|bool
* @return Object|bool
*/
public function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null)
{
@ -399,7 +399,7 @@ class Contracts extends DolibarrApi
*
* @url PUT {id}/lines/{lineid}/unactivate
*
* @return array|bool
* @return Object|bool
*/
public function unactivateLine($id, $lineid, $datestart, $comment = null)
{

View File

@ -625,7 +625,7 @@ abstract class CommonDocGenerator
);
// Units
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long'));
$resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short'));

View File

@ -578,7 +578,7 @@ abstract class CommonObject
*
* @param Translate $langs Language object for translation of civility (used only if option is 1)
* @param int $option 0=No option, 1=Add civility
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname, 4=Lastname, 5=Lastname if defined else firstname
* @param int $maxlen Maximum length
* @return string String with full name
*/
@ -4259,7 +4259,7 @@ abstract class CommonObject
print '<td class="right">'.$langs->trans('PriceUHT').'</td>';
if (!empty($conf->multicurrency->enabled)) print '<td class="right">'.$langs->trans('PriceUHTCurrency').'</td>';
print '<td class="right">'.$langs->trans('Qty').'</td>';
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<td class="left">'.$langs->trans('Unit').'</td>';
}
@ -4402,7 +4402,7 @@ abstract class CommonObject
$this->tpl['price'] = price($line->subprice);
$this->tpl['multicurrency_price'] = price($line->multicurrency_subprice);
$this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : '&nbsp;';
if ($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long'));
if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long'));
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : '&nbsp;';
// Is the line strike or not
@ -6324,8 +6324,18 @@ abstract class CommonObject
$param_list_array = explode(':', $param_list[0]);
$showempty = (($required && $default != '') ? 0 : 1);
if (!preg_match('/search_/', $keyprefix) && !empty($param_list_array[2])) { // If the entry into $fields is set to add a create button
$morecss .= ' widthcentpercentminusx';
if (!preg_match('/search_/', $keyprefix)) {
if (!empty($param_list_array[2])) { // If the entry into $fields is set to add a create button
if ($this->fields[$key]['picto']) {
$morecss .= ' widthcentpercentminusxx';
} else {
$morecss .= ' widthcentpercentminusx';
}
} else {
if ($this->fields[$key]['picto']) {
$morecss .= ' widthcentpercentminusx';
}
}
}
$out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, $moreparam, 0, empty($val['disabled']) ? 0 : 1);
@ -8053,12 +8063,8 @@ abstract class CommonObject
// Delete llx_ecm_files
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
$res = $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive
if (! $res) {
$error++;
}
}
@ -8456,42 +8462,80 @@ abstract class CommonObject
/**
* Delete related files of object in database
*
* @return bool
* @param integer $mode 0=Use path to find record, 1=Use src_object_xxx fields (Mode 1 is recommanded for new objects)
* @return bool True if OK, False if KO
*/
public function deleteEcmFiles()
public function deleteEcmFiles($mode = 0)
{
global $conf;
$this->db->begin();
switch ($this->element) {
case 'propal':
$element = 'propale';
break;
case 'product':
$element = 'produit';
break;
case 'order_supplier':
$element = 'fournisseur/commande';
break;
case 'invoice_supplier':
$element = 'fournisseur/facture/'.get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier');
break;
case 'shipping':
$element = 'expedition/sending';
break;
default:
$element = $this->element;
// Delete in database with mode 0
if ($mode == 0) {
switch ($this->element) {
case 'propal':
$element = 'propale';
break;
case 'product':
$element = 'produit';
break;
case 'order_supplier':
$element = 'fournisseur/commande';
break;
case 'invoice_supplier':
$element = 'fournisseur/facture/'.get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier');
break;
case 'shipping':
$element = 'expedition/sending';
break;
default:
$element = $this->element;
}
// Delete ecm_files extrafields
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files_extrafields WHERE fk_object IN (";
$sql .= " SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE filename LIKE '".$this->db->escape($this->ref)."%'";
$sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here
$sql .= ")";
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$this->db->rollback();
return false;
}
// Delete ecm_files
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'";
$sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$this->db->rollback();
return false;
}
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'";
$sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity;
// Delete in database with mode 1
if ($mode == 1) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files_extrafields";
$sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id.")";
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->lasterror();
$this->db->rollback();
return false;
}
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$this->db->rollback();
return false;
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files";
$sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->lasterror();
$this->db->rollback();
return false;
}
}
$this->db->commit();

View File

@ -2113,7 +2113,7 @@ class Form
$outarray = array();
// Units
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$langs->load('other');
}
@ -2738,12 +2738,13 @@ class Form
* @param int $limit Limit of line number
* @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices
* @param string $morecss Add more CSS
* @param int $showstockinlist Show stock information (slower).
* @return array Array of keys for json
*/
public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '')
public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '', $showstockinlist = 0)
{
// phpcs:enable
global $langs, $conf, $db;
global $langs, $conf, $db, $user;
$out = '';
$outarray = array();
@ -2752,16 +2753,16 @@ class Form
$langs->load('stocks');
// Units
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$langs->load('other');
}
$sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type,";
$sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type, p.stock,";
$sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
$sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
$sql .= " pfp.supplier_reputation";
// Units
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units";
}
if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode";
@ -2770,7 +2771,7 @@ class Form
if ($socid) $sql .= " AND pfp.fk_soc = ".$socid;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid";
// Units
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit";
}
$sql .= " WHERE p.entity IN (".getEntity('product').")";
@ -2837,7 +2838,7 @@ class Form
// Units
$outvalUnits = '';
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
if (!empty($objp->unit_short)) {
$outvalUnits .= ' - '.$objp->unit_short;
}
@ -2974,6 +2975,45 @@ class Form
}
}
if (!empty($conf->stock->enabled) && $showstockinlist && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
{
$novirtualstock = ($showstockinlist == 2);
if (!empty($user->rights->stock->lire)) {
$outvallabel .= ' - '.$langs->trans("Stock").':'.$objp->stock;
if ($objp->stock > 0) {
$optlabel .= ' - <span class="product_line_stock_ok">';
} elseif ($objp->stock <= 0) {
$optlabel .= ' - <span class="product_line_stock_too_low">';
}
$optlabel .= $langs->transnoentities("Stock").':'.$objp->stock;
$optlabel .= '</span>';
if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation
{
$langs->load("stocks");
$tmpproduct = new Product($this->db);
$tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after)
$tmpproduct->load_virtual_stock();
$virtualstock = $tmpproduct->stock_theorique;
$outvallabel .= ' - '.$langs->trans("VirtualStock").':'.$virtualstock;
$optlabel .= ' - '.$langs->transnoentities("VirtualStock").':';
if ($virtualstock > 0) {
$optlabel .= '<span class="product_line_stock_ok">';
} elseif ($virtualstock <= 0) {
$optlabel .= '<span class="product_line_stock_too_low">';
}
$optlabel .= $virtualstock;
$optlabel .= '</span>';
unset($tmpproduct);
}
}
}
$opt = '<option value="'.$outkey.'"';
if ($selected && $selected == $objp->idprodfournprice) $opt .= ' selected';
if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled';
@ -6554,7 +6594,7 @@ class Form
var separ = urlBase.indexOf("?") >= 0 ? "&" : "?";
/* console.log("params.term="+params.term); */
/* console.log("params.term encoded="+encodeURIComponent(params.term)); */
saveRemoteData[data.id].url = urlBase + separ + "sall=" + encodeURIComponent(params.term);';
saveRemoteData[data.id].url = urlBase + separ + "sall=" + encodeURIComponent(params.term.replace(/\"/g, ""));';
}
if (!$disableFiltering) {
@ -6585,7 +6625,7 @@ class Form
$.each( saveRemoteData, function( key, value ) {
if (key == selected)
{
console.log("selectArrayAjax - Do a redirect to "+value.url)
console.log("selectArrayFilter - Do a redirect to "+value.url)
location.assign(value.url);
}
});

View File

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

View File

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

View File

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

View File

@ -1060,7 +1060,7 @@ function dol_escape_json($stringtoescape)
* Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
*
* @param string $stringtoescape String to escape
* @param int $keepb 1=Preserve b tags (otherwise, remove them)
* @param int $keepb 1=Keep b tags and escape them, 0=remove them
* @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value). Set to 1 when escaping for a <textarea>.
* @param string $keepmoretags '' or 'common' or list of tags
* @param int $escapeonlyhtmltags 1=Escape only html tags, not the special chars like accents.
@ -1069,7 +1069,7 @@ function dol_escape_json($stringtoescape)
*/
function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $keepmoretags = '', $escapeonlyhtmltags = 0)
{
if ($keepmoretags == 'common') $keepmoretags = 'html,body,a,em,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
if ($keepmoretags == 'common') $keepmoretags = 'html,body,a,b,em,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
// TODO Implement $keepmoretags
// escape quotes and backslashes, newlines, etc.
@ -6725,7 +6725,7 @@ function get_date_range($date_start, $date_end, $format = '', $outputlangs = '',
*
* @param string $firstname Firstname
* @param string $lastname Lastname
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname, 4=Lastname, 5=Lastname if defined else firstname
* @return string Firstname + lastname or Lastname + firstname
*/
function dolGetFirstLastname($firstname, $lastname, $nameorder = -1)
@ -6735,22 +6735,24 @@ function dolGetFirstLastname($firstname, $lastname, $nameorder = -1)
$ret = '';
// If order not defined, we use the setup
if ($nameorder < 0) $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
if ($nameorder && $nameorder != 2 && $nameorder != 3)
{
if ($nameorder == 1) {
$ret .= $firstname;
if ($firstname && $lastname) $ret .= ' ';
$ret .= $lastname;
} elseif ($nameorder == 2 || $nameorder == 3)
{
} elseif ($nameorder == 2 || $nameorder == 3) {
$ret .= $firstname;
if (empty($ret) && $nameorder == 3)
{
if (empty($ret) && $nameorder == 3) {
$ret .= $lastname;
}
} else {
} else { // 0, 4 or 5
$ret .= $lastname;
if ($firstname && $lastname) $ret .= ' ';
$ret .= $firstname;
if (empty($ret) && $nameorder == 5) {
$ret .= $firstname;
}
if ($nameorder == 0) {
if ($firstname && $lastname) $ret .= ' ';
$ret .= $firstname;
}
}
return $ret;
}

View File

@ -1338,28 +1338,23 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
// We add ref of product (and supplier ref if defined)
$prefix_prodserv = "";
$ref_prodserv = "";
if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this
{
if ($prodser->isService())
{
if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) { // In standard mode, we do not show this
if ($prodser->isService()) {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
} else {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
}
}
if (empty($hideref))
{
if ($issupplierline)
{
if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1)
$ref_prodserv = $ref_supplier;
elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2)
$ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
else // Common case
{
if (empty($hideref)) {
if ($issupplierline) {
if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) { // Common case
$ref_prodserv = $prodser->ref; // Show local ref
if ($ref_supplier) $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : '');
} elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) {
$ref_prodserv = $ref_supplier;
} elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) {
$ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
}
} else {
$ref_prodserv = $prodser->ref; // Show local ref only
@ -1966,7 +1961,7 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0)
elseif (empty($hidedetails) || $hidedetails > 1)
{
$total_ht = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
if ($object->lines[$i]->situation_percent > 0)
if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0)
{
// TODO Remove this. The total should be saved correctly in database instead of being modified here.
$prev_progress = 0;

View File

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

View File

@ -1740,7 +1740,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
} elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 1)
{
$newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list');
$newmenu->add('/projet/list.php?mainmenu=project&amp;leftmenu=list&search_usage_opportunity=1&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode);
$newmenu->add('/projet/list.php?mainmenu=project&amp;leftmenu=list&search_usage_opportunity=1&search_status=99&search_opp_status=openedopp&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode);
$newmenu->add('/projet/list.php?mainmenu=project&amp;leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode);
} elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
$newmenu->add('/projet/list.php?mainmenu=project&amp;leftmenu=list&search_usage_opportunity=1&search_status=99', $langs->trans("List"), 2, $showmode);

View File

@ -166,7 +166,7 @@ class pdf_einstein extends ModelePDFCommandes
// Define position of columns
$this->posxdesc = $this->marge_gauche + 1;
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxtva = 101;
$this->posxup = 118;
@ -224,8 +224,9 @@ class pdf_einstein extends ModelePDFCommandes
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
global $outputlangsbis;
$outputlangsbis = null;
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@ -332,7 +333,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->AddPage();
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null));
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
@ -490,7 +491,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
// Unit
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
@ -1207,7 +1208,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);

View File

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

View File

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

View File

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

View File

@ -656,7 +656,7 @@ class pdf_standard extends ModelePDFProduct
$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);

View File

@ -166,7 +166,7 @@ class pdf_azur extends ModelePDFPropales
// Define position of columns
$this->posxdesc = $this->marge_gauche + 1;
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxtva = 101;
$this->posxup = 118;
@ -583,7 +583,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
// Unit
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
@ -1381,7 +1381,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);

View File

@ -209,8 +209,9 @@ class pdf_cyan extends ModelePDFPropales
// Load translation files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
global $outputlangsbis;
$outputlangsbis = null;
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
@ -1968,7 +1969,7 @@ class pdf_cyan extends ModelePDFPropales
),
'border-left' => true, // add left line separator
);
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$this->cols['unit']['status'] = true;
}

View File

@ -161,7 +161,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->posxdiscount = 162;
$this->postotalht = 174;
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$this->posxtva = 99;
$this->posxup = 114;
$this->posxqty = 130;
@ -400,6 +400,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pageposbefore = $pdf->getPage();
$showpricebeforepagebreak = 1;
$posYAfterImage = 0;
// Description of product line
$curX = $this->posxdesc - 1;

View File

@ -192,8 +192,9 @@ class pdf_cornas extends ModelePDFSuppliersOrders
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
global $outputlangsbis;
$outputlangsbis = null;
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$outputlangsbis->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
@ -1562,7 +1563,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
),
'border-left' => true, // add left line separator
);
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$this->cols['unit']['status'] = true;
}

View File

@ -162,7 +162,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->posxdiscount = 162;
$this->postotalht = 174;
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxtva = 95;
$this->posxup = 114;
@ -528,7 +528,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
// Unit
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
@ -1057,7 +1057,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);

View File

@ -159,7 +159,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$this->posxdiscount = 162;
$this->postotalht = 174;
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxtva = 101;
$this->posxup = 118;
@ -521,7 +521,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
// Unit
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
@ -1216,7 +1216,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);

View File

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

View File

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

View File

@ -105,7 +105,7 @@ if ($nolinesbefore) {
<?php } ?>
<td class="linecolqty right"><?php echo $langs->trans('Qty'); ?></td>
<?php
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<td class="linecoluseunit left">';
print '<span id="title_units">';

View File

@ -189,7 +189,7 @@ $coldisplay++;
</td>
<?php
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$coldisplay++;
print '<td class="left">';

View File

@ -89,7 +89,7 @@ if ($inputalsopricewithtax) print '<td class="right" style="width: 80px">'.$lang
// Qty
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<td class="linecoluseunit left">'.$langs->trans('Unit').'</td>';
}

View File

@ -223,7 +223,7 @@ if ((($line->info_bits & 2) != 2) && $line->special_code != 3) {
} else print '&nbsp;';
print '</td>';
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<td class="linecoluseunit nowrap left">';
$label = $line->getLabelOfUnit('short');

View File

@ -36,7 +36,7 @@ if (!empty($conf->multicurrency->enabled))
print '<td class="right">'.$this->tpl['multicurrency_price'].'</td>';
print '<td class="right">'.$this->tpl['qty'].'</td>';
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
print '<td class="left">'.$langs->trans($this->tpl['unit']).'</td>';
print '<td class="right">'.$this->tpl['remise_percent'].'</td>';

View File

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

View File

@ -1535,7 +1535,7 @@ if ($action == 'create')
$srcLine = new OrderLine($db);
$srcLine->id = $line->id;
$srcLine->fetch_optionals(); // fetch extrafields also available in orderline
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
$expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
print $expLine->showOptionals($extrafields, 'edit', array('style'=>'class="drag drop oddeven"', 'colspan'=>$colspan), $indiceAsked, '', 1);
}

View File

@ -1074,60 +1074,119 @@ class ExpenseReport extends CommonObject
/**
* delete
* Delete object in database
*
* @param User $fuser User that delete
* @param User $user User that delete
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, >0 if OK
*/
public function delete(User $fuser = null)
public function delete(User $user = null, $notrigger = false)
{
global $user, $langs, $conf;
$rowid = $this->id;
global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error = 0;
// Delete lines
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element_line.' WHERE '.$this->fk_element.' = '.$rowid;
if (!$error && !$this->db->query($sql))
{
$this->error = $this->db->error()." sql=".$sql;
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$error++;
$this->db->begin();
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('EXPENSEREPORT_DELETE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
// Delete llx_ecm_files
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
// Delete extrafields of lines and lines
if (!$error && !empty($this->table_element_line)) {
$tabletodelete = $this->table_element_line;
//$sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")";
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id;
if (! $this->db->query($sql)) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
if (!$error) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
}
if (!$error) {
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) $error++;
}
// Removed extrafields of object
if (!$error) {
$result = $this->deleteExtraFields();
if ($result < 0) {
$error++;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
// Delete main record
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid = '.$rowid;
$resql = $this->db->query($sql);
if (!$resql)
{
$this->error = $this->db->error()." sql=".$sql;
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id;
$res = $this->db->query($sql);
if (! $res) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR);
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
// Delete record into ECM index and physically
if (!$error) {
$res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive
if (! $res) {
$error++;
}
}
if (!$error) {
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->expensereport->multidir_output[$this->entity] && !empty($this->ref)) {
$dir = $conf->expensereport->multidir_output[$this->entity]."/".$ref;
$file = $dir."/".$ref.".pdf";
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = 'ErrorFailToDeleteFile';
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
}
if (file_exists($dir)) {
$res = @dol_delete_dir_recursive($dir);
if (!$res) {
$this->error = 'ErrorFailToDeleteDir';
$this->errors[] = $this->error;
$this->db->rollback();
return 0;
}
}
}
}
if (!$error) {
dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG);
$this->db->commit();
return 1;
} else {
$this->db->rollback();
return -1;
}
}
}
/**
* Set to status validate
@ -2438,7 +2497,7 @@ class ExpenseReport extends CommonObject
{
$obj = $this->db->fetch_object($resql);
$this->db->free($resql);
return $obj->amount;
return (empty($obj->amount) ? 0 : $obj->amount);
} else {
$this->error = $this->db->lasterror();
return -1;

View File

@ -2924,7 +2924,6 @@ class CommandeFournisseur extends CommonOrder
{
$response->nbtodo++;
$commandestatic->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated
$commandestatic->delivery_date = $this->db->jdate($obj->delivery_date);
$commandestatic->date_commande = $this->db->jdate($obj->date_commande);
$commandestatic->statut = $obj->fk_statut;

View File

@ -74,7 +74,6 @@ $search_user = GETPOST('search_user', 'int');
$search_request_author = GETPOST('search_request_author', 'alpha');
$search_ht = GETPOST('search_ht', 'alpha');
$search_ttc = GETPOST('search_ttc', 'alpha');
$search_status = (GETPOST('search_status', 'alpha') != '' ?GETPOST('search_status', 'alpha') : GETPOST('statut', 'alpha')); // alpha and not intbecause it can be '6,7'
$optioncss = GETPOST('optioncss', 'alpha');
$socid = GETPOST('socid', 'int');
$search_sale = GETPOST('search_sale', 'int');
@ -92,7 +91,11 @@ $search_project_ref = GETPOST('search_project_ref', 'alpha');
$search_btn = GETPOST('button_search', 'alpha');
$search_remove_btn = GETPOST('button_removefilter', 'alpha');
$status = GETPOST('statut', 'alpha');
if (is_array(GETPOST('search_status', 'intcomma'))) {
$search_status = join(',', GETPOST('search_status', 'intcomma'));
} else {
$search_status = (GETPOST('search_status', 'intcomma') != '' ? GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma'));
}
// Security check
$orderid = GETPOST('orderid', 'int');
@ -176,6 +179,7 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
$error = 0;
/*
@ -500,18 +504,21 @@ $formorder = new FormOrder($db);
$formother = new FormOther($db);
$formcompany = new FormCompany($db);
$title = $langs->trans("SuppliersOrders");
$title = $langs->trans("ListOfSupplierOrders");
if ($socid > 0)
{
$fourn = new Fournisseur($db);
$fourn->fetch($socid);
$title .= ' - '.$fourn->name;
}
if ($status)
if ($search_status)
{
if ($status == '1,2,3') $title .= ' - '.$langs->trans("StatusOrderToProcessShort");
if ($status == '6,7') $title .= ' - '.$langs->trans("StatusOrderCanceled");
else $title .= ' - '.$commandestatic->LibStatut($status);
if ($search_status == '1,2') $title .= ' - '.$langs->trans("SuppliersOrdersToProcess");
elseif ($search_status == '3,4') $title .= ' - '.$langs->trans("SuppliersOrdersAwaitingReception");
elseif ($search_status == '1,2,3') $title .= ' - '.$langs->trans("StatusOrderToProcessShort");
elseif ($search_status == '6,7') $title .= ' - '.$langs->trans("StatusOrderCanceled");
elseif (is_numeric($search_status)) $title .= ' - '.$commandestatic->LibStatut($search_status);
}
if ($search_billed > 0) $title .= ' - '.$langs->trans("Billed");
@ -571,8 +578,8 @@ if ($search_billed != '' && $search_billed >= 0) $sql .= " AND cf.billed = ".$db
if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category;
//Required triple check because statut=0 means draft filter
if (GETPOST('statut', 'intcomma') !== '')
$sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape(GETPOST('statut', 'intcomma'))).")";
if ($search_status != '' && $search_status >= 0)
$sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(GETPOST('statut', 'intcomma')))).")";
if ($search_status != '' && $search_status != '-1')
$sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
$sql .= dolSqlDateFilter("cf.date_commande", $search_orderday, $search_ordermonth, $search_orderyear);
$sql .= dolSqlDateFilter("cf.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear);
@ -621,15 +628,6 @@ $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if ($resql)
{
if ($socid > 0)
{
$soc = new Societe($db);
$soc->fetch($socid);
$title = $langs->trans('ListOfSupplierOrders').' - '.$soc->name;
} else {
$title = $langs->trans('ListOfSupplierOrders');
}
$num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array();
@ -669,7 +667,7 @@ if ($resql)
if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
if ($search_refsupp) $param .= "&search_refsupp=".urlencode($search_refsupp);
if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status);
if ($search_status != '' && $search_status != '-1') $param .= "&search_status=".urlencode($search_status);
if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref);
if ($search_billed != '') $param .= "&search_billed=".urlencode($search_billed);
if ($show_files) $param .= '&show_files='.urlencode($show_files);
@ -969,7 +967,7 @@ if ($resql)
if (!empty($arrayfields['cf.fk_statut']['checked']))
{
print '<td class="liste_titre right">';
$formorder->selectSupplierOrderStatus((strstr($search_status, ',') ?-1 : $search_status), 1, 'search_status');
$formorder->selectSupplierOrderStatus($search_status, 1, 'search_status');
print '</td>';
}
// Status billed

View File

@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('companies', 'bills', 'banks', 'compta'));

View File

@ -233,10 +233,10 @@ table.listofchoices, table.listofchoices tr, table.listofchoices td {
/* OK */
div.ok {
color: #114466;
color: #009933;
}
span.ok {
color: #114466;
color: #009933;
}
/* Warning */

View File

@ -425,9 +425,7 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas
{
global $conf, $langs;
$langs->load("main");
$langs->load("other");
$langs->load("admin");
$langs->loadLangs(array("main", "other", "admin"));
print '</td></tr></table>'."\n";
print '</td></tr></table>'."\n";
@ -437,7 +435,10 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas
print '<div class="nextbutton" id="nextbutton">';
if ($nonext == '2')
{
print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : '').'<br><br>';
print '<span class="warning">';
print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : '');
print '</span>';
print '<br><br>';
}
print '<input type="submit" '.($nonext == '2' ? 'disabled="disabled" ' : '').'value="'.$langs->trans("NextStep").' ->"';

View File

@ -468,7 +468,7 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 413,'PCG99-BASE','INCOME', '754', '409', 'Ristournes perçues des coopératives (provenant des excédents)', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 414,'PCG99-BASE','INCOME', '755', '409', 'Quotes-parts de résultat sur opérations faites en commun', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 415,'PCG99-BASE','INCOME', '758', '409', 'Produits divers de gestion courante', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 416,'PCG99-BASE','INCOME', 'FIN', '76','1507', 'Produits financiers', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 416,'PCG99-BASE','INCOME', '76','1507', 'Produits financiers', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 417,'PCG99-BASE','INCOME', '761', '416', 'Produits de participations', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 418,'PCG99-BASE','INCOME', '762', '416', 'Produits des autres immobilisations financières', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 419,'PCG99-BASE','INCOME', '763', '416', 'Revenus des autres créances', 1);
@ -476,7 +476,7 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 421,'PCG99-BASE','INCOME', '765', '416', 'Escomptes obtenus', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 422,'PCG99-BASE','INCOME', '766', '416', 'Gains de change', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 423,'PCG99-BASE','INCOME', '767', '416', 'Produits nets sur cessions de valeurs mobilières de placement', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 424,'PCG99-BASE','INCOME', 'FIN', '768', '416', 'Autres produits financiers', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 424,'PCG99-BASE','INCOME', '768', '416', 'Autres produits financiers', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 425,'PCG99-BASE','INCOME', '77','1507', 'Produits exceptionnels', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 426,'PCG99-BASE','INCOME', '771', '425', 'Produits exceptionnels sur opérations de gestion', 1);
INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 427,'PCG99-BASE','INCOME', '772', '425', '(Compte à la disposition des entités pour enregistrer, en cours d''exercice, les produits sur exercices antérieurs)', 1);

View File

@ -35,6 +35,8 @@ ALTER TABLE llx_payment_various MODIFY COLUMN ref varchar(30) NULL;
ALTER TABLE llx_prelevement_bons ADD COLUMN type varchar(16) DEFAULT 'debit-order';
ALTER TABLE llx_prelevement_facture CHANGE COLUMN fk_facture_foun fk_facture_fourn integer NULL;
ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture (fk_facture);
ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture_fourn (fk_facture_fourn);
@ -372,7 +374,7 @@ 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 force_severity varchar(32) NULL;
ALTER TABLE llx_c_ticket_severity CHANGE color color VARCHAR(10) NULL;
ALTER TABLE llx_c_ticket_severity CHANGE color color VARCHAR(10) NULL;
ALTER TABLE llx_expensereport ADD COLUMN fk_user_creat integer NULL;
@ -410,6 +412,7 @@ ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extraf
ALTER TABLE llx_ecm_directories ADD COLUMN note_private text AFTER fk_user_m;
ALTER TABLE llx_ecm_directories ADD COLUMN note_public text AFTER note_private;
ALTER TABLE llx_website_page ADD COLUMN allowed_in_frames integer DEFAULT 0;
ALTER TABLE llx_website_page ADD COLUMN object_type varchar(255);
ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255);
@ -421,7 +424,7 @@ ALTER TABLE llx_projet_task_time MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIM
ALTER TABLE llx_projet_task_time MODIFY COLUMN datec datetime;
DELETE FROM llx_user_rights WHERE fk_id IN (SELECT id FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous');
DELETE FROM llx_user_rights WHERE fk_id IN (SELECT id FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous');
DELETE FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous';
UPDATE llx_rights_def set perms = 'readall' WHERE perms = 'read_all' and module = 'holiday';

View File

@ -20,7 +20,7 @@ create table llx_prelevement_facture
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_facture integer NULL,
fk_facture_foun integer NULL,
fk_facture_fourn integer NULL,
fk_prelevement_lignes integer NOT NULL
)ENGINE=innodb;

View File

@ -29,7 +29,8 @@ CREATE TABLE llx_website_page
image varchar(255),
keywords varchar(255),
lang varchar(6),
fk_page integer,
fk_page integer,
allowed_in_frames integer DEFAULT 0,
htmlheader text,
content mediumtext, -- text is not enough in size
status integer DEFAULT 1,
@ -40,6 +41,6 @@ CREATE TABLE llx_website_page
date_creation datetime,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
import_key varchar(14), -- import key
object_type varchar(255),
fk_object varchar(255)
object_type varchar(255), -- To link page to an object
fk_object varchar(255) -- To link page to an object
) ENGINE=innodb;

View File

@ -146,11 +146,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
if ($db->connected)
{
print '<tr><td class="nowrap">';
print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.'</td><td class="right">'.$langs->trans("OK").'</td></tr>'."\n";
print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.'</td><td class="right"><span class="neutral">'.$langs->trans("OK").'</span></td></tr>'."\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection").": $dolibarr_main_db_host ".$langs->transnoentities("OK"));
$ok = 1;
} else {
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).'</td><td class="right">'.$langs->transnoentities("Error")."</td></tr>\n";
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).'</td><td class="right"><span class="error">'.$langs->transnoentities("Error")."</span></td></tr>\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name));
$ok = 0;
}
@ -160,11 +160,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
if ($db->database_selected)
{
print '<tr><td class="nowrap">';
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.'</td><td class="right">'.$langs->trans("OK")."</td></tr>\n";
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.'</td><td class="right"><span class="neutral">'.$langs->trans("OK")."</span></td></tr>\n";
dolibarr_install_syslog("upgrade: Database connection successful: ".$dolibarr_main_db_name);
$ok = 1;
} else {
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).'</td><td class="right">'.$langs->trans("Error")."</td></tr>\n";
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).'</td><td class="right"><span class="ok">'.$langs->trans("Error")."</span></td></tr>\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name));
$ok = 0;
}
@ -196,7 +196,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
&& versioncompare($versionarray, $versionmindb) < 0)
{
// Warning: database version too low.
print "<tr><td>".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))."</td><td class=\"right\">".$langs->trans("Error")."</td></tr>\n";
print "<tr><td>".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb)).'</td><td class="right"><span class="error">'.$langs->trans("Error")."</span></td></tr>\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb)));
$ok = 0;
}

View File

@ -531,7 +531,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
print '</td></tr>';
} else {
print '<tr><td colspan="4">';
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: OK';
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: <span class="ok">OK</span>';
print "<!-- (".$reshook.") -->";
print '</td></tr>';
}
@ -1353,9 +1353,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf)
if ($insert_resql)
{
$nb++;
print '<td><span style="color:green">'.$langs->trans("OK").'</span></td>';
print '<td><span class="ok">'.$langs->trans("OK").'</span></td>';
} else {
print '<td><span style="color:red">Error on insert</span></td>';
print '<td><span class="error">Error on insert</span></td>';
$error++;
}
print '</tr>';

View File

@ -1672,7 +1672,7 @@ AdvancedEditor=Advanced editor
ActivateFCKeditor=Activate advanced editor for:
FCKeditorForCompany=WYSIWIG creation/edition of elements description and note (except products/services)
FCKeditorForProduct=WYSIWIG creation/edition of products/services description and note
FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). <font class="warning">Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formatting when building PDF files.</font>
FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). <span class="warning">Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formatting when building PDF files.</span>
FCKeditorForMailing= WYSIWIG creation/edition for mass eMailings (Tools->eMailing)
FCKeditorForUserSignature=WYSIWIG creation/edition of user signature
FCKeditorForMail=WYSIWIG creation/edition for all mail (except Tools->eMailing)

View File

@ -1105,3 +1105,4 @@ SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry=Security token has exp
UpToDate=Up-to-date
OutOfDate=Out-of-date
EventReminder=Event Reminder
UpdateForAllLines=Update for all lines

View File

@ -77,3 +77,4 @@ UnitCost=Unit cost
TotalCost=Total cost
BOMTotalCost=The cost to produce this BOM based on cost of each quantity and product to consume (use Cost price if defined, else Average Weighted Price if defined, else the Best purchase price)
GoOnTabProductionToProduceFirst=You must first have started the production to close a Manufacturing Order (See tab '%s'). But you can Cancel it.
ErrorAVirtualProductCantBeUsedIntoABomOrMo=A kit can't be used into a BOM or a MO

View File

@ -135,4 +135,5 @@ ReplacementDoneInXPages=Replacement done in %s pages or containers
RSSFeed=RSS Feed
RSSFeedDesc=You can get a RSS feed of latest articles with type 'blogpost' using this URL
PagesRegenerated=%s page(s)/container(s) regenerated
RegenerateWebsiteContent=Regenerate web site cache files
RegenerateWebsiteContent=Regenerate web site cache files
AllowedInFrames=Allowed in Frames

View File

@ -68,6 +68,8 @@ function testSqlAndScriptInject($val, $type)
// We clean string because some hacks try to obfuscate evil strings by inserting non printable chars. Example: 'java(ascci09)scr(ascii00)ipt' is processed like 'javascript' (whatever is place of evil ascii char)
// We should use dol_string_nounprintableascii but function is not yet loaded/available
$val = preg_replace('/[\x00-\x1F\x7F]/u', '', $val); // /u operator makes UTF8 valid characters being ignored so are not included into the replace
// We clean html comments because some hacks try to obfuscate evil strings by inserting HTML comments. Example: on<!-- -->error=alert(1)
$val = preg_replace('/<!--[^>]*-->/', '', $val);
$inj = 0;
// For SQL Injection (only GET are used to be included into bad escaped SQL requests)

View File

@ -73,6 +73,7 @@ class MyObject extends CommonObject
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
* 'label' the translation key.
* 'picto' is code of a picto to show before value in forms
* 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
* 'position' is the sort order of field.
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
@ -105,16 +106,16 @@ class MyObject extends CommonObject
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>'Help text', 'showoncombobox'=>1),
'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'),
'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501),
//'date_validation ' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
//'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'notnull'=>0, 'position'=>600),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),

View File

@ -1300,7 +1300,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
),
'border-left' => true, // add left line separator
);
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$this->cols['unit']['status'] = true;
}

View File

@ -122,6 +122,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase
/**
* A sample test
*
* @return bool
*/
public function testSomething()
@ -139,4 +140,53 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase
return $result;
}
/**
* testMyObjectCreate
*
* @return int
*/
public function testMyObjectCreate()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new MyObject($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);
print __METHOD__." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
/**
* testMyObjectDelete
*
* @param int $id Id of object
* @return int
*
* @depends testMyObjectCreate
* The depends says test is run only if previous is ok
*/
public function testMyObjectDelete($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new MyObject($this->savdb);
$result=$localobject->fetch($id);
$result=$localobject->delete($user);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
}

View File

@ -98,11 +98,11 @@ class Mo extends CommonObject
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1),
'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM", 'css'=>'maxwidth300'),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300'),
'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'isameasure'=>1),
'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'default'=>1, 'isameasure'=>1),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'css'=>'maxwidth300'),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>51, 'notnull'=>-1, 'index'=>1,),
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>1, 'position'=>52, 'css'=>'maxwidth300'),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'css'=>'maxwidth400'),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>1, 'visible'=>-1, 'position'=>51, 'notnull'=>-1, 'index'=>1, 'css'=>'minwidth200 maxwidth400'),
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'picto'=>'stock', 'enabled'=>1, 'visible'=>1, 'position'=>52, 'css'=>'maxwidth400'),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'notnull'=>-1,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,),
@ -249,6 +249,19 @@ class Mo extends CommonObject
$this->db->begin();
if ($this->fk_product > 0) {
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$tmpproduct = new Product($this->db);
$tmpproduct->fetch($this->fk_product);
if ($tmpproduct->hasFatherOrChild(1) > 0) {
$this->error = 'ErrorAVirtualProductCantBeUsedIntoABomOrMo';
$this->errors[] = $this->error;
$this->db->rollback();
return -1;
}
}
// Check that product is not a kit/virtual product
if (!$error) {
$idcreated = $this->createCommon($user, $notrigger);
if ($idcreated <= 0) {

View File

@ -35,15 +35,13 @@ if (!$user->rights->opensurvey->write) accessforbidden();
$langs->load("opensurvey");
// On teste toutes les variables pour supprimer l'ensemble des warnings PHP
// On transforme en entites html les données afin éviter les failles XSS
$post_var = array('title', 'description', 'mailsonde', 'creation_sondage_date', 'creation_sondage_autre');
foreach ($post_var as $var)
{
${$var} = GETPOST($var);
}
$title = GETPOST('title');
$description = GETPOST('description', 'restricthtml');
$mailsonde = GETPOST('mailsonde');
$creation_sondage_date = GETPOST('creation_sondage_date');
$creation_sondage_date = GETPOST('creation_sondage_date');
// On initialise egalement la session car sinon bonjour les warning :-)
// We init some session variable to avoir warning
$session_var = array('title', 'description', 'mailsonde');
foreach ($session_var as $var)
{

View File

@ -1151,7 +1151,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
}
// Units
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>';
print '<td colspan="3">';
@ -1610,7 +1610,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
}
}
// Units
if ($conf->global->PRODUCT_USE_UNITS)
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>';
print '<td colspan="3">';

View File

@ -519,7 +519,7 @@ if ($id > 0 || $ref)
print '<input class="flat" name="qty" size="5" value="'.$quantity.'">';
}
// Units
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$unit = $object->getLabelOfUnit();
if ($unit !== '') {
print '&nbsp;&nbsp;'.$langs->trans($unit);
@ -537,7 +537,7 @@ if ($id > 0 || $ref)
print '<input class="flat" name="packaging" size="5" value="'.$packaging.'">';
// Units
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$unit = $object->getLabelOfUnit();
if ($unit !== '') {
print '&nbsp;&nbsp;'.$langs->trans($unit);
@ -1000,7 +1000,7 @@ END;
print '<td class="right">';
print $productfourn->fourn_qty;
// Units
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$unit = $object->getLabelOfUnit();
if ($unit !== '') {
print '&nbsp;&nbsp;'.$langs->trans($unit);

View File

@ -419,28 +419,29 @@ $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
llxHeader("", $title, $help_url);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($search_all != '') $param .= '&search_all='.$search_all;
if ($search_sday) $param .= '&search_sday='.$search_sday;
if ($search_smonth) $param .= '&search_smonth='.$search_smonth;
if ($search_syear) $param .= '&search_syear='.$search_syear;
if ($search_eday) $param .= '&search_eday='.$search_eday;
if ($search_emonth) $param .= '&search_emonth='.$search_emonth;
if ($search_eyear) $param .= '&search_eyear='.$search_eyear;
if ($socid) $param .= '&socid='.$socid;
if ($search_ref != '') $param .= '&search_ref='.$search_ref;
if ($search_label != '') $param .= '&search_label='.$search_label;
if ($search_societe != '') $param .= '&search_societe='.$search_societe;
if ($search_status >= 0) $param .= '&search_status='.$search_status;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_all != '') $param .= '&search_all='.urlencode($search_all);
if ($search_sday) $param .= '&search_sday='.urlencode($search_sday);
if ($search_smonth) $param .= '&search_smonth='.urlencode($search_smonth);
if ($search_syear) $param .= '&search_syear='.urlencode($search_syear);
if ($search_eday) $param .= '&search_eday='.urlencode($search_eday);
if ($search_emonth) $param .= '&search_emonth='.urlencode($search_emonth);
if ($search_eyear) $param .= '&search_eyear='.urlencode($search_eyear);
if ($socid) $param .= '&socid='.urlencode($socid);
if ($search_categ) $param .= '&search_categ='.urlencode($search_categ);
if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref);
if ($search_label != '') $param .= '&search_label='.urlencode($search_label);
if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe);
if ($search_status >= 0) $param .= '&search_status='.urlencode($search_status);
if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status);
if ($search_opp_percent != '') $param .= '&search_opp_percent='.urlencode($search_opp_percent);
if ($search_public != '') $param .= '&search_public='.$search_public;
if ($search_project_user != '') $param .= '&search_project_user='.$search_project_user;
if ($search_sale > 0) $param .= '&search_sale='.$search_sale;
if ($search_opp_amount != '') $param .= '&search_opp_amount='.$search_opp_amount;
if ($search_budget_amount != '') $param .= '&search_budget_amount='.$search_budget_amount;
if ($optioncss != '') $param .= '&optioncss='.$optioncss;
if ($search_public != '') $param .= '&search_public='.urlencode($search_public);
if ($search_project_user != '') $param .= '&search_project_user='.urlencode($search_project_user);
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
if ($search_opp_amount != '') $param .= '&search_opp_amount='.urlencode($search_opp_amount);
if ($search_budget_amount != '') $param .= '&search_budget_amount='.urlencode($search_budget_amount);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';

View File

@ -1213,7 +1213,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
),
'border-left' => true, // add left line separator
);
if ($conf->global->PRODUCT_USE_UNITS) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$this->cols['unit']['status'] = true;
}

View File

@ -678,7 +678,10 @@ if ($action == "order" and $placeid != 0)
$printer = new dolReceiptPrinter($db);
}
$headerorder = '<html><br><b>'.$langs->trans('Place').' '.$place.'<br><table width="65%"><thead><tr><th class="left">'.$langs->trans("Label").'</th><th class="right">'.$langs->trans("Qty").'</th></tr></thead><tbody>';
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
$resql = $db->query($sql);
$row = $db->fetch_object($resql);
$headerorder = '<html><br><b>'.$langs->trans('Place').' '.$row->label.'<br><table width="65%"><thead><tr><th class="left">'.$langs->trans("Label").'</th><th class="right">'.$langs->trans("Qty").'</th></tr></thead><tbody>';
$footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
$order_receipt_printer1 = "";
$order_receipt_printer2 = "";
@ -695,11 +698,15 @@ if ($action == "order" and $placeid != 0)
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
$result = array_intersect($catsprinter1, $existing);
$count = count($result);
if (!$line->fk_product) $count++; // Print Free-text item (Unassigned printer) to Printer 1
if ($count > 0) {
$linestoprint++;
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1
$db->query($sql);
$order_receipt_printer1 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
$order_receipt_printer1 .= '<tr><td class="left">';
if ($line->fk_product) $order_receipt_printer1 .= $line->product_label;
else $order_receipt_printer1 .= $line->description;
$order_receipt_printer1 .= '</td><td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer1 .= '</td></tr>';
}
@ -1372,4 +1379,4 @@ if ($action == "search")
</center>';
}
print '</div>';
print '</div>';

View File

@ -2617,7 +2617,8 @@ a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { text-align
/* color: #f3e4ac !important; */
}
.helppresentcircle {
color: var(--butactionbg);
color: var(--colorbackhmenu1);
filter: invert(0.8);
margin-left: -7px;
display: inline-block;
margin-top: -10px;

View File

@ -2588,6 +2588,17 @@ font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; }
a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { text-align: <?php print $left; ?>; font-weight: normal; color: #999; text-decoration: none; }
.helppresentcircle {
color: var(--colorbackhmenu1);
filter: invert(0.5);
margin-left: -7px;
display: inline-block;
margin-top: -10px;
font-size: x-small;
vertical-align: super;
opacity: 0.95;
}
div.blockvmenulogo
{
border-bottom: 0 !important;

View File

@ -81,6 +81,7 @@ class WebsitePage extends CommonObject
*/
public $lang;
public $allowed_in_frames;
public $htmlheader;
public $content;
public $grabbed_from;
@ -160,6 +161,7 @@ class WebsitePage extends CommonObject
//'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000),
'fk_website' =>array('type'=>'integer', 'label'=>'WebsiteId', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>40, 'searchall'=>0, 'foreignkey'=>'websitepage.rowid'),
'fk_page' =>array('type'=>'integer', 'label'=>'ParentPageId', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'position'=>45, 'searchall'=>0, 'foreignkey'=>'website.rowid'),
'allowed_in_frames' =>array('type'=>'integer', 'label'=>'AllowedInFrames', 'enabled'=>1, 'visible'=>-1, 'position'=>48, 'searchall'=>0),
'htmlheader' =>array('type'=>'text', 'label'=>'HtmlHeader', 'enabled'=>1, 'visible'=>0, 'position'=>50, 'searchall'=>0),
'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>0, 'position'=>51, 'searchall'=>0),
'grabbed_from' =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>400, 'comment'=>'URL page content was grabbed from'),
@ -265,6 +267,7 @@ class WebsitePage extends CommonObject
$sql .= " t.content,";
$sql .= " t.lang,";
$sql .= " t.fk_page,";
$sql .= " t.allowed_in_frames,";
$sql .= " t.status,";
$sql .= " t.grabbed_from,";
$sql .= " t.date_creation,";
@ -325,6 +328,7 @@ class WebsitePage extends CommonObject
$this->content = $obj->content;
$this->lang = $obj->lang;
$this->fk_page = $obj->fk_page;
$this->allowed_in_frames = $obj->allowed_in_frames;
$this->status = $obj->status;
$this->grabbed_from = $obj->grabbed_from;
$this->date_creation = $this->db->jdate($obj->date_creation);
@ -383,6 +387,7 @@ class WebsitePage extends CommonObject
$sql .= " t.content,";
$sql .= " t.lang,";
$sql .= " t.fk_page,";
$sql .= " t.allowed_in_frames,";
$sql .= " t.status,";
$sql .= " t.grabbed_from,";
$sql .= " t.date_creation,";
@ -453,6 +458,7 @@ class WebsitePage extends CommonObject
$record->content = $obj->content;
$record->lang = $obj->lang;
$record->fk_page = $obj->fk_page;
$record->allowed_in_frames = $obj->allowed_in_frames;
$record->status = $obj->status;
$record->grabbed_from = $obj->grabbed_from;
$record->date_creation = $this->db->jdate($obj->date_creation);
@ -839,6 +845,7 @@ class WebsitePage extends CommonObject
$this->description = 'This is my page';
$this->image = '';
$this->keywords = 'keyword1, keyword2';
$this->allowed_in_frames = 1;
$this->htmlheader = '';
$this->content = '<html><body>This is a html content</body></html>';
$this->status = '';

View File

@ -940,6 +940,7 @@ if ($action == 'addcontainer')
$objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma');
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
$objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml'));
$objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09');
$objectpage->htmlheader = GETPOST('htmlheader', 'none');
$objectpage->author_alias = GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml');
$objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS');
@ -1562,7 +1563,7 @@ if ($action == 'setashome')
}
}
// Update page (meta)
// Update page properties (meta)
if ($action == 'updatemeta')
{
$db->begin();
@ -1656,6 +1657,7 @@ if ($action == 'updatemeta')
$objectpage->description = str_replace(array('<', '>'), '', GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml'));
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
$objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml'));
$objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09');
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
$objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0);
$objectpage->author_alias = trim(GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml'));
@ -2831,7 +2833,6 @@ if (!GETPOST('hide_websitemenu'))
print '</span>'; // end websitehelp
if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')
{
// Adding jquery code to change on the fly url of preview ext
@ -2887,7 +2888,6 @@ if (!GETPOST('hide_websitemenu'))
}
$head = array();
@ -3279,7 +3279,7 @@ if ($action == 'importsite')
print '<br>';
}
if ($action == 'editmeta' || $action == 'createcontainer')
if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of a web site OR properties of a web page
{
print '<div class="fiche">';
@ -3366,6 +3366,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
$pageimage = $objectpage->image;
$pagekeywords = $objectpage->keywords;
$pagelang = $objectpage->lang;
$pageallowedinframes = $objectpage->allowed_in_frames;
$pagehtmlheader = $objectpage->htmlheader;
$pagedatecreation = $objectpage->date_creation;
$pagedatemodification = $objectpage->date_modification;
@ -3389,6 +3390,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage = GETPOST('WEBSITE_IMAGE', 'alpha');
if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml'));
if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang = GETPOST('WEBSITE_LANG', 'aZ09');
if (GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09')) $pageallowedinframes = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09');
if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none');
if ($action != 'createcontainer')
@ -3542,6 +3544,15 @@ if ($action == 'editmeta' || $action == 'createcontainer')
}
print '</td></tr>';
// Allowed in frames
print '<tr><td>';
print $langs->trans('AllowedInFrames');
//$htmlhelp = $langs->trans("AllowedInFramesDesc");
//print $form->textwithpicto($langs->trans('AllowedInFrames'), $htmlhelp, 1, 'help', '', 0, 2, 'allowedinframestooltip');
print '</td><td>';
print '<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ? 'checked="checked"' : '').'>';
print '</td></tr>';
// Categories
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
{
@ -3566,18 +3577,19 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print "</td></tr>";
}
print '<tr><td class="titlefieldcreate">';
print 'ObjectClass';
print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
print '</td></tr>';
print '<tr><td class="titlefieldcreate">';
print 'ObjectID';
print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
print '</td></tr>';
if (!empty($conf->global->WEBSITE_PAGE_SHOW_INTERNAL_LINKS_TO_OBJECT)) {
print '<tr><td class="titlefieldcreate">';
print 'ObjectClass';
print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
print '</td></tr>';
print '<tr><td class="titlefieldcreate">';
print 'ObjectID';
print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
print '</td></tr>';
}
$fuser = new User($db);

View File

@ -89,7 +89,7 @@ if ($resql) {
$membertype->id = $obj->rowid;
$membertype->fetch($membertype->id);
print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype - label;
print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype->label;
$oldobject = $membertype;

View File

@ -77,8 +77,8 @@ class AllTests
$suite = new PHPUnit\Framework\TestSuite('PHPUnit Framework');
//require_once dirname(__FILE__).'/CoreTest.php';
//$suite->addTestSuite('CoreTest');
require_once dirname(__FILE__).'/CoreTest.php';
$suite->addTestSuite('CoreTest');
require_once dirname(__FILE__).'/AdminLibTest.php';
$suite->addTestSuite('AdminLibTest');
require_once dirname(__FILE__).'/CompanyLibTest.php';

View File

@ -148,4 +148,30 @@ class BOMTest extends PHPUnit\Framework\TestCase
return $result;
}
/**
* testBOMDelete
*
* @param int $id Id of object
* @return void
*
* @depends testBOMCreate
* The depends says test is run only if previous is ok
*/
public function testBOMDelete($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new BOM($this->savdb);
$result=$localobject->fetch($id);
$result=$localobject->delete($user);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
}

View File

@ -281,7 +281,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
preg_match_all('/sql.+\s*\'"\s*\.\s*\$(.........)/', $filecontent, $matches, PREG_SET_ORDER);
foreach ($matches as $key => $val)
{
if (! in_array($val[1], array('this->db-', 'this->esc', 'db->escap', 'dbsession->escap', 'db->idate', 'excludeGr', 'includeGr'))) {
if (! in_array($val[1], array('this->db-', 'this->esc', 'db->escap', 'dbsession', 'db->idate', 'excludeGr', 'includeGr'))) {
$ok=false;
break;
}

View File

@ -239,78 +239,99 @@ class CoreTest extends PHPUnit\Framework\TestCase
/**
* testSqlAndScriptInject
* testSqlAndScriptInjectWithPHPUnit
*
* @return void
*/
public function testSqlAndScriptInject()
public function testSqlAndScriptInjectWithPHPUnit()
{
global $dolibarr_main_prod;
global $dolibarr_main_url_root;
global $dolibarr_main_data_root;
global $dolibarr_main_document_root;
global $dolibarr_main_data_root_alt;
global $dolibarr_main_document_root_alt;
global $dolibarr_main_db_host;
global $dolibarr_main_db_port;
global $dolibarr_main_db_type;
global $dolibarr_main_db_prefix;
// This is code copied from main.inc.php !!!!!!!!!!!!!!!
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Security: SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST, PHP_SELF).
* Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST, PHP_SELF).
*
* @param string $val Value
* @param string $type 1=GET, 0=POST, 2=PHP_SELF
* @return int >0 if there is an injection
* @param string $val Value brut found int $_GET, $_POST or PHP_SELF
* @param string $type 1=GET, 0=POST, 2=PHP_SELF, 3=GET without sql reserved keywords (the less tolerant test)
* @return int >0 if there is an injection, 0 if none
*/
function testSqlAndScriptInject($val, $type)
{
// phpcs:enable
$inj = 0;
// For SQL Injection (only GET and POST are used to be included into bad escaped SQL requests)
if ($type != 2)
{
$inj += preg_match('/delete\s+from/i', $val);
$inj += preg_match('/create\s+table/i', $val);
$inj += preg_match('/update.+set.+=/i', $val);
$inj += preg_match('/insert\s+into/i', $val);
$inj += preg_match('/select.+from/i', $val);
$inj += preg_match('/union.+select/i', $val);
$inj += preg_match('/into\s+(outfile|dumpfile)/i', $val);
$inj += preg_match('/(\.\.%2f)+/i', $val);
}
// For XSS Injection done by adding javascript with script
// This is all cases a browser consider text is javascript:
// When it found '<script', 'javascript:', '<style', 'onload\s=' on body tag, '="&' on a tag size with old browsers
// All examples on page: http://ha.ckers.org/xss.html#XSScalc
// More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
$inj += preg_match('/<script/i', $val);
$inj += preg_match('/<iframe/i', $val);
$inj += preg_match('/Set\.constructor/i', $val); // ECMA script 6
if (! defined('NOSTYLECHECK')) $inj += preg_match('/<style/i', $val);
$inj += preg_match('/base[\s]+href/si', $val);
$inj += preg_match('/<.*onmouse/si', $val); // onmousexxx can be set on img or any html tag like <img title='...' onmouseover=alert(1)>
$inj += preg_match('/onerror\s*=/i', $val); // onerror can be set on img or any html tag like <img title='...' onerror = alert(1)>
$inj += preg_match('/onfocus\s*=/i', $val); // onfocus can be set on input text html tag like <input type='text' value='...' onfocus = alert(1)>
$inj += preg_match('/onload\s*=/i', $val); // onload can be set on svg tag <svg/onload=alert(1)> or other tag like body <body onload=alert(1)>
//$inj += preg_match('/on[A-Z][a-z]+\*=/', $val); // To lock event handlers onAbort(), ...
$inj += preg_match('/&#58;|&#0000058|&#x3A/i', $val); // refused string ':' encoded (no reason to have it encoded) to lock 'javascript:...'
//if ($type == 1)
//{
$inj += preg_match('/javascript:/i', $val);
$inj += preg_match('/vbscript:/i', $val);
//}
// For XSS Injection done by adding javascript closing html tags like with onmousemove, etc... (closing a src or href tag with not cleaned param)
if ($type == 1) $inj += preg_match('/"/i', $val); // We refused " in GET parameters value
if ($type == 2) $inj += preg_match('/[;"]/', $val); // PHP_SELF is a file system path. It can contains spaces.
return $inj;
// Decode string first
// So <svg o&#110;load='console.log(&quot;123&quot;)' become <svg onload='console.log(&quot;123&quot;)'
// So "&colon;&apos;" become ":'" (due to ENT_HTML5)
$val = html_entity_decode($val, ENT_QUOTES | ENT_HTML5);
// TODO loop to decode until no more thing to decode ?
// We clean string because some hacks try to obfuscate evil strings by inserting non printable chars. Example: 'java(ascci09)scr(ascii00)ipt' is processed like 'javascript' (whatever is place of evil ascii char)
// We should use dol_string_nounprintableascii but function is not yet loaded/available
$val = preg_replace('/[\x00-\x1F\x7F]/u', '', $val); // /u operator makes UTF8 valid characters being ignored so are not included into the replace
// We clean html comments because some hacks try to obfuscate evil strings by inserting HTML comments. Example: on<!-- -->error=alert(1)
$val = preg_replace('/<!--[^>]*-->/', '', $val);
$inj = 0;
// For SQL Injection (only GET are used to be included into bad escaped SQL requests)
if ($type == 1 || $type == 3)
{
$inj += preg_match('/delete\s+from/i', $val);
$inj += preg_match('/create\s+table/i', $val);
$inj += preg_match('/insert\s+into/i', $val);
$inj += preg_match('/select\s+from/i', $val);
$inj += preg_match('/into\s+(outfile|dumpfile)/i', $val);
$inj += preg_match('/user\s*\(/i', $val); // avoid to use function user() that return current database login
$inj += preg_match('/information_schema/i', $val); // avoid to use request that read information_schema database
$inj += preg_match('/<svg/i', $val); // <svg can be allowed in POST
}
if ($type == 3)
{
$inj += preg_match('/select|update|delete|truncate|replace|group\s+by|concat|count|from|union/i', $val);
}
if ($type != 2) // Not common key strings, so we can check them both on GET and POST
{
$inj += preg_match('/updatexml\(/i', $val);
$inj += preg_match('/update.+set.+=/i', $val);
$inj += preg_match('/union.+select/i', $val);
$inj += preg_match('/(\.\.%2f)+/i', $val);
}
// For XSS Injection done by closing textarea to execute content into a textarea field
$inj += preg_match('/<\/textarea/i', $val);
// For XSS Injection done by adding javascript with script
// This is all cases a browser consider text is javascript:
// When it found '<script', 'javascript:', '<style', 'onload\s=' on body tag, '="&' on a tag size with old browsers
// All examples on page: http://ha.ckers.org/xss.html#XSScalc
// More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
$inj += preg_match('/<audio/i', $val);
$inj += preg_match('/<embed/i', $val);
$inj += preg_match('/<iframe/i', $val);
$inj += preg_match('/<object/i', $val);
$inj += preg_match('/<script/i', $val);
$inj += preg_match('/Set\.constructor/i', $val); // ECMA script 6
if (!defined('NOSTYLECHECK')) $inj += preg_match('/<style/i', $val);
$inj += preg_match('/base\s+href/si', $val);
$inj += preg_match('/=data:/si', $val);
// List of dom events is on https://www.w3schools.com/jsref/dom_obj_event.asp
$inj += preg_match('/onmouse([a-z]*)\s*=/i', $val); // onmousexxx can be set on img or any html tag like <img title='...' onmouseover=alert(1)>
$inj += preg_match('/ondrag([a-z]*)\s*=/i', $val); //
$inj += preg_match('/ontouch([a-z]*)\s*=/i', $val); //
$inj += preg_match('/on(abort|afterprint|beforeprint|beforeunload|blur|canplay|canplaythrough|change|click|contextmenu|copy|cut)\s*=/i', $val);
$inj += preg_match('/on(dblclick|drop|durationchange|ended|error|focus|focusin|focusout|hashchange|input|invalid)\s*=/i', $val);
$inj += preg_match('/on(keydown|keypress|keyup|load|loadeddata|loadedmetadata|loadstart|offline|online|pagehide|pageshow)\s*=/i', $val);
$inj += preg_match('/on(paste|pause|play|playing|progress|ratechange|resize|reset|scroll|search|seeking|select|show|stalled|start|submit|suspend)\s*=/i', $val);
$inj += preg_match('/on(timeupdate|toggle|unload|volumechange|waiting)\s*=/i', $val);
//$inj += preg_match('/on[A-Z][a-z]+\*=/', $val); // To lock event handlers onAbort(), ...
$inj += preg_match('/&#58;|&#0000058|&#x3A/i', $val); // refused string ':' encoded (no reason to have it encoded) to lock 'javascript:...'
$inj += preg_match('/javascript\s*:/i', $val);
$inj += preg_match('/vbscript\s*:/i', $val);
// For XSS Injection done by adding javascript closing html tags like with onmousemove, etc... (closing a src or href tag with not cleaned param)
if ($type == 1) {
$val = str_replace('enclosure="', 'enclosure=X', $val); // We accept enclosure="
$inj += preg_match('/"/i', $val); // We refused " in GET parameters value.
}
if ($type == 2) $inj += preg_match('/[;"]/', $val); // PHP_SELF is a file system path. It can contains spaces.
return $inj;
}
// Run tests
// More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
@ -404,5 +425,9 @@ class CoreTest extends PHPUnit\Framework\TestCase
$test='Set.constructor`alert\x281\x29```';
$result=testSqlAndScriptInject($test, 0);
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject iii');
$test="on<!-- ab\nc -->error=alert(1)";
$result=testSqlAndScriptInject($test, 0);
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject jjj');
}
}

View File

@ -281,15 +281,9 @@ class ExpenseReportTest extends PHPUnit\Framework\TestCase
$langs=$this->savlangs;
$db=$this->savdb;
/*$result=$localobject->setstatus(0);
$result=$localobject->getSumPayments();
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
*/
/*$localobject->info($localobject->id);
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
$this->assertNotEquals($localobject->date_creation, '');
*/
$this->assertGreaterThanOrEqual(0, $result);
return $localobject->id;
}
@ -316,7 +310,7 @@ class ExpenseReportTest extends PHPUnit\Framework\TestCase
$result=$localobject->delete($user);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
$this->assertGreaterThan(0, $result);
return $result;
}
}

View File

@ -203,4 +203,27 @@ class LangTest extends PHPUnit\Framework\TestCase
return;
}
/**
* testTrans
*
* @return string
*/
public function testTrans()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$tmplangs=new Translate('', $conf);
$langcode='en_US';
$tmplangs->setDefaultLang($langcode);
$tmplangs->load("main");
$result = $tmplangs->trans("FilterOnInto", "<input autofocus onfocus='alert(1337)' <--!");
print __METHOD__." result trans FilterOnInto = ".$result."\n";
$this->assertEquals($result, "Search criteria '<b>&lt;input autofocus onfocus='alert(1337)' &lt;--!</b>' into fields ", 'Result of lang->trans must have original translation string with its original HTML tag, but inserted values must be fully encoded.');
}
}