Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop_menu

This commit is contained in:
Regis Houssin 2019-08-13 07:34:02 +02:00
commit 7c8b3c9a38
658 changed files with 6611 additions and 3707 deletions

View File

@ -32,7 +32,7 @@ PSR/simple-cache ? Library for cache (used by PHPSp
Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer)
Sabre 3.2.2 BSD Yes DAV support Sabre 3.2.2 BSD Yes DAV support
Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP
Stripe 6.35 MIT licence Yes Library for Stripe module Stripe 6.41 MIT licence Yes Library for Stripe module
TCPDF 6.2.25 LGPL-3+ Yes PDF generation TCPDF 6.2.25 LGPL-3+ Yes PDF generation
TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement

109
ChangeLog
View File

@ -15,8 +15,117 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Properties ->libelle_incoterms were renamed into ->label_incoterms * Properties ->libelle_incoterms were renamed into ->label_incoterms
* Removed the method liste_array() of project class. It was not used by core code. * Removed the method liste_array() of project class. It was not used by core code.
* The function show_theme() hase been renamed into showSkins()
***** ChangeLog for 10.0.1 compared to 10.0.0 *****
FIX: #10930
FIX: #10984
FIX: reposition on "Build backup" button
FIX: #11400
FIX: #11412
FIX: #11460
FIX: #11463
FIX: #11466
FIX: #11492
FIX: #11498
FIX: #11505
FIX: #11506
FIX: #11507
FIX: #11509
FIX: #11537
FIX: #11543
FIX: #11553
FIX: #11576
FIX: #11584
FIX: #11590
FIX: accounting mode must be taken from global conf, because there's no way to choose a mode with interface
FIX: Add message from public interface
FIX: add missing hook calls
FIX: Add warning when setup is strange
FIX: ajax call for line positioning when CSRFCHECK_WITH_TOKEN is on
FIX: API return 404 sometimes even if API exists
FIX: Attachment was lost when we validate an expense report
FIX: avoid conflict with "$classname" in card.php
FIX: Bad sql request
FIX: better compatibility with multicompany transverse mode
FIX: Better PHP compatibility
FIX: Block to link with tickets
FIX: Can't submit a ticket from public interface
FIX: categories import: prevent mismatch between category type and object type
FIX: Closing ticket from public interface
FIX: Column 'paid' missing in expense report
FIX: compatibility mysql 8. rank is reserved
FIX: Computed field were not calculated into lists.
FIX: Content of email for subscription
FIX: correct error in files with multiple spaces
FIX: CVE-2019-11199
FIX: delete of links between objects
FIX: div not balanced
FIX: do not return formatted prices in json string
FIX: duplicate on the check (TODO field $onetrtd not used ?)
FIX: element name in update_price
FIX: empty product_use_units in product configuration
FIX: expedition card: infinite loop for printObjectLine hook if return > 0
FIX: extrafield loading bug due to assumption that an object is a third party while it may be a contact if MAIN_USE_COMPANY_NAME_OF_CONTACT is set.
FIX: Fatal error on dol_htmloutput_mesg with corrupted array
FIX: Fatal situation if payment removed on expense report. Action
FIX: FEC Format - Missing date_creation in general ledger when you add a new transaction
FIX: FEC Format - Save translation of the journal label in database & nowrap on amount
FIX: floating point precision errors in the triggers of the workflow module
FIX: for #11232
FIX: format of field with type timestamp
FIX: fournrprice log for insert
FIX: help text
FIX: import filter error
FIX: __INFOS__ tag not exists
FIX: issue #9300: install error with PostgreSQL when using custom table prefix
FIX: Language key
FIX: Limit of uploaded files (max_post_size was not used)
FIX: list of balance of leaves
FIX: minor spelling issues
FIX: missing "dropdown-icon" replacement
FIX: Missing field "Conciliated" into bank transaction export
FIX: missing filter by current contact
FIX: missing token
FIX: Missing where on entity
FIX: move sql request in INNER JOIN
FIX: name was able to be in field but went back to new line
FIX: Nowrap on amount
FIX: Online payment
FIX: on shipment delete confirm dialog, a new checkbox allows the user to choose if they want their stock re-incremented after the deletion.
FIX: option EXPORT_LABEL_FOR_SELECT to restore compatibility in export
FIX: Option THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION
FIX: outdated phpdoc
FIX: Permission for BOM menu
FIX: permission to delete a draft purchase order
FIX: phpcs
FIX: Position was lost when we edit the line of template invoice
FIX: product_use_units was set to 0 each time a conf in block other was set
FIX: propal createFrom hook: undefined parameter attached
FIX: Responsive of public interface of ticket
FIX: search by phone pro
FIX: Setup of TakePos was not possible after a clean install
FIX: Show list of events on tickets
FIX: socpeople assigned list in action com list
FIX: SQL problem on donation & nowrap on amount
FIX: stock increase on shipment deletion if STOCK_CALCULATE_ON_SHIPMENT_NEW: is set
FIX: stripe webhook ID constant set
FIX: summary of time spent in preview tab of projects
FIX: the feature to bill time spent was not enabled.
FIX: The new feature to attach document on lines was not correclty
FIX: The proposed new supplier code does not work
FIX: this function can not be private
FIX: tk9877 - PDF rouget requires product.lib.php (otherwise measuring_units_string() is not defined)
FIX: Update the file index table when we validate/rename a ref.
FIX: use rounding to compare the amounts
FIX: We must save code instead of value in database for template invoice modelpdf
FIX: we need to be able to add freeline with qty between 0 & 1 in supplierorder line
FIX: We should remove property comments only for project and task api.
FIX: When saving an action it didn't save the label based on the type of event if the label is empty and the type is customized
FIX: when STOCK_CALCULATE_ON_SHIPMENT_NEW: is set, deleting a "closed" shipment now increases stock as expected
FIX: wrong path sociales/index.php doesnt exist anymore
***** ChangeLog for 10.0.0 compared to 9.0.0 ***** ***** ChangeLog for 10.0.0 compared to 9.0.0 *****
For Users: For Users:
NEW: Module "Ticket" is available as a stable module. NEW: Module "Ticket" is available as a stable module.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -156,17 +156,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$ok=1; $ok=1;
foreach ($listfield as $f => $value) foreach ($listfield as $f => $value)
{ {
if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes','DictionaryRevenueStamp','DictionaryAccountancyCategory','Pcg_version'))) continue; // For some pages, country is not mandatory if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory
if ($value == 'country' && in_array($tablib[$id], array('DictionaryCanton','DictionaryCompanyType','DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory if ((! isset($_POST[$value]) || $_POST[$value]==''))
if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue;
if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
if ($value == 'color' && empty($_POST['color'])) continue;
if ($value == 'formula' && empty($_POST['formula'])) continue;
if ((! isset($_POST[$value]) || $_POST[$value]=='')
&& (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy')) // Fields that are not mandatory
&& (! ($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10
)
)
{ {
$ok=0; $ok=0;
$fieldnamekey=$listfield[$f]; $fieldnamekey=$listfield[$f];
@ -174,19 +165,6 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($fieldnamekey == 'pcg_version') $fieldnamekey='Pcg_version'; if ($fieldnamekey == 'pcg_version') $fieldnamekey='Pcg_version';
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments';
if ($fieldnamekey == 'nbjour') $fieldnamekey='NbOfDays';
if ($fieldnamekey == 'decalage') $fieldnamekey='Offset';
if ($fieldnamekey == 'module') $fieldnamekey='Module';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
if ($fieldnamekey == 'taux') $fieldnamekey = 'Rate';
if ($fieldnamekey == 'type') $fieldnamekey = 'Type';
if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
if ($fieldnamekey == 'unicode') $fieldnamekey = 'Unicode';
if ($fieldnamekey == 'deductible') $fieldnamekey = 'Deductible';
if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder';
if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated';
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
} }
@ -196,9 +174,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$ok=0; $ok=0;
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
} }
if (isset($_POST["code"])) if (isset($_POST["pcg_version"]))
{ {
if ($_POST["code"]=='0') if ($_POST["pcg_version"]=='0')
{ {
$ok=0; $ok=0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
@ -210,29 +188,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
}*/ }*/
} }
if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2))
{
if (in_array($tablib[$id], array('DictionaryCompanyType','DictionaryHolidayTypes'))) // Field country is no mandatory for such dictionaries
{
$_POST["country"]='';
}
else
{ {
$ok=0; $ok=0;
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
} }
}
if (! is_numeric($_POST["code"]))
{
$ok=0;
setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors');
}
// Clean some parameters
if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0
if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
// Si verif ok et action add, on ajoute la ligne // Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) if ($ok && GETPOST('actionadd', 'alpha'))

View File

@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php
$langs->loadLangs(array("accountancy", "bills", "compta")); $langs->loadLangs(array("accountancy", "bills", "compta"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$id = GETPOST('id', 'int'); // id of record $id = GETPOST('id', 'int'); // id of record
$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' $mode = GETPOST('mode', 'aZ09'); // '' or 'tmp'
@ -346,6 +347,8 @@ if ($action == 'create')
} }
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="confirm_create">' . "\n"; print '<input type="hidden" name="action" value="confirm_create">' . "\n";
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n"; print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
print '<input type="hidden" name="mode" value="_tmp">' . "\n"; print '<input type="hidden" name="mode" value="_tmp">' . "\n";
@ -441,6 +444,7 @@ if ($action == 'create')
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editdate') { if ($action == 'editdate') {
print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">'; print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdate">'; print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
@ -464,6 +468,7 @@ if ($action == 'create')
print '</td><td>'; print '</td><td>';
if ($action == 'editjournal') { if ($action == 'editjournal') {
print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">'; print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setjournal">'; print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
@ -487,6 +492,7 @@ if ($action == 'create')
print '</td><td>'; print '</td><td>';
if ($action == 'editdocref') { if ($action == 'editdocref') {
print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">'; print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdocref">'; print '<input type="hidden" name="action" value="setdocref">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
@ -583,6 +589,8 @@ if ($action == 'create')
print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print load_fiche_titre($langs->trans("ListeMvts"), '', '');
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">'; print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="doc_date" value="' . $object->doc_date . '">' . "\n"; print '<input type="hidden" name="doc_date" value="' . $object->doc_date . '">' . "\n";
print '<input type="hidden" name="doc_type" value="' . $object->doc_type . '">' . "\n"; print '<input type="hidden" name="doc_type" value="' . $object->doc_type . '">' . "\n";
print '<input type="hidden" name="doc_ref" value="' . $object->doc_ref . '">' . "\n"; print '<input type="hidden" name="doc_ref" value="' . $object->doc_ref . '">' . "\n";

View File

@ -48,6 +48,7 @@ class AccountancyExport
public static $EXPORT_TYPE_BOB50 = 35; public static $EXPORT_TYPE_BOB50 = 35;
public static $EXPORT_TYPE_CIEL = 40; public static $EXPORT_TYPE_CIEL = 40;
public static $EXPORT_TYPE_SAGE50_SWISS = 45; public static $EXPORT_TYPE_SAGE50_SWISS = 45;
public static $EXPORT_TYPE_CHARLEMAGNE = 50;
public static $EXPORT_TYPE_QUADRATUS = 60; public static $EXPORT_TYPE_QUADRATUS = 60;
public static $EXPORT_TYPE_OPENCONCERTO = 100; public static $EXPORT_TYPE_OPENCONCERTO = 100;
public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_LDCOMPTA = 110;
@ -108,6 +109,7 @@ class AccountancyExport
self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'),
self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'),
self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'),
self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'),
); );
ksort($listofexporttypes, SORT_NUMERIC); ksort($listofexporttypes, SORT_NUMERIC);
@ -202,6 +204,10 @@ class AccountancyExport
'label' => $langs->trans('Modelcsv_FEC'), 'label' => $langs->trans('Modelcsv_FEC'),
'ACCOUNTING_EXPORT_FORMAT' => 'txt', 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
), ),
self::$EXPORT_TYPE_CHARLEMAGNE => array(
'label' => $langs->trans('Modelcsv_charlemagne'),
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
),
), ),
'cr'=> array ( 'cr'=> array (
'1' => $langs->trans("Unix"), '1' => $langs->trans("Unix"),
@ -272,6 +278,9 @@ class AccountancyExport
break; break;
case self::$EXPORT_TYPE_FEC : case self::$EXPORT_TYPE_FEC :
$this->exportFEC($TData); $this->exportFEC($TData);
break;
case self::$EXPORT_TYPE_CHARLEMAGNE :
$this->exportCharlemagne($TData);
break; break;
default: default:
$this->errors[] = $langs->trans('accountancy_error_modelnotfound'); $this->errors[] = $langs->trans('accountancy_error_modelnotfound');
@ -284,7 +293,6 @@ class AccountancyExport
* Export format : CEGID * Export format : CEGID
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportCegid($objectLines) public function exportCegid($objectLines)
@ -310,7 +318,6 @@ class AccountancyExport
* Export format : COGILOG * Export format : COGILOG
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportCogilog($objectLines) public function exportCogilog($objectLines)
@ -344,7 +351,6 @@ class AccountancyExport
* Export format : COALA * Export format : COALA
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportCoala($objectLines) public function exportCoala($objectLines)
@ -372,7 +378,6 @@ class AccountancyExport
* Export format : BOB50 * Export format : BOB50
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportBob50($objectLines) public function exportBob50($objectLines)
@ -411,7 +416,6 @@ class AccountancyExport
* Export format : CIEL * Export format : CIEL
* *
* @param array $TData data * @param array $TData data
*
* @return void * @return void
*/ */
public function exportCiel(&$TData) public function exportCiel(&$TData)
@ -452,7 +456,6 @@ class AccountancyExport
* Export format : Quadratus * Export format : Quadratus
* *
* @param array $TData data * @param array $TData data
*
* @return void * @return void
*/ */
public function exportQuadratus(&$TData) public function exportQuadratus(&$TData)
@ -536,7 +539,6 @@ class AccountancyExport
* Export format : EBP * Export format : EBP
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportEbp($objectLines) public function exportEbp($objectLines)
@ -573,7 +575,6 @@ class AccountancyExport
* Export format : Agiris Isacompta * Export format : Agiris Isacompta
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportAgiris($objectLines) public function exportAgiris($objectLines)
@ -614,7 +615,6 @@ class AccountancyExport
* Export format : OpenConcerto * Export format : OpenConcerto
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportOpenConcerto($objectLines) public function exportOpenConcerto($objectLines)
@ -644,16 +644,17 @@ class AccountancyExport
} }
/** /**
* Export format : Configurable * Export format : Configurable CSV
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportConfigurable($objectLines) public function exportConfigurable($objectLines)
{ {
global $conf; global $conf;
$separator = $this->separator;
foreach ($objectLines as $line) { foreach ($objectLines as $line) {
$tab = array(); $tab = array();
// export configurable // export configurable
@ -661,15 +662,14 @@ class AccountancyExport
$tab[] = $line->piece_num; $tab[] = $line->piece_num;
$tab[] = $date; $tab[] = $date;
$tab[] = $line->doc_ref; $tab[] = $line->doc_ref;
$tab[] = $line->label_operation; $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation;
$tab[] = length_accountg($line->numero_compte); $tab[] = length_accountg($line->numero_compte);
$tab[] = length_accounta($line->subledger_account); $tab[] = length_accounta($line->subledger_account);
$tab[] = price($line->debit); $tab[] = price2num($line->debit);
$tab[] = price($line->credit); $tab[] = price2num($line->credit);
$tab[] = price($line->montant); $tab[] = price2num($line->montant);
$tab[] = $line->code_journal; $tab[] = $line->code_journal;
$separator = $this->separator;
print implode($separator, $tab) . $this->end_line; print implode($separator, $tab) . $this->end_line;
} }
} }
@ -678,7 +678,6 @@ class AccountancyExport
* Export format : FEC * Export format : FEC
* *
* @param array $objectLines data * @param array $objectLines data
*
* @return void * @return void
*/ */
public function exportFEC($objectLines) public function exportFEC($objectLines)
@ -1013,6 +1012,66 @@ class AccountancyExport
} }
} }
/**
* Export format : Charlemagne
*
* @param array $objectLines data
* @return void
*/
public function exportCharlemagne($objectLines)
{
global $langs;
$langs->load('compta');
$separator = "\t";
$end_line = "\n";
/*
* Charlemagne export need header
*/
print $langs->transnoentitiesnoconv('Date') . $separator;
print self::trunc($langs->transnoentitiesnoconv('Journal'), 6) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Account'), 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Piece'), 20) . $separator;
print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60) . $separator;
print $langs->transnoentitiesnoconv('Amount') . $separator;
print 'S' . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 1', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 1', 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 2', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 2', 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 3', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 3', 60) . $separator;
print $end_line;
foreach($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%Y%m%d');
print $date . $separator; //Date
print self::trunc($line->code_journal, 6) . $separator; //Journal code
if(!empty($line->subledger_account)) $account = $line->subledger_account;
else $account = $line->numero_compte;
print self::trunc($account, 15) . $separator;//Account number
print self::trunc($line->label_compte, 60) . $separator;//Account label
print self::trunc($line->doc_ref, 20) . $separator;//Piece
print self::trunc($line->label_operation, 60) . $separator;//Operation label
print price(abs($line->montant)) . $separator;//Amount
print $line->sens . $separator;//Direction
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $end_line;
}
}
/** /**
* trunc * trunc
* *

View File

@ -128,10 +128,11 @@ class Subscription extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)";
if ($this->fk_type == null) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
$member=new Adherent($this->db); $member=new Adherent($this->db);
$result=$member->fetch($this->fk_adherent); $result=$member->fetch($this->fk_adherent);
if ($this->fk_type == null) { // If type not defined, we use the type of member
$type=$member->typeid; $type=$member->typeid;
} else { } else {
$type=$this->fk_type; $type=$this->fk_type;
@ -151,10 +152,12 @@ class Subscription extends CommonObject
if (! $error) if (! $error)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
$this->fk_type = $type;
} }
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
$this->context = array('member'=>$member);
// Call triggers // Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
@ -257,6 +260,7 @@ class Subscription extends CommonObject
$result=$member->update_end_date($user); $result=$member->update_end_date($user);
if (! $error && ! $notrigger) { if (! $error && ! $notrigger) {
$this->context = array('member'=>$member);
// Call triggers // Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail

View File

@ -182,7 +182,7 @@ if ($result > 0)
if (empty($dn)) if (empty($dn))
{ {
$langs->load("errors"); $langs->load("errors");
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font></td></tr>'; print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>';
} }
else else
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -205,18 +205,18 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
print $form->showrefnav($object, 'rowid', $linkback, 1); print $form->showrefnav($object, 'rowid', $linkback, 1);
print '</td></tr>'; print '</td></tr>';
// Type
print '<tr>';
print '<td>'.$langs->trans("Type").'</td><td class="valeur" colspan="3">';
print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type));
print'</td></tr>';
// Member // Member
$adh->ref=$adh->getFullName($langs); $adh->ref=$adh->getFullName($langs);
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1, 0, 'subscription').'</td>'; print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>'; print '</tr>';
// Type
print '<tr>';
print '<td>'.$langs->trans("Type").'</td><td class="valeur" colspan="3">';
print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type));
print'</td></tr>';
// Date start subscription // Date start subscription
print '<tr><td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="2">'; print '<tr><td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="2">';
print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1); print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1);
@ -309,6 +309,12 @@ if ($rowid && $action != 'edit')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';
// Type // Type
print '<tr>'; print '<tr>';
print '<td class="titlefield">'.$langs->trans("Type").'</td>'; print '<td class="titlefield">'.$langs->trans("Type").'</td>';
@ -322,17 +328,6 @@ if ($rowid && $action != 'edit')
} }
print '</td></tr>'; print '</td></tr>';
// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';
// Date record
/*print '<tr>';
print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->datec,'dayhour').'</td>';
print '</tr>';*/
// Date subscription // Date subscription
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->dateh, 'day').'</td>'; print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->dateh, 'day').'</td>';

View File

@ -40,8 +40,8 @@ $action = GETPOST('action', 'aZ09');
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin)
{ {
$result=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); $result1=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
$result=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); $result2=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
if ($result1 >= 0 && $result2 >= 0) if ($result1 >= 0 && $result2 >= 0)
{ {

View File

@ -1058,7 +1058,7 @@ if ($id)
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow=$langs->trans($valuetoshow); // try to translate
$class=''; $class='';
if ($fieldlist[$field]=='pos') { $valuetoshow=$langs->trans("Position"); $class='width100'; } if ($fieldlist[$field]=='pos') { $valuetoshow=$langs->trans("Position"); $class='maxwidth100'; }
if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
if ($fieldlist[$field]=='taux') { if ($fieldlist[$field]=='taux') {
@ -1076,7 +1076,7 @@ if ($id)
if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
else $valuetoshow=$langs->trans("Type"); else $valuetoshow=$langs->trans("Type");
} }
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); $class='width100'; } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); $class='maxwidth100'; }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
{ {
$valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, ''));
@ -1602,7 +1602,6 @@ if ($id)
$class='tddict'; $class='tddict';
if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200'; if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200';
if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto';
if ($fieldlist[$field] == 'code') $class.=' width100';
if ($fieldlist[$field] == 'position') $class.=' right'; if ($fieldlist[$field] == 'position') $class.=' right';
if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap'; if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap';
if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap'; if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap';
@ -1780,7 +1779,6 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
global $form; global $form;
global $region_id; global $region_id;
global $elementList,$sourceList,$localtax_typeList; global $elementList,$sourceList,$localtax_typeList;
global $bc;
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
@ -1981,7 +1979,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
} }
$classtd=''; $class=''; $classtd=''; $class='';
if ($fieldlist[$field]=='code') $classtd='width100'; if ($fieldlist[$field]=='code') $class='maxwidth100';
if (in_array($fieldlist[$field], array('pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) $class='maxwidth50'; if (in_array($fieldlist[$field], array('pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) $class='maxwidth50';
if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class='quatrevingtpercent'; if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class='quatrevingtpercent';
print '<td class="'.$classtd.'">'; print '<td class="'.$classtd.'">';

View File

@ -259,7 +259,7 @@ if ($action == 'edit') // Edit
print '</table><br>'."\n"; print '</table><br>'."\n";
// Themes and themes options // Themes and themes options
show_theme(null, 1); showSkins(null, 1);
print '<br>'; print '<br>';
// Other // Other
@ -464,7 +464,7 @@ else // Show
// Themes // Themes
show_theme(null, 0); showSkins(null, 0);
print '<br>'; print '<br>';

View File

@ -446,8 +446,10 @@ print "\n";
<br> <br>
<div class="center"><input type="submit" class="button" <div class="center">
value="<?php echo $langs->trans("GenerateBackup") ?>" id="buttonGo" /><br> <input type="submit" class="button reposition" value="<?php echo $langs->trans("GenerateBackup") ?>" id="buttonGo">
<input type="hidden" name="page_y" value="<?php echo GETPOST('page_y', 'int'); ?>">
<br>
<br> <br>
<?php <?php
@ -459,7 +461,7 @@ if (! empty($_SESSION["commandbackuplastdone"]))
//print $paramclear; //print $paramclear;
// Now run command and show result // Now show result
print '<b>'.$langs->trans("BackupResult").':</b> '; print '<b>'.$langs->trans("BackupResult").':</b> ';
print $_SESSION["commandbackupresult"]; print $_SESSION["commandbackupresult"];
@ -598,9 +600,6 @@ print '<br>';
</fieldset> </fieldset>
</form> </form>
<?php <?php
// End of page // End of page

View File

@ -50,7 +50,7 @@ if (! $user->admin) accessforbidden();
if ($file && ! $what) if ($file && ! $what)
{ {
//print DOL_URL_ROOT.'/dolibarr_export.php'; //print DOL_URL_ROOT.'/dolibarr_export.php';
header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod")))); header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int')?'&page_y='.GETPOST('page_y', 'int'):''));
exit; exit;
} }
@ -122,25 +122,15 @@ $utils = new Utils($db);
// MYSQL // MYSQL
if ($what == 'mysql') if ($what == 'mysql')
{ {
$cmddump=GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg
$cmddump=dol_sanitizePathName($cmddump); $cmddump=dol_sanitizePathName($cmddump);
if (! empty($dolibarr_main_restrict_os_commands)) if (! empty($dolibarr_main_restrict_os_commands))
{ {
$arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands);
$ok=0;
dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump);
foreach($arrayofallowedcommand as $allowedcommand)
{
$basenamecmddump=basename($cmddump); $basenamecmddump=basename($cmddump);
if (preg_match('/^'.preg_quote($allowedcommand, '/').'$/', $basenamecmddump)) // the provided command $cmddump must be an allowed command if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command
{
$ok=1;
break;
}
}
if (! $ok)
{ {
$errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands');
} }
@ -176,6 +166,18 @@ if ($what == 'postgresql')
$cmddump=GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg
$cmddump=dol_sanitizePathName($cmddump); $cmddump=dol_sanitizePathName($cmddump);
/* Not required, the command is output on screen but not ran for pgsql
if (! empty($dolibarr_main_restrict_os_commands))
{
$arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands);
dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump);
$basenamecmddump=basename($cmddump);
if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command
{
$errormsg=$langs->trans('CommandIsNotInsideAllowedCommands');
}
} */
if (! $errormsg && $cmddump) if (! $errormsg && $cmddump)
{ {
dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity);
@ -193,7 +195,6 @@ if ($what == 'postgresql')
} }
if ($errormsg) if ($errormsg)
{ {
setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors');
@ -230,8 +231,8 @@ $result=$formfile->list_of_documents($filearray,null,'systemtools','',1,'backup/
print '<br>'; print '<br>';
*/ */
// Redirect t backup page // Redirect to backup page
header("Location: dolibarr_export.php"); header("Location: dolibarr_export.php".(GETPOST('page_y', 'int')?'?page_y='.GETPOST('page_y', 'int'):''));
$time_end = time(); $time_end = time();

View File

@ -618,7 +618,7 @@ if ($id)
// Active // Active
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
print '<a href="'.$url.'action='.$acts[$obj->status].'">'.$actl[$obj->status].'</a>'; print '<a href="'.$url.'action='.$acts[($obj->status?1:0)].'">'.$actl[($obj->status?1:0)].'</a>';
print "</td>"; print "</td>";
// Modify link // Modify link

View File

@ -368,7 +368,7 @@ class Documents extends DolibarrApi
throw new RestException(404, 'Product not found'); throw new RestException(404, 'Product not found');
} }
$upload_dir = $conf->product->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'product'); $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
} }
elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event')
{ {

View File

@ -79,16 +79,6 @@ if (! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_
} }
/*
if (! empty($_POST['txtUsername']) && ! empty($conf->banque->enabled) && (empty($conf_fkaccount_cash) && empty($conf_fkaccount_cheque) && empty($conf_fkaccount_cb)))
{
$langs->load("errors");
$retour=$langs->trans("ErrorModuleSetupNotComplete");
header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid);
exit;
}
*/
// Check password // Check password
$auth = new Auth($db); $auth = new Auth($db);
$retour = $auth->verif($username, $password); $retour = $auth->verif($username, $password);

View File

@ -165,7 +165,7 @@ $langs->loadLangs(array("main","bills","cashdesk"));
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0)
{ {
$langs->load("errors"); $langs->load("errors");
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("Cash").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")).'" />'; print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("Cash").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
} }
else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />'; else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />';
print '</div>'; print '</div>';
@ -173,7 +173,7 @@ $langs->loadLangs(array("main","bills","cashdesk"));
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0)
{ {
$langs->load("errors"); $langs->load("errors");
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")).'" />'; print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
} }
else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />'; else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />';
print '</div>'; print '</div>';
@ -181,7 +181,7 @@ $langs->loadLangs(array("main","bills","cashdesk"));
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0)
{ {
$langs->load("errors"); $langs->load("errors");
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")).'" />'; print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete"), $langs->transnoentitiesnoconv("CashDesk")).'" />';
} }
else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />'; else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />';
print '</div>'; print '</div>';

View File

@ -168,287 +168,8 @@ if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5p
//var_dump($objectpage);exit; //var_dump($objectpage);exit;
print '<div class="centpercent websitebar">'; print '<div class="centpercent websitebar">';
if (count($object->records) > 0)
{
// ***** Part for web sites
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("WebSite").': ';
print '</div>';
// List of websites
print '<div class="websiteselection">';
$out='';
$out.='<select name="website" class="minwidth100" id="website">';
if (empty($object->records)) $out.='<option value="-1">&nbsp;</option>';
// Loop on each sites
$i=0;
foreach($object->records as $key => $valwebsite)
{
if (empty($website)) $website=$valwebsite->ref;
$out.='<option value="'.$valwebsite->ref.'"';
if ($website == $valwebsite->ref) $out.=' selected'; // To preselect a value
$out.='>';
$out.=$valwebsite->ref;
$out.='</option>';
$i++;
}
$out.='</select>';
$out.=ajax_combobox('website');
print $out;
print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">';
if ($website)
{
$virtualurl='';
$dataroot=DOL_DATA_ROOT.'/collab/'.$website;
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
}
if ($website && $action == 'preview')
{
$disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
print ' &nbsp; ';
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
}
print '</div>';
// Button for websites
print '<div class="websitetools">';
if ($action == 'preview')
{
print '<div class="websiteinputurl">';
print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" placeholder="'.$langs->trans("http://myvirtualhost").'" value="'.$virtualurl.'">';
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
print $form->textwithpicto('', $htmltext);
print '</div>';
$urlext=$virtualurl;
$urlint=$urlwithroot.'/public/collab/index.php?website='.$website;
//if (! empty($object->virtualhost))
//{
print '<a class="websitebuttonsitepreview" id="previewsiteext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
//}
print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/collab/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview');
print '</a>';
}
if (in_array($action, array('editcss','editmenu','create')))
{
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
if (preg_match('/^create/', $action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/', $action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
}
print '</div>';
// ***** Part for pages
if ($website)
{
print '</div>';
$array=$objectpage->fetchAll($object->id);
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0);
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Page").': ';
print '</div>';
print '<div class="websiteselection">';
if ($action != 'add')
{
$out='';
$out.='<select name="pageid" id="pageid" class="minwidth200">';
if ($atleastonepage)
{
if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one
{
$firstpageid=0;$homepageid=0;
foreach($array as $key => $valpage)
{
if (empty($firstpageid)) $firstpageid=$valpage->id;
if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id;
}
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
}
foreach($array as $key => $valpage)
{
$out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>';
$out.=$valpage->title;
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
$out.='</option>';
}
}
else $out.='<option value="-1">&nbsp;</option>';
$out.='</select>';
$out.=ajax_combobox('pageid');
print $out;
}
else
{
print $langs->trans("New");
}
print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
//print $form->selectarray('page', $array);
if ($action == 'preview')
{
$disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
if ($pageid > 0)
{
print ' &nbsp; ';
if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageContent")).'" name="editcontent">';
//print '<a href="'.$_SERVER["PHP_SELF"].'?action=editmeta&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageMeta")).'</a>';
//print '<a href="'.$_SERVER["PHP_SELF"].'?action=editcontent&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageContent")).'</a>';
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
}
}
print '</div>';
print '<div class="websiteselection">';
print '</div>';
print '<div class="websitetools">';
if ($website && $pageid > 0 && $action == 'preview')
{
$websitepage = new WebSitePage($db);
$websitepage->fetch($pageid);
$realpage=$urlwithroot.'/public/collab/index.php?website='.$website.'&page='.$pageid;
$pagealias = $websitepage->pageurl;
print '<div class="websiteinputurl">';
print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">';
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias);
print $form->textwithpicto('', $htmltext);
print '</div>';
if (! empty($object->virtualhost))
{
$urlext=$virtualurl.'/'.$pagealias.'.php';
print '<a class="websitebuttonsitepreview" id="previewpageext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
}
else
{
print '<a class="websitebuttonsitepreview" id="previewpageextnoclick" href="#">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
}
print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview');
print '</a>'; // View page in new Tab
//print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">';
// TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext
}
if (! in_array($action, array('editcss','editmenu','create')))
{
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
if (preg_match('/^create/', $action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/', $action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
}
print '</div>';
if ($action == 'preview')
{
// Adding jquery code to change on the fly url of preview ext
if (! empty($conf->use_javascript_ajax))
{
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#previewsiteext,#previewpageext").click(function() {
newurl=jQuery("#previewsiteurl").val();
newpage=jQuery("#previewsiteurl").val() + "/" + jQuery("#previewpageurl").val() + ".php";
console.log("Open url "+newurl);
/* Save url */
jQuery.ajax({
method: "POST",
url: "'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
data: {
field: \'editval_virtualhost\',
element: \'websites\',
table_element: \'website\',
fk_element: '.$object->id.',
value: newurl,
},
context: document.body
});
jQuery("#previewsiteext").attr("href",newurl);
jQuery("#previewpageext").attr("href",newpage);
});
});
</script>';
}
}
}
}
else
{
print '<div class="websiteselection">';
$langs->load("errors");
print $langs->trans("ErrorModuleSetupNotComplete");
print '<div>';
$action='';
}
print '</div>';
$head = array();
if ($action == 'editcontent')
{
/*
* Editing global variables not related to a specific theme
*/
$csscontent = @file_get_contents($filecss);
$contentforedit = '';
/*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
$contentforedit.=$csscontent;
$contentforedit.='</style>'."\n";*/
$contentforedit .= $objectpage->content;
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('PAGE_CONTENT', $contentforedit, '', 500, 'Full', '', true, true, true, ROWS_5, '90%');
$doleditor->Create(0, '', false);
}
print "</div>\n</form>\n"; print "</div>\n</form>\n";

View File

@ -530,11 +530,11 @@ class Propal extends CommonObject
$pu_ht_devise = $tabprice[19]; $pu_ht_devise = $tabprice[19];
// Rang to use // Rang to use
$rangtouse = $rang; $ranktouse = $rang;
if ($rangtouse == -1) if ($ranktouse == -1)
{ {
$rangmax = $this->line_max($fk_parent_line); $rangmax = $this->line_max($fk_parent_line);
$rangtouse = $rangmax + 1; $ranktouse = $rangmax + 1;
} }
// TODO A virer // TODO A virer
@ -568,7 +568,7 @@ class Propal extends CommonObject
$this->line->fk_remise_except=$fk_remise_except; $this->line->fk_remise_except=$fk_remise_except;
$this->line->remise_percent=$remise_percent; $this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu_ht; $this->line->subprice=$pu_ht;
$this->line->rang=$rangtouse; $this->line->rang=$ranktouse;
$this->line->info_bits=$info_bits; $this->line->info_bits=$info_bits;
$this->line->total_ht=$total_ht; $this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva; $this->line->total_tva=$total_tva;
@ -3515,7 +3515,7 @@ class Propal extends CommonObject
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Proposal"));
return ""; return "";
} }
} }

View File

@ -168,6 +168,7 @@ $arrayfields=array(
'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1),
'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
); );
// Extra fields // Extra fields
@ -269,10 +270,10 @@ $sql.= " typent.code as typent_code,";
$sql.= " ava.rowid as availability,"; $sql.= " ava.rowid as availability,";
$sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; $sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
$sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
$sql.= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; $sql.= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
$sql.= ' u.login'; $sql.= ' u.login';
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
// Add fields from extrafields // Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
@ -688,6 +689,12 @@ if ($resql)
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '</td>'; print '</td>';
} }
// Date cloture
if (! empty($arrayfields['p.date_cloture']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Status // Status
if (! empty($arrayfields['p.fk_statut']['checked'])) if (! empty($arrayfields['p.fk_statut']['checked']))
{ {
@ -735,6 +742,7 @@ if ($resql)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['p.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print '</tr>'."\n"; print '</tr>'."\n";
@ -1073,6 +1081,14 @@ if ($resql)
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Date cloture
if (! empty($arrayfields['p.date_cloture']['checked']))
{
print '<td align="center" class="nowrap">';
print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Status // Status
if (! empty($arrayfields['p.fk_statut']['checked'])) if (! empty($arrayfields['p.fk_statut']['checked']))
{ {

View File

@ -2590,7 +2590,7 @@ if ($action == 'create' && $usercancreate)
} }
} else { } else {
$langs->load("errors"); $langs->load("errors");
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")) . '">' . $langs->trans('CreateShipment') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Shipment"))) . '">' . $langs->trans('CreateShipment') . '</a></div>';
} }
} }
} }

View File

@ -1458,11 +1458,11 @@ class Commande extends CommonOrder
$pu_ht_devise = $tabprice[19]; $pu_ht_devise = $tabprice[19];
// Rang to use // Rang to use
$rangtouse = $rang; $ranktouse = $rang;
if ($rangtouse == -1) if ($ranktouse == -1)
{ {
$rangmax = $this->line_max($fk_parent_line); $rangmax = $this->line_max($fk_parent_line);
$rangtouse = $rangmax + 1; $ranktouse = $rangmax + 1;
} }
// TODO A virer // TODO A virer
@ -1496,7 +1496,7 @@ class Commande extends CommonOrder
$this->line->fk_remise_except=$fk_remise_except; $this->line->fk_remise_except=$fk_remise_except;
$this->line->remise_percent=$remise_percent; $this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu_ht; $this->line->subprice=$pu_ht;
$this->line->rang=$rangtouse; $this->line->rang=$ranktouse;
$this->line->info_bits=$info_bits; $this->line->info_bits=$info_bits;
$this->line->total_ht=$total_ht; $this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva; $this->line->total_tva=$total_tva;

View File

@ -143,6 +143,7 @@ $arrayfields=array(
'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
); );
@ -247,7 +248,7 @@ $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; $sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,';
$sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; $sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,';
$sql.= ' c.date_creation as date_creation, c.tms as date_update,'; $sql.= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label";
if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
// Add fields from extrafields // Add fields from extrafields
@ -693,6 +694,12 @@ if ($resql)
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '</td>'; print '</td>';
} }
// Date cloture
if (! empty($arrayfields['c.date_cloture']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Status // Status
if (! empty($arrayfields['c.fk_statut']['checked'])) if (! empty($arrayfields['c.fk_statut']['checked']))
{ {
@ -748,6 +755,7 @@ if ($resql)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (! empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
@ -1092,6 +1100,14 @@ if ($resql)
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Date cloture
if (! empty($arrayfields['c.date_cloture']['checked']))
{
print '<td align="center" class="nowrap">';
print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Status // Status
if (! empty($arrayfields['c.fk_statut']['checked'])) if (! empty($arrayfields['c.fk_statut']['checked']))
{ {

View File

@ -0,0 +1 @@

View File

@ -2828,11 +2828,11 @@ class Facture extends CommonInvoice
$pu_ht_devise = $tabprice[19]; $pu_ht_devise = $tabprice[19];
// Rank to use // Rank to use
$rangtouse = $rang; $ranktouse = $rang;
if ($rangtouse == -1) if ($ranktouse == -1)
{ {
$rangmax = $this->line_max($fk_parent_line); $rangmax = $this->line_max($fk_parent_line);
$rangtouse = $rangmax + 1; $ranktouse = $rangmax + 1;
} }
// Insert line // Insert line
@ -2866,7 +2866,7 @@ class Facture extends CommonInvoice
$this->line->date_start=$date_start; $this->line->date_start=$date_start;
$this->line->date_end=$date_end; $this->line->date_end=$date_end;
$this->line->ventil=$ventil; $this->line->ventil=$ventil;
$this->line->rang=$rangtouse; $this->line->rang=$ranktouse;
$this->line->info_bits=$info_bits; $this->line->info_bits=$info_bits;
$this->line->fk_remise_except=$fk_remise_except; $this->line->fk_remise_except=$fk_remise_except;
@ -3498,7 +3498,7 @@ class Facture extends CommonInvoice
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice"));
return ""; return "";
} }
} }

View File

@ -489,7 +489,7 @@ class RemiseCheque extends CommonObject
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Bank"));
return ""; return "";
} }
} }

View File

@ -1141,7 +1141,7 @@ class Paiement extends CommonObject
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice"));
return ""; return "";
} }
} }

View File

@ -116,7 +116,7 @@ llxHeader('', $langs->trans("NewStandingOrder"));
if (prelevement_check_config() < 0) if (prelevement_check_config() < 0)
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
} }
/*$h=0; /*$h=0;

View File

@ -58,7 +58,7 @@ llxHeader('', $langs->trans("CustomersStandingOrdersArea"));
if (prelevement_check_config() < 0) if (prelevement_check_config() < 0)
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
} }
print load_fiche_titre($langs->trans("CustomersStandingOrdersArea")); print load_fiche_titre($langs->trans("CustomersStandingOrdersArea"));

View File

@ -69,7 +69,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
} }
// Customer or supplier selected in drop box // Customer or supplier selected in drop box
$thirdTypeSelect = GETPOST("third_select_id"); $thirdTypeSelect = GETPOST("third_select_id");
$type_element = GETPOST('type_element')?GETPOST('type_element'):''; $type_element = GETPOSTISSET('type_element')?GETPOST('type_element'):'';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products"));
@ -173,13 +173,13 @@ if ($type_element == 'fichinter')
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle, '; $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle, ';
$tables_from = MAIN_DB_PREFIX.'fichinterdet d'; $tables_from = MAIN_DB_PREFIX.'fichinterdet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)";
$where = ' WHERE f.entity IN ('.getEntity('ficheinter').')'; $where = ' WHERE f.entity IN ('.getEntity('ficheinter').')';
$dateprint = 'f.datec'; $dateprint = 'f.datec';
$doc_number='f.ref'; $doc_number='f.ref';
} }
if ($type_element == 'invoice') elseif ($type_element == 'invoice')
{ // Customer : show products from invoices { // Customer : show products from invoices
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$documentstatic=new Facture($db); $documentstatic=new Facture($db);
@ -187,14 +187,14 @@ if ($type_element == 'invoice')
$tables_from = MAIN_DB_PREFIX.'facturedet d'; $tables_from = MAIN_DB_PREFIX.'facturedet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)";
$where = " WHERE f.entity IN (".getEntity('invoice').")"; $where = " WHERE f.entity IN (".getEntity('invoice').")";
$dateprint = 'f.datef'; $dateprint = 'f.datef';
$doc_number='f.ref'; $doc_number='f.ref';
$thirdTypeSelect='customer'; $thirdTypeSelect='customer';
} }
if ($type_element == 'propal') elseif ($type_element == 'propal')
{ {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$documentstatic=new Propal($db); $documentstatic=new Propal($db);
@ -202,14 +202,14 @@ if ($type_element == 'propal')
$tables_from = MAIN_DB_PREFIX.'propaldet d'; $tables_from = MAIN_DB_PREFIX.'propaldet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('propal').')'; $where = ' WHERE c.entity IN ('.getEntity('propal').')';
$datePrint = 'c.datep'; $datePrint = 'c.datep';
$doc_number='c.ref'; $doc_number='c.ref';
$thirdTypeSelect='customer'; $thirdTypeSelect='customer';
} }
if ($type_element == 'order') elseif ($type_element == 'order')
{ {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$documentstatic=new Commande($db); $documentstatic=new Commande($db);
@ -217,14 +217,14 @@ if ($type_element == 'order')
$tables_from = MAIN_DB_PREFIX.'commandedet d'; $tables_from = MAIN_DB_PREFIX.'commandedet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('order').')'; $where = ' WHERE c.entity IN ('.getEntity('order').')';
$dateprint = 'c.date_commande'; $dateprint = 'c.date_commande';
$doc_number='c.ref'; $doc_number='c.ref';
$thirdTypeSelect='customer'; $thirdTypeSelect='customer';
} }
if ($type_element == 'supplier_invoice') elseif ($type_element == 'supplier_invoice')
{ // Supplier : Show products from invoices. { // Supplier : Show products from invoices.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$documentstatic=new FactureFournisseur($db); $documentstatic=new FactureFournisseur($db);
@ -232,14 +232,14 @@ if ($type_element == 'supplier_invoice')
$tables_from = MAIN_DB_PREFIX.'facture_fourn_det d'; $tables_from = MAIN_DB_PREFIX.'facture_fourn_det d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)";
$where = ' WHERE f.entity IN ('.getEntity($documentstatic->element).')'; $where = ' WHERE f.entity IN ('.getEntity($documentstatic->element).')';
$dateprint = 'f.datef'; $dateprint = 'f.datef';
$doc_number='f.ref'; $doc_number='f.ref';
$thirdTypeSelect='supplier'; $thirdTypeSelect='supplier';
} }
//if ($type_element == 'supplier_proposal') //elseif ($type_element == 'supplier_proposal')
//{ //{
// require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; // require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
// $documentstatic=new SupplierProposal($db); // $documentstatic=new SupplierProposal($db);
@ -252,7 +252,7 @@ if ($type_element == 'supplier_invoice')
// $doc_number='c.ref'; // $doc_number='c.ref';
// $thirdTypeSelect='supplier'; // $thirdTypeSelect='supplier';
//} //}
if ($type_element == 'supplier_order') elseif ($type_element == 'supplier_order')
{ // Supplier : Show products from orders. { // Supplier : Show products from orders.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$documentstatic=new CommandeFournisseur($db); $documentstatic=new CommandeFournisseur($db);
@ -260,14 +260,14 @@ if ($type_element == 'supplier_order')
$tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d'; $tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity($documentstatic->element).')'; $where = ' WHERE c.entity IN ('.getEntity($documentstatic->element).')';
$dateprint = 'c.date_valid'; $dateprint = 'c.date_valid';
$doc_number='c.ref'; $doc_number='c.ref';
$thirdTypeSelect='supplier'; $thirdTypeSelect='supplier';
} }
if ($type_element == 'contract') elseif ($type_element == 'contract')
{ // Order { // Order
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$documentstatic=new Contrat($db); $documentstatic=new Contrat($db);
@ -276,7 +276,7 @@ if ($type_element == 'contract')
$tables_from = MAIN_DB_PREFIX.'contratdet d'; $tables_from = MAIN_DB_PREFIX.'contratdet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)"; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('contrat').')'; $where = ' WHERE c.entity IN ('.getEntity('contrat').')';
$dateprint = 'c.date_valid'; $dateprint = 'c.date_valid';

View File

@ -245,7 +245,7 @@ class Contrat extends CommonObject
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Contract"));
return ""; return "";
} }
} }

View File

@ -17,7 +17,7 @@
/** /**
* \file /htdocs/core/ajax/extraparams.php * \file /htdocs/core/ajax/extraparams.php
* \brief File to return Ajax response on set extra parameters of elements * \brief File to make Ajax action on setting extra parameters of elements
*/ */
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal

View File

@ -15,8 +15,9 @@
*/ */
/** /**
* \file htdocs/core/ajax/productonoff.php * \file htdocs/core/ajax/objectonoff.php
* \brief File to set tosell and tobuy for product * \brief File to set status for an object
* This Ajax service is called when option MAIN_DIRECT_STATUS_UPDATE is set.
*/ */
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
@ -36,6 +37,13 @@ $field=GETPOST('field', 'alpha');
$element=GETPOST('element', 'alpha'); $element=GETPOST('element', 'alpha');
$object = new GenericObject($db); $object = new GenericObject($db);
// Security check
if (! empty($user->societe_id))
$socid = $user->societe_id;
/* /*
* View * View
*/ */
@ -44,6 +52,20 @@ top_httphead();
print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
if ($element == 'societe' && in_array($field, array('status')))
{
$result = restrictedArea($user, 'societe', $id);
}
elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch')))
{
$result = restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid');
}
else
{
accessforbidden("Bad value for combination of parameters element/field.", 0, 0, 1);
exit;
}
// Registering new values // Registering new values
if (($action == 'set') && ! empty($id)) if (($action == 'set') && ! empty($id))
$object->setValueFrom($field, $value, $element, $id); $object->setValueFrom($field, $value, $element, $id);

View File

@ -0,0 +1,71 @@
<?php
/* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/ajax/pingresult.php
* \brief File to save result of an anonymous ping into database (1 ping is done per installation)
*/
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
$action=GETPOST('action', 'alpha');
$hash_unique_id=GETPOST('hash_unique_id', 'alpha');
$hash_algo=GETPOST('hash', 'alpha');
// Security check
if (! empty($user->societe_id))
$socid = $user->societe_id;
$now = dol_now();
/*
* View
*/
top_httphead();
print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// If ok
if ($action == 'firstpingok')
{
// Note: pings are by entities
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt'));
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', $hash_unique_id);
print 'First ping OK saved for entity '.$conf->entity;
}
// If ko
elseif ($action == 'firstpingko')
{
// Note: pings are by entities
dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt');
print 'First ping KO saved for entity '.$conf->entity;
}
else {
print 'Error action='.$action.' not supported';
}

View File

@ -17,7 +17,7 @@
/** /**
* \file htdocs/core/ajax/security.php * \file htdocs/core/ajax/security.php
* \brief This ajax component is used to generated has keys for security purposes * \brief This ajax component is used to generated hash keys for security purposes
* like key to use into URL to protect them. * like key to use into URL to protect them.
*/ */

View File

@ -74,6 +74,9 @@ class box_graph_invoices_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
//$facturestatic=new Facture($db); //$facturestatic=new Facture($db);
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxCustomersInvoicesPerMonth", $max); $text = $langs->trans("BoxCustomersInvoicesPerMonth", $max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, 'text' => $text,
@ -129,7 +132,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) if ($shownb)
{ {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png"; $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$endyear.'.png';
@ -145,8 +148,15 @@ class box_graph_invoices_permonth extends ModeleBoxes
unset($data1); unset($data1);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -167,7 +177,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) if ($showtot)
{ {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png"; $filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$endyear.'.png';
@ -183,8 +193,15 @@ class box_graph_invoices_permonth extends ModeleBoxes
unset($data2); unset($data2);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -73,6 +73,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max); $text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, 'text' => $text,
@ -126,7 +129,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) if ($shownb)
{ {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$year.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$year.'.png';
@ -142,8 +145,15 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
unset($data1); unset($data1);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -164,7 +174,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) if ($showtot)
{ {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png"; $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$year.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$year.'.png';
@ -180,8 +190,15 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
unset($data2); unset($data2);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -74,6 +74,9 @@ class box_graph_orders_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
//$commandestatic=new Commande($db); //$commandestatic=new Commande($db);
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxCustomersOrdersPerMonth", $max); $text = $langs->trans("BoxCustomersOrdersPerMonth", $max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, 'text' => $text,
@ -129,7 +132,7 @@ class box_graph_orders_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) if ($shownb)
{ {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png';
@ -143,8 +146,15 @@ class box_graph_orders_permonth extends ModeleBoxes
unset($data1); unset($data1);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -165,7 +175,7 @@ class box_graph_orders_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) if ($showtot)
{ {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png';
@ -179,8 +189,15 @@ class box_graph_orders_permonth extends ModeleBoxes
unset($data2); unset($data2);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -73,6 +73,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxSuppliersOrdersPerMonth", $max); $text = $langs->trans("BoxSuppliersOrdersPerMonth", $max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, 'text' => $text,
@ -128,7 +131,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) if ($shownb)
{ {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png"; $filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png';
@ -142,8 +145,15 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
unset($data1); unset($data1);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -164,7 +174,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) if ($showtot)
{ {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png"; $filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png';
@ -178,8 +188,15 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
unset($data2); unset($data2);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -74,6 +74,9 @@ class box_graph_propales_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
//$propalstatic=new Propal($db); //$propalstatic=new Propal($db);
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$langs->load("propal"); $langs->load("propal");
$text = $langs->trans("BoxProposalsPerMonth", $max); $text = $langs->trans("BoxProposalsPerMonth", $max);
@ -128,7 +131,7 @@ class box_graph_propales_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) if ($shownb)
{ {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars'); $datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars');
$filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png"; $filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png";
@ -143,8 +146,15 @@ class box_graph_propales_permonth extends ModeleBoxes
unset($data1); unset($data1);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -165,7 +175,7 @@ class box_graph_propales_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) if ($showtot)
{ {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars'); $datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars');
//$datatype2 = array('lines','bars'); //$datatype2 = array('lines','bars');
@ -182,8 +192,15 @@ class box_graph_propales_permonth extends ModeleBoxes
unset($data2); unset($data2);
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{ {
$legend[]=$i; $legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -2054,6 +2054,7 @@ abstract class CommonObject
} }
} }
/** /**
* Change the retained warranty payments terms * Change the retained warranty payments terms
* *
@ -6084,6 +6085,12 @@ abstract class CommonObject
$type='link'; $type='link';
$param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
} }
elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) {
$param['options'] = array($reg[1] . ':' . $reg[2] . ':' . $reg[3] . ':' . $reg[4] => 'N');
$type = 'sellist';
}
$langfile=$val['langfile']; $langfile=$val['langfile'];
$list=$val['list']; $list=$val['list'];
$help=$val['help']; $help=$val['help'];
@ -6105,7 +6112,7 @@ abstract class CommonObject
{ {
$morecss = 'minwidth100imp'; $morecss = 'minwidth100imp';
} }
elseif ($type == 'datetime') elseif ($type == 'datetime' || $type == 'timestamp')
{ {
$morecss = 'minwidth200imp'; $morecss = 'minwidth200imp';
} }
@ -6149,7 +6156,7 @@ abstract class CommonObject
$value=''; $value='';
} }
} }
elseif ($type == 'datetime') elseif ($type == 'datetime' || $type == 'timestamp')
{ {
if(! empty($value)) { if(! empty($value)) {
$value=dol_print_date($value, 'dayhour'); $value=dol_print_date($value, 'dayhour');
@ -7384,6 +7391,7 @@ abstract class CommonObject
if (!empty($id)) $sql.= ' WHERE rowid = '.$id; if (!empty($id)) $sql.= ' WHERE rowid = '.$id;
elseif (!empty($ref)) $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); elseif (!empty($ref)) $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']);
else $sql.=' WHERE 1 = 1'; // usage with empty id and empty ref is very rare else $sql.=' WHERE 1 = 1'; // usage with empty id and empty ref is very rare
if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.=' AND entity IN ('.getEntity($this->table_element).')';
if ($morewhere) $sql.= $morewhere; if ($morewhere) $sql.= $morewhere;
$sql.=' LIMIT 1'; // This is a fetch, to be sure to get only one record $sql.=' LIMIT 1'; // This is a fetch, to be sure to get only one record

View File

@ -1094,7 +1094,7 @@ class DolGraph
$i++; $i++;
} }
// shadowSize: 0 -> Drawing is faster without shadows // shadowSize: 0 -> Drawing is faster without shadows
$this->stringtoshow.="\n".' ], { series: { shadowSize: 0, stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6 } }'."\n"; $this->stringtoshow.="\n".' ], { series: { shadowSize: 0, stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6, fillColor: { colors: [{opacity: 0.9 }, {opacity: 0.85}] }} }'."\n";
// Xaxis // Xaxis
$this->stringtoshow.=', xaxis: { ticks: ['."\n"; $this->stringtoshow.=', xaxis: { ticks: ['."\n";

View File

@ -17,7 +17,7 @@
*/ */
/** /**
* \file htdocs/core/ajax/fileupload.php * \file htdocs/core/ajax/fileupload.class.php
* \brief File to return Ajax response on file upload * \brief File to return Ajax response on file upload
*/ */

View File

@ -199,8 +199,6 @@ class FormMargin
if (! $user->rights->margins->liretous) return; if (! $user->rights->margins->liretous) return;
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
$marginInfo = $this->getMarginInfosArray($object, $force_price); $marginInfo = $this->getMarginInfosArray($object, $force_price);
if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better
@ -240,13 +238,13 @@ class FormMargin
//if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans('MarginOnProducts').'</td>'; print '<td>'.$langs->trans('MarginOnProducts').'</td>';
print '<td class="right">'.price($marginInfo['pv_products'], null, null, null, null, $rounding).'</td>'; print '<td class="right">'.price($marginInfo['pv_products']).'</td>';
print '<td class="right">'.price($marginInfo['pa_products'], null, null, null, null, $rounding).'</td>'; print '<td class="right">'.price($marginInfo['pa_products']).'</td>';
print '<td class="right">'.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).'</td>'; print '<td class="right">'.price($marginInfo['margin_on_products']).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td class="right">'.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').'</td>'; print '<td class="right">'.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, 2).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES)) if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td class="right">'.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'</td>'; print '<td class="right">'.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, 2).'%').'</td>';
print '</tr>'; print '</tr>';
} }
@ -254,13 +252,13 @@ class FormMargin
{ {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans('MarginOnServices').'</td>'; print '<td>'.$langs->trans('MarginOnServices').'</td>';
print '<td class="right">'.price($marginInfo['pv_services'], null, null, null, null, $rounding).'</td>'; print '<td class="right">'.price($marginInfo['pv_services']).'</td>';
print '<td class="right">'.price($marginInfo['pa_services'], null, null, null, null, $rounding).'</td>'; print '<td class="right">'.price($marginInfo['pa_services']).'</td>';
print '<td class="right">'.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).'</td>'; print '<td class="right">'.price($marginInfo['margin_on_services']).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td class="right">'.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').'</td>'; print '<td class="right">'.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, 2).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES)) if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td class="right">'.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'</td>'; print '<td class="right">'.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, 2).'%').'</td>';
print '</tr>'; print '</tr>';
} }
@ -268,13 +266,13 @@ class FormMargin
{ {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td>'.$langs->trans('TotalMargin').'</td>'; print '<td>'.$langs->trans('TotalMargin').'</td>';
print '<td class="right">'.price($marginInfo['pv_total'], null, null, null, null, $rounding).'</td>'; print '<td class="right">'.price($marginInfo['pv_total']).'</td>';
print '<td class="right">'.price($marginInfo['pa_total'], null, null, null, null, $rounding).'</td>'; print '<td class="right">'.price($marginInfo['pa_total']).'</td>';
print '<td class="right">'.price($marginInfo['total_margin'], null, null, null, null, $rounding).'</td>'; print '<td class="right">'.price($marginInfo['total_margin']).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td class="right">'.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').'</td>'; print '<td class="right">'.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES)) if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td class="right">'.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'</td>'; print '<td class="right">'.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'</td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';

View File

@ -40,9 +40,11 @@ abstract class Stats
* @param int $startyear End year * @param int $startyear End year
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month
* @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january
* @return array Array of values * @return array Array of values
*/ */
public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -86,6 +88,8 @@ abstract class Stats
else else
{ {
$year=$startyear; $year=$startyear;
$sm = $startmonth - 1;
if ($sm != 0) $year = $year - 1;
while ($year <= $endyear) while ($year <= $endyear)
{ {
$datay[$year] = $this->getNbByMonth($year, $format); $datay[$year] = $this->getNbByMonth($year, $format);
@ -96,11 +100,11 @@ abstract class Stats
for ($i = 0 ; $i < 12 ; $i++) for ($i = 0 ; $i < 12 ; $i++)
{ {
$data[$i][]=$datay[$endyear][$i][0]; $data[$i][]=$datay[$endyear][($i+$sm)%12][0];
$year=$startyear; $year=$startyear;
while($year <= $endyear) while($year <= $endyear)
{ {
$data[$i][]=$datay[$year][$i][1]; $data[$i][]=$datay[$year - (1 - ((int) ($i+$sm)/12)) + ($sm == 0 ? 1 : 0)][($i+$sm)%12][1];
$year++; $year++;
} }
} }
@ -134,9 +138,10 @@ abstract class Stats
* @param int $startyear End year * @param int $startyear End year
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month
* @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january
* @return array Array of values * @return array Array of values
*/ */
public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -181,6 +186,8 @@ abstract class Stats
else else
{ {
$year=$startyear; $year=$startyear;
$sm = $startmonth - 1;
if ($sm != 0) $year = $year - 1;
while($year <= $endyear) while($year <= $endyear)
{ {
$datay[$year] = $this->getAmountByMonth($year, $format); $datay[$year] = $this->getAmountByMonth($year, $format);
@ -191,11 +198,11 @@ abstract class Stats
// $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...) // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
for ($i = 0 ; $i < 12 ; $i++) for ($i = 0 ; $i < 12 ; $i++)
{ {
$data[$i][]=$datay[$endyear][$i][0]; // set label $data[$i][]=$datay[$endyear][($i+$sm)%12][0]; // set label
$year=$startyear; $year=$startyear;
while($year <= $endyear) while($year <= $endyear)
{ {
$data[$i][]=$datay[$year][$i][1]; // set yval for x=i $data[$i][]=$datay[$year - (1 - ((int) ($i+$sm)/12)) + ($sm == 0 ? 1 : 0)][($i+$sm)%12][1]; // set yval for x=i
$year++; $year++;
} }
} }
@ -411,7 +418,8 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Renvoie le nombre de proposition par mois pour une annee donnee * Renvoie le nombre de documents par mois pour une annee donnee
* Return number of documents per month for a given year
* *
* @param int $year Year * @param int $year Year
* @param string $sql SQL * @param string $sql SQL
@ -470,7 +478,8 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Renvoie le nombre d'element par mois pour une annee donnee * Renvoie le montant totalise par mois pour une annee donnee
* Return the amount per month for a given year
* *
* @param int $year Year * @param int $year Year
* @param string $sql SQL * @param string $sql SQL
@ -527,6 +536,7 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Renvoie le montant moyen par mois pour une annee donnee * Renvoie le montant moyen par mois pour une annee donnee
* Return the amount average par month for a given year
* *
* @param int $year Year * @param int $year Year
* @param string $sql SQL * @param string $sql SQL

View File

@ -148,6 +148,7 @@ print '
/* Set handler to add page_y param on output (click on href links or submit button) */ /* Set handler to add page_y param on output (click on href links or submit button) */
jQuery(".reposition").click(function() { jQuery(".reposition").click(function() {
var page_y = $(document).scrollTop(); var page_y = $(document).scrollTop();
if (page_y > 0) if (page_y > 0)
{ {
if (this.href) if (this.href)
@ -157,7 +158,7 @@ print '
} }
else else
{ {
console.log("We click on tag with .reposition class but element is not an <a> html tag, so we try to update form field page_y with value "+page_y); console.log("We click on tag with .reposition class but element is not an <a> html tag, so we try to update input form field page_y with value "+page_y);
jQuery("input[type=hidden][name=page_y]").val(page_y); jQuery("input[type=hidden][name=page_y]").val(page_y);
} }
} }

View File

@ -538,11 +538,12 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
} }
/** /**
* On/off button for object * On/off button to change status of an object
* This is called when MAIN_DIRECT_STATUS_UPDATE is set and it use tha ajax service objectonoff.php
* *
* @param Object $object Object to set * @param Object $object Object to set
* @param string $code Name of constant : status or status_buy for product by example * @param string $code Name of constant : status or status_buy for product by example
* @param string $field Name of database field : tosell or tobuy for product by example * @param string $field Name of database field : 'tosell' or 'tobuy' for product by example
* @param string $text_on Text if on * @param string $text_on Text if on
* @param string $text_off Text if off * @param string $text_off Text if off
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))

View File

@ -555,6 +555,7 @@ function dol_count_nb_of_line($file)
* *
* @param string $pathoffile Path of file * @param string $pathoffile Path of file
* @return integer File size * @return integer File size
* @see dol_print_size()
*/ */
function dol_filesize($pathoffile) function dol_filesize($pathoffile)
{ {
@ -2164,6 +2165,12 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); $accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file)));
$original_file=$dolibarr_main_data_root.'/'.$original_file; $original_file=$dolibarr_main_data_root.'/'.$original_file;
} }
// Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log
elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root))
{
$accessallowed=($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file)));
$original_file=$dolibarr_main_data_root.'/doctemplates/websites/'.$original_file;
}
// Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip
elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root))
{ {

View File

@ -2467,6 +2467,13 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
$newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
} }
} }
elseif (strtoupper($countrycode) == "JM")
{//Jamaïque
if(dol_strlen($newphone) == 12)
{//ex: +1867_ABC_DEFG
$newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
}
}
elseif (strtoupper($countrycode) == "MG") elseif (strtoupper($countrycode) == "MG")
{//Madagascar {//Madagascar
if(dol_strlen($phone) == 13) if(dol_strlen($phone) == 13)
@ -4420,7 +4427,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
{ {
if ($currency_code == 'auto') $currency_code=$conf->currency; if ($currency_code == 'auto') $currency_code=$conf->currency;
$listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY'); $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY','CAD');
$listoflanguagesbefore=array('nl_NL'); $listoflanguagesbefore=array('nl_NL');
if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore))
{ {
@ -6573,12 +6580,19 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o
{ {
$newmesgarray=array(); $newmesgarray=array();
foreach($mesgarray as $val) foreach($mesgarray as $val)
{
if (is_string($val))
{ {
$tmpmesgstring=preg_replace('/<\/div><div class="(error|warning)">/', '<br>', $val); $tmpmesgstring=preg_replace('/<\/div><div class="(error|warning)">/', '<br>', $val);
$tmpmesgstring=preg_replace('/<div class="(error|warning)">/', '', $tmpmesgstring); $tmpmesgstring=preg_replace('/<div class="(error|warning)">/', '', $tmpmesgstring);
$tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring); $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring);
$newmesgarray[]=$tmpmesgstring; $newmesgarray[]=$tmpmesgstring;
} }
else
{
dol_syslog("Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
}
}
$mesgarray=$newmesgarray; $mesgarray=$newmesgarray;
} }
print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror?'error':'warning'), $keepembedded); print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror?'error':'warning'), $keepembedded);

View File

@ -576,6 +576,7 @@ function isValidVATID($company)
{ {
$vatprefix = $company->country_code; $vatprefix = $company->country_code;
if ($vatprefix == 'GR') $vatprefix = '(EL|GR)'; if ($vatprefix == 'GR') $vatprefix = '(EL|GR)';
elseif ($vatprefix == 'MC') $vatprefix = 'FR'; // Monaco is using french VAT numbers
else $vatprefix = preg_quote($vatprefix, '/'); else $vatprefix = preg_quote($vatprefix, '/');
if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra))) if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra)))
{ {

View File

@ -279,7 +279,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
// Check write permission from module (we need to know write permission to create but also to delete drafts record) // Check write permission from module (we need to know write permission to create but also to delete drafts record)
$createok=1; $nbko=0; $createok=1; $nbko=0;
if (GETPOST('action', 'aZ09') == 'create' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')) if (GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete'))
{ {
foreach ($featuresarray as $feature) foreach ($featuresarray as $feature)
{ {
@ -329,7 +329,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
// If a or and at least one ok // If a or and at least one ok
if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1; if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1;
if (GETPOST('action', 'aZ09') == 'create' && ! $createok) accessforbidden(); if ((GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update') && ! $createok) accessforbidden();
//print "Write access is ok"; //print "Write access is ok";
} }

View File

@ -38,7 +38,8 @@ function takepos_prepare_head()
$head[$h][2] = 'setup'; $head[$h][2] = 'setup';
$h++; $h++;
for ($i = 1; $i <= $conf->global->TAKEPOS_NUM_TERMINALS; $i++) $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS);
for ($i = 1; $i <= $numterminals; $i++)
{ {
$head[$h][0] = DOL_URL_ROOT.'/takepos/admin/terminal.php?terminal='.$i; $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/terminal.php?terminal='.$i;
$head[$h][1] = $langs->trans("Terminal"). " ".$i; $head[$h][1] = $langs->trans("Terminal"). " ".$i;

View File

@ -295,10 +295,9 @@ function user_admin_prepare_head()
* @param boolean $foruserprofile Show for user profile view * @param boolean $foruserprofile Show for user profile view
* @return void * @return void
*/ */
function show_theme($fuser, $edit = 0, $foruserprofile = false) function showSkins($fuser, $edit = 0, $foruserprofile = false)
{ {
global $conf,$langs,$db,$form; global $conf,$langs,$db,$form;
global $bc;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
@ -351,9 +350,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
{ {
print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("DefaultSkin").'</th>'; print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("DefaultSkin").'</th>';
print '<th class="right">'; print '<th class="right">';
$url='https://www.dolistore.com/lang-en/4-skins'; $url='https://www.dolistore.com/4-skins';
if (preg_match('/fr/i', $langs->defaultlang)) $url='https://www.dolistore.com/fr/4-themes';
//if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes';
print '<a href="'.$url.'" target="_blank">'; print '<a href="'.$url.'" target="_blank">';
print $langs->trans('DownloadMoreSkins'); print $langs->trans('DownloadMoreSkins');
print '</a>'; print '</a>';
@ -432,7 +429,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("TopMenuDisableImages").'</td>'; print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
print '<td>'.($conf->global->THEME_TOPMENU_DISABLE_IMAGE?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:$langs->trans("Default")).'</td>'; print '<td>'.($conf->global->THEME_TOPMENU_DISABLE_IMAGE?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:$langs->trans("Default")).'</td>';
print '<td class="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_THEME_TOPMENU_DISABLE_IMAGE" id="check_THEME_TOPMENU_DISABLE_IMAGE" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TEXTLINK)?" checked":""); print '<td class="left" class="nowrap" width="20%"><input name="check_THEME_TOPMENU_DISABLE_IMAGE" id="check_THEME_TOPMENU_DISABLE_IMAGE" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TEXTLINK)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").'</td>'; print '> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'; print '<td>';
@ -477,7 +474,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>'; print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'</td>'; print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'</td>';
print '<td class="nowrap left" width="20%"><input '.$bc[$var].' name="check_THEME_ELDY_TOPMENU_BACK1" id="check_THEME_ELDY_TOPMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); print '<td class="nowrap left" width="20%"><input name="check_THEME_ELDY_TOPMENU_BACK1" id="check_THEME_ELDY_TOPMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").'</td>'; print '> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'; print '<td>';
@ -524,7 +521,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>'; print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'</td>'; print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'</td>';
print '<td class="nowrap left" width="20%"><input '.$bc[$var].' name="check_THEME_ELDY_TOPMENU_BACK1" id="check_THEME_ELDY_TOPMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); print '<td class="nowrap left" width="20%"><input name="check_THEME_ELDY_TOPMENU_BACK1" id="check_THEME_ELDY_TOPMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").'</td>'; print '> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'; print '<td>';
@ -573,7 +570,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>'; print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_VERMENU_BACK1:$langs->trans("Default")).'</td>'; print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_VERMENU_BACK1:$langs->trans("Default")).'</td>';
print '<td class="nowrap left" width="20%"><input '.$bc[$var].' name="check_THEME_ELDY_VERMENU_BACK1" id="check_THEME_ELDY_VERMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); print '<td class="nowrap left" width="20%"><input name="check_THEME_ELDY_VERMENU_BACK1" id="check_THEME_ELDY_VERMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").'</td>'; print '> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'; print '<td>';
@ -763,7 +760,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>'; print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TEXTLINK:$langs->trans("Default")).'</td>'; print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TEXTLINK:$langs->trans("Default")).'</td>';
print '<td class="nowrap left" width="20%"><input '.$bc[$var].' name="check_THEME_ELDY_TEXTLINK" id="check_THEME_ELDY_TEXTLINK" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TEXTLINK)?" checked":""); print '<td class="nowrap left" width="20%"><input name="check_THEME_ELDY_TEXTLINK" id="check_THEME_ELDY_TEXTLINK" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TEXTLINK)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").'</td>'; print '> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'; print '<td>';
@ -813,9 +810,9 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
/* Must first change option to choose color of highlight instead of yes or no. /* Must first change option to choose color of highlight instead of yes or no.
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("HighlightLinesOnMouseHover").'</td>'; print '<td>'.$langs->trans("HighlightLinesOnMouseHover").'</td>';
print '<td><input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER" disabled="disabled" type="checkbox" '.($conf->global->THEME_ELDY_USE_HOVER?" checked":"").'></td>'; print '<td><input name="check_THEME_ELDY_USE_HOVER" disabled="disabled" type="checkbox" '.($conf->global->THEME_ELDY_USE_HOVER?" checked":"").'></td>';
print '<td class="nowrap left" width="20%"><input '.$bc[$var].' name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>'; print '<td class="nowrap left" width="20%"><input name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
print '<td><input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled="disabled"').' type="checkbox" '.($hoverdisabled?"":" checked").'>'; print '<td><input name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled="disabled"').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -825,7 +822,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("HighlightLinesColor").'</td>'; print '<td>'.$langs->trans("HighlightLinesColor").'</td>';
print '<td colspan="'.($colspan-1).'">'; print '<td colspan="'.($colspan-1).'">';
//print '<input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>'; //print '<input name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
//print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; //print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
if ($edit) if ($edit)
{ {
@ -856,9 +853,9 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
/* Must first change option to choose color of highlight instead of yes or no. /* Must first change option to choose color of highlight instead of yes or no.
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("HighlightLinesOnMouseHover").'</td>'; print '<td>'.$langs->trans("HighlightLinesOnMouseHover").'</td>';
print '<td><input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER" disabled="disabled" type="checkbox" '.($conf->global->THEME_ELDY_USE_HOVER?" checked":"").'></td>'; print '<td><input name="check_THEME_ELDY_USE_HOVER" disabled="disabled" type="checkbox" '.($conf->global->THEME_ELDY_USE_HOVER?" checked":"").'></td>';
print '<td class="nowrap left" width="20%"><input '.$bc[$var].' name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>'; print '<td class="nowrap left" width="20%"><input name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
print '<td><input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled="disabled"').' type="checkbox" '.($hoverdisabled?"":" checked").'>'; print '<td><input name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled="disabled"').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -869,7 +866,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("HighlightLinesChecked").'</td>'; print '<td>'.$langs->trans("HighlightLinesChecked").'</td>';
print '<td colspan="'.($colspan-1).'">'; print '<td colspan="'.($colspan-1).'">';
//print '<input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>'; //print '<input name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
//print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; //print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
if ($edit) if ($edit)
{ {
@ -947,5 +944,44 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
*/ */
} }
// Use MAIN_OPTIMIZEFORTEXTBROWSER
if ($foruserprofile)
{
//$default=yn($conf->global->MAIN_OPTIMIZEFORCOLORBLIND);
$default=$langs->trans('No');
print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_OPTIMIZEFORCOLORBLIND").'</td>';
print '<td colspan="'.($colspan-1).'">';
$colorBlindOptions = array(
0 => $langs->trans('No'),
'protanopia' => $langs->trans('Protanopia'),
'deuteranopes' => $langs->trans('Deuteranopes'),
'tritanopes' => $langs->trans('Tritanopes'),
);
if ($edit)
{
print $form->selectArray('MAIN_OPTIMIZEFORCOLORBLIND', $colorBlindOptions, $fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND, 0);
}
else
{
if (!empty($fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND) && isset($colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND])){
print $colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND];
}
else{
print yn(0);
}
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
print $form->textwithpicto('', $langs->trans("MAIN_OPTIMIZEFORCOLORBLINDDesc"));
print '</td>';
print '</tr>';
}
else
{
}
print '</table>'; print '</table>';
} }

View File

@ -29,13 +29,16 @@
* @param Website $website Web site object * @param Website $website Web site object
* @param string $content Content to replace * @param string $content Content to replace
* @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections. * @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections.
* @param string $contenttype Content type
* @return boolean True if OK * @return boolean True if OK
* @see dolWebsiteOutput() for function used to replace content in a web server context * @see dolWebsiteOutput() for function used to replace content in a web server context
*/ */
function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0) function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $contenttype='html')
{ {
$nbrep = 0; $nbrep = 0;
dol_syslog('dolWebsiteReplacementOfLinks start (contenttype='.$contenttype." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')', LOG_DEBUG);
// Replace php code. Note $content may come from database and does not contains body tags. // Replace php code. Note $content may come from database and does not contains body tags.
$replacewith='...php...'; $replacewith='...php...';
if ($removephppart) $replacewith=''; if ($removephppart) $replacewith='';
@ -90,6 +93,8 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0)
$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
$content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
dol_syslog('dolWebsiteReplacementOfLinks end', LOG_DEBUG);
return $content; return $content;
} }
@ -177,15 +182,17 @@ function dolKeepOnlyPhpCode($str)
* Used to ouput the page when viewed from server (Dolibarr or Apache). * Used to ouput the page when viewed from server (Dolibarr or Apache).
* *
* @param string $content Content string * @param string $content Content string
* @param string $contenttype Content type
* @param int $containerid Contenair id
* @return void * @return void
* @see dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context when USEDOLIBARREDITOR is not on * @see dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context when USEDOLIBARREDITOR is not on
*/ */
function dolWebsiteOutput($content) function dolWebsiteOutput($content, $contenttype='html', $containerid='')
{ {
global $db, $langs, $conf, $user; global $db, $langs, $conf, $user;
global $dolibarr_main_url_root, $dolibarr_main_data_root; global $dolibarr_main_url_root, $dolibarr_main_data_root;
dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')'); dol_syslog("dolWebsiteOutput start (contenttype=".$contenttype." containerid=".$containerid." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')');
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
@ -195,10 +202,13 @@ function dolWebsiteOutput($content)
if (defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr editor if (defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr editor
{ {
// We remove the <head> part of content // We remove the <head> part of content
if ($contenttype == 'html')
{
$content = preg_replace('/<head>.*<\/head>/ims', '', $content); $content = preg_replace('/<head>.*<\/head>/ims', '', $content);
$content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $content); $content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $content);
$content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content); $content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content);
} }
}
elseif (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server elseif (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server
{ {
global $website; global $website;
@ -285,7 +295,7 @@ function dolWebsiteOutput($content)
* *
* @param string $content Content string * @param string $content Content string
* @return void * @return void
* @see dolWebsiteOutput * @see dolWebsiteOutput()
*/ */
/* /*
function dolWebsiteSaveContent($content) function dolWebsiteSaveContent($content)
@ -342,9 +352,9 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri
if (defined('USEDOLIBARREDITOR')) if (defined('USEDOLIBARREDITOR'))
{ {
print '<div class="margintoponly marginleftonly">'; print '<div class="margintoponly marginleftonly">';
print "This page contains dynamic code that make a redirect to '".$containerref."' in your current context. There is no preview for this page."; print "This page contains dynamic code that make a redirect to '".$containerref."' in your current context. Redirect has been canceled as it is not supported in edition mode.";
print '</div>'; print '</div>';
exit; return;
} }
if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server
@ -452,8 +462,6 @@ function includeContainer($containerref)
function getStructuredData($type, $data = array()) function getStructuredData($type, $data = array())
{ {
global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers. global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
global $includehtmlcontentopened;
global $websitekey, $websitepagefile;
if ($type == 'software') if ($type == 'software')
{ {
@ -561,6 +569,108 @@ function getStructuredData($type, $data = array())
return $ret; return $ret;
} }
/**
* Return list of containers object that match a criteria
*
* @param string $type Type of container to search into (Example: 'page')
* @param string $algo Algorithm used for search (Example: 'meta' is searching into meta information like title and description, 'metacontent')
* @param string $searchstring Search string
* @param int $max Max number of answers
* @return string HTML content
*/
function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25)
{
global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
$error = 0;
$arrayresult = array('code'=>'', 'list'=>array());
if (! is_object($weblangs)) $weblangs = $langs;
if (empty($searchstring))
{
$error++;
$arrayresult['code']='KO';
$arrayresult['message']=$weblangs->trans("EmptySearchString");
}
elseif (dol_strlen($searchstring) < 2)
{
$weblangs->load("errors");
$error++;
$arrayresult['code']='KO';
$arrayresult['message']=$weblangs->trans("ErrorSearchCriteriaTooSmall");
}
elseif (! in_array($type, array('', 'page')))
{
$error++;
$arrayresult['code']='KO';
$arrayresult['message']='Bad value for parameter $type';
}
$searchdone = 0;
if (! $error && in_array($algo, array('meta', 'metacontent', 'content')))
{
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page';
$sql.= " WHERE fk_website = ".$website->id;
if ($type) $sql.= " AND type_container = '".$db->escape($type)."'";
$sql.= " AND (";
$searchalgo = '';
if ($algo == 'meta' || $algo == 'metacontent')
{
$searchalgo.= ($searchalgo?' OR ':'')."title LIKE '%".$db->escape($searchstring)."%' OR description LIKE '%".$db->escape($searchstring)."%'";
$searchalgo.= ($searchalgo?' OR ':'')."keywords LIKE '".$db->escape($searchstring).",%' OR keywords LIKE '% ".$db->escape($searchstring)."%'"; // TODO Use a better way to scan keywords
}
if ($algo == 'metacontent' || $algo == 'content')
{
$searchalgo.= ($searchalgo?' OR ':'')."content LIKE '%".$db->escape($searchstring)."%'";
}
$sql.=$searchalgo;
$sql.= ")";
$sql.= $db->plimit($max);
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
while (($obj = $db->fetch_object($resql)) && ($i < $max || $max == 0))
{
if ($obj->rowid > 0)
{
$tmpwebsitepage = new WebsitePage($db);
$tmpwebsitepage->fetch($obj->rowid);
if ($tmpwebsitepage->id > 0) $arrayresult['list'][]=$tmpwebsitepage;
}
$i++;
}
$arrayresult['code']='OK';
if (empty($arrayresult['list']))
{
$arrayresult['code']='KO';
$arrayresult['message']=$weblangs->trans("NoRecordFound");
}
}
else
{
$error++;
$arrayresult['code']=$db->lasterrno();
$arrayresult['message']=$db->lasterror();
}
$searchdone = 1;
}
if (! $searchdone)
{
$error++;
$arrayresult['code']='KO';
$arrayresult['message']='No supported algorithm found';
}
return $arrayresult;
}
/** /**
* Download all images found into page content $tmp. * Download all images found into page content $tmp.
* If $modifylinks is set, links to images will be replace with a link to viewimage wrapper. * If $modifylinks is set, links to images will be replace with a link to viewimage wrapper.
@ -744,313 +854,3 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify
} }
} }
} }
/**
* Save content of a page on disk
*
* @param string $filemaster Full path of filename master.inc.php for website to generate
* @return boolean True if OK
*/
function dolSaveMasterFile($filemaster)
{
global $conf;
// Now generate the master.inc.php page
dol_syslog("We regenerate the master file");
dol_delete_file($filemaster);
$mastercontent = '<?php'."\n";
$mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
$mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
$mastercontent.= '?>'."\n";
$result = file_put_contents($filemaster, $mastercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
return $result;
}
/**
* Save content of a page on disk
*
* @param string $filealias Full path of filename to generate
* @param Website $object Object website
* @param WebsitePage $objectpage Object websitepage
* @return boolean True if OK
*/
function dolSavePageAlias($filealias, $object, $objectpage)
{
global $conf;
// Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
dol_syslog("We regenerate the alias page filealias=".$filealias);
$aliascontent = '<?php'."\n";
$aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
$aliascontent.= 'global $dolibarr_main_data_root;'."\n";
$aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
$aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
$aliascontent.= '?>'."\n";
$result = file_put_contents($filealias, $aliascontent);
if (! empty($conf->global->MAIN_UMASK)) {
@chmod($filealias, octdec($conf->global->MAIN_UMASK));
}
return ($result?true:false);
}
/**
* Save content of a page on disk
*
* @param string $filetpl Full path of filename to generate
* @param Website $object Object website
* @param WebsitePage $objectpage Object websitepage
* @return boolean True if OK
*/
function dolSavePageContent($filetpl, $object, $objectpage)
{
global $conf;
// Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
dol_delete_file($filetpl);
$shortlangcode = '';
if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
$tplcontent ='';
$tplcontent.= "<?php // BEGIN PHP\n";
$tplcontent.= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$tplcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$tplcontent.= "ob_start();\n";
$tplcontent.= "// END PHP ?>\n";
if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
{
$tplcontent.= "<!DOCTYPE html>\n";
}
$tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n";
$tplcontent.= '<head>'."\n";
$tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
$tplcontent.= '<meta charset="UTF-8">'."\n";
$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
$tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
$tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
$tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
$tplcontent.= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
$tplcontent.= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
$tplcontent.= '<!-- Include link to CSS file -->'."\n";
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
$tplcontent.= '<!-- Include HTML header from common file -->'."\n";
$tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
$tplcontent.= '<!-- Include HTML header from page header block -->'."\n";
$tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
$tplcontent.= '</head>'."\n";
$tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n";
$tplcontent.= '<body id="bodywebsite" class="bodywebsite">'."\n";
$tplcontent.= $objectpage->content."\n";
$tplcontent.= '</body>'."\n";
$tplcontent.= '</html>'."\n";
$tplcontent.= '<?php // BEGIN PHP'."\n";
$tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
$tplcontent.= "// END PHP ?>"."\n";
//var_dump($filetpl);exit;
$result = file_put_contents($filetpl, $tplcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
return $result;
}
/**
* Save content of the index.php and wrapper.php page
*
* @param string $pathofwebsite Path of website root
* @param string $fileindex Full path of file index.php
* @param string $filetpl File tpl to index.php page redirect to
* @param string $filewrapper Full path of file wrapper.php
* @return boolean True if OK
*/
function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
{
global $conf;
$result1=false;
$result2=false;
dol_mkdir($pathofwebsite);
dol_delete_file($fileindex);
$indexcontent = '<?php'."\n";
$indexcontent.= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
$indexcontent.= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$indexcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
$indexcontent.= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
$indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$indexcontent.= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
$indexcontent.= "}\n";
$indexcontent.= "include_once './".basename($filetpl)."'\n";
$indexcontent.= '// END PHP ?>'."\n";
$result1 = file_put_contents($fileindex, $indexcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
dol_delete_file($filewrapper);
$wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
$result2 = file_put_contents($filewrapper, $wrappercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
return ($result1 && $result2);
}
/**
* Save content of a page on disk
*
* @param string $filehtmlheader Full path of filename to generate
* @param string $htmlheadercontent Content of file
* @return boolean True if OK
*/
function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
{
global $conf, $pathofwebsite;
dol_syslog("Save html header into ".$filehtmlheader);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filehtmlheader, $htmlheadercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
return false;
}
return true;
}
/**
* Save content of a page on disk
*
* @param string $filecss Full path of filename to generate
* @param string $csscontent Content of file
* @return boolean True if OK
*/
function dolSaveCssFile($filecss, $csscontent)
{
global $conf, $pathofwebsite;
dol_syslog("Save css file into ".$filecss);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filecss, $csscontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filecss, null, 'errors');
return false;
}
return true;
}
/**
* Save content of a page on disk
*
* @param string $filejs Full path of filename to generate
* @param string $jscontent Content of file
* @return boolean True if OK
*/
function dolSaveJsFile($filejs, $jscontent)
{
global $conf, $pathofwebsite;
dol_syslog("Save js file into ".$filejs);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filejs, $jscontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filejs, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filejs, null, 'errors');
return false;
}
return true;
}
/**
* Save content of a page on disk
*
* @param string $filerobot Full path of filename to generate
* @param string $robotcontent Content of file
* @return boolean True if OK
*/
function dolSaveRobotFile($filerobot, $robotcontent)
{
global $conf, $pathofwebsite;
dol_syslog("Save robot file into ".$filerobot);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filerobot, $robotcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filerobot, null, 'errors');
return false;
}
return true;
}
/**
* Save content of a page on disk
*
* @param string $filehtaccess Full path of filename to generate
* @param string $htaccess Content of file
* @return boolean True if OK
*/
function dolSaveHtaccessFile($filehtaccess, $htaccess)
{
global $conf, $pathofwebsite;
dol_syslog("Save htaccess file into ".$filehtaccess);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filehtaccess, $htaccess);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
return false;
}
return true;
}

View File

@ -0,0 +1,457 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/lib/website2.lib.php
* \ingroup website
* \brief Library for website module (rare functions not required for execution of website)
*/
/**
* Save content of a page on disk
*
* @param string $filemaster Full path of filename master.inc.php for website to generate
* @return boolean True if OK
*/
function dolSaveMasterFile($filemaster)
{
global $conf;
// Now generate the master.inc.php page
dol_syslog("We regenerate the master file");
dol_delete_file($filemaster);
$mastercontent = '<?php'."\n";
$mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
$mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
$mastercontent.= '?>'."\n";
$result = file_put_contents($filemaster, $mastercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
return $result;
}
/**
* Save content of a page on disk
*
* @param string $filealias Full path of filename to generate
* @param Website $object Object website
* @param WebsitePage $objectpage Object websitepage
* @return boolean True if OK
*/
function dolSavePageAlias($filealias, $object, $objectpage)
{
global $conf;
// Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
dol_syslog("We regenerate the alias page filealias=".$filealias);
$aliascontent = '<?php'."\n";
$aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
$aliascontent.= 'global $dolibarr_main_data_root;'."\n";
$aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
$aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
$aliascontent.= '?>'."\n";
$result = file_put_contents($filealias, $aliascontent);
if (! empty($conf->global->MAIN_UMASK)) {
@chmod($filealias, octdec($conf->global->MAIN_UMASK));
}
return ($result?true:false);
}
/**
* Save content of a page on disk
*
* @param string $filetpl Full path of filename to generate
* @param Website $object Object website
* @param WebsitePage $objectpage Object websitepage
* @return boolean True if OK
*/
function dolSavePageContent($filetpl, $object, $objectpage)
{
global $conf;
// Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
dol_delete_file($filetpl);
$shortlangcode = '';
if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
$tplcontent ='';
$tplcontent.= "<?php // BEGIN PHP\n";
$tplcontent.= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$tplcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$tplcontent.= "ob_start();\n";
$tplcontent.= "// END PHP ?>\n";
if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
{
$tplcontent.= "<!DOCTYPE html>\n";
}
$tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n";
$tplcontent.= '<head>'."\n";
$tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
$tplcontent.= '<meta charset="UTF-8">'."\n";
$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
$tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
$tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
$tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
$tplcontent.= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
$tplcontent.= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
$tplcontent.= '<!-- Include link to CSS file -->'."\n";
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
$tplcontent.= '<!-- Include HTML header from common file -->'."\n";
$tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
$tplcontent.= '<!-- Include HTML header from page header block -->'."\n";
$tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
$tplcontent.= '</head>'."\n";
$tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n";
$tplcontent.= '<body id="bodywebsite" class="bodywebsite">'."\n";
$tplcontent.= $objectpage->content."\n";
$tplcontent.= '</body>'."\n";
$tplcontent.= '</html>'."\n";
$tplcontent.= '<?php // BEGIN PHP'."\n";
$tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.');'."\n";
$tplcontent.= "// END PHP ?>"."\n";
//var_dump($filetpl);exit;
$result = file_put_contents($filetpl, $tplcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
return $result;
}
/**
* Save content of the index.php and wrapper.php page
*
* @param string $pathofwebsite Path of website root
* @param string $fileindex Full path of file index.php
* @param string $filetpl File tpl to index.php page redirect to
* @param string $filewrapper Full path of file wrapper.php
* @return boolean True if OK
*/
function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
{
global $conf;
$result1=false;
$result2=false;
dol_mkdir($pathofwebsite);
dol_delete_file($fileindex);
$indexcontent = '<?php'."\n";
$indexcontent.= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
$indexcontent.= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$indexcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
$indexcontent.= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
$indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$indexcontent.= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
$indexcontent.= "}\n";
$indexcontent.= "include_once './".basename($filetpl)."'\n";
$indexcontent.= '// END PHP ?>'."\n";
$result1 = file_put_contents($fileindex, $indexcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
dol_delete_file($filewrapper);
$wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
$result2 = file_put_contents($filewrapper, $wrappercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
return ($result1 && $result2);
}
/**
* Save content of a page on disk
*
* @param string $filehtmlheader Full path of filename to generate
* @param string $htmlheadercontent Content of file
* @return boolean True if OK
*/
function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
{
global $conf, $pathofwebsite;
dol_syslog("Save html header into ".$filehtmlheader);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filehtmlheader, $htmlheadercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
return false;
}
return true;
}
/**
* Save content of a page on disk
*
* @param string $filecss Full path of filename to generate
* @param string $csscontent Content of file
* @return boolean True if OK
*/
function dolSaveCssFile($filecss, $csscontent)
{
global $conf, $pathofwebsite;
dol_syslog("Save css file into ".$filecss);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filecss, $csscontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filecss, null, 'errors');
return false;
}
return true;
}
/**
* Save content of a page on disk
*
* @param string $filejs Full path of filename to generate
* @param string $jscontent Content of file
* @return boolean True if OK
*/
function dolSaveJsFile($filejs, $jscontent)
{
global $conf, $pathofwebsite;
dol_syslog("Save js file into ".$filejs);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filejs, $jscontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filejs, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filejs, null, 'errors');
return false;
}
return true;
}
/**
* Save content of a page on disk
*
* @param string $filerobot Full path of filename to generate
* @param string $robotcontent Content of file
* @return boolean True if OK
*/
function dolSaveRobotFile($filerobot, $robotcontent)
{
global $conf, $pathofwebsite;
dol_syslog("Save robot file into ".$filerobot);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filerobot, $robotcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filerobot, null, 'errors');
return false;
}
return true;
}
/**
* Save content of a page on disk
*
* @param string $filehtaccess Full path of filename to generate
* @param string $htaccess Content of file
* @return boolean True if OK
*/
function dolSaveHtaccessFile($filehtaccess, $htaccess)
{
global $conf, $pathofwebsite;
dol_syslog("Save htaccess file into ".$filehtaccess);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filehtaccess, $htaccess);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
return false;
}
return true;
}
/**
* Save content of a page on disk
*
* @param string $file Full path of filename to generate
* @param string $content Content of file
* @return boolean True if OK
*/
function dolSaveManifestJson($file, $content)
{
global $conf, $pathofwebsite;
dol_syslog("Save manifest.js.php file into ".$file);
dol_mkdir($pathofwebsite);
$result = file_put_contents($file, $content);
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
setEventMessages('Failed to write file '.$file, null, 'errors');
return false;
}
return true;
}
/**
* Show list of themes. Show all thumbs of themes
*
* @param Website $website Object website to load the tempalte into
* @return void
*/
function showWebsiteTemplates(Website $website)
{
global $conf,$langs,$db,$form;
global $bc;
$dirthemes=array('/doctemplates/websites');
if (! empty($conf->modules_parts['websitetemplates'])) // Using this feature slow down application
{
foreach($conf->modules_parts['websitetemplates'] as $reldir)
{
$dirthemes=array_merge($dirthemes, (array) ($reldir.'doctemplates/websites'));
}
}
$dirthemes=array_unique($dirthemes);
// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
$colspan=2;
$thumbsbyrow=6;
print '<table class="noborder" width="100%">';
// Title
print '<tr class="liste_titre"><th class="titlefield"></th>';
print '<th class="right">';
$url='https://www.dolistore.com/43-web-site-templates';
print '<a href="'.$url.'" target="_blank">';
print $langs->trans('DownloadMoreSkins');
print '</a>';
print '</th></tr>';
print '<tr>';
print '<td>'.$langs->trans("ThemeDir").'</td>';
print '<td>';
foreach($dirthemes as $dirtheme)
{
echo '"'.$dirtheme.'" ';
}
print '</td>';
print '</tr>';
print '<tr><td colspan="'.$colspan.'">';
print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
$i=0;
foreach($dirthemes as $dir)
{
//print $dirroot.$dir;exit;
$dirtheme=DOL_DATA_ROOT.$dir; // This include loop on $conf->file->dol_document_root
if (is_dir($dirtheme))
{
$handle=opendir($dirtheme);
if (is_resource($handle))
{
while (($subdir = readdir($handle))!==false)
{
if (is_file($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
&& substr($subdir, 0, 3) <> 'CVS' && preg_match('/\.zip$/i', $subdir))
{
$subdirwithoutzip = preg_replace('/\.zip$/i', '', $subdir);
// Disable not stable themes (dir ends with _exp or _dev)
if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue;
if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) continue;
print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
$file=$dirtheme."/".$subdirwithoutzip.".jpg";
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.".jpg";
if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
print '<br>';
print $subdir.' ('.dol_print_size(dol_filesize($dirtheme."/".$subdir), 1, 1).')';
print '<br><a href="'.$_SERVER["PHP_SELF"].'?action=importsiteconfirm&website='.$website->ref.'&templateuserfile='.$subdir.'" class="button">'.$langs->trans("Load").'</a>';
print '</div>';
$i++;
}
}
}
}
}
print '</div></td></tr></table>';
print '</td></tr>';
print '</table>';
}

View File

@ -252,7 +252,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L'); $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L');
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(32, 26); $pdf->SetXY(32, 26);
$pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L');
$pdf->SetFont('', '', $default_font_size); $pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(10, 32); $pdf->SetXY(10, 32);

View File

@ -1227,7 +1227,7 @@ class pdf_einstein extends ModelePDFCommandes
* @param int $showaddress 0=no, 1=yes * @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @param string $titlekey Translation key to show as title of document * @param string $titlekey Translation key to show as title of document
* @return void * @return int Return topshift value
*/ */
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle") protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
{ {

View File

@ -67,13 +67,13 @@ class pdf_proforma extends pdf_einstein
* @param int $showaddress 0=no, 1=yes * @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @param string $titlekey Translation key to show as title of document * @param string $titlekey Translation key to show as title of document
* @return void * @return int Return topshift value
*/ */
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma") protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma")
{ {
// phpcs:enable // phpcs:enable
global $conf,$langs,$hookmanager; global $conf,$langs,$hookmanager;
parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey); return parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey);
} }
} }

View File

@ -136,12 +136,12 @@ class pdf_soleil extends ModelePDFFicheinter
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Display logo
$this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement $this->option_modereg = 0; // Display payment mode
$this->option_condreg = 0; // Affiche conditions reglement $this->option_condreg = 0; // Display payment terms
$this->option_codeproduitservice = 0; // Affiche code produit-service $this->option_codeproduitservice = 0; // Display product-service code
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Available in several languages
$this->option_draft_watermark = 1; //Support add of a watermark on drafts $this->option_draft_watermark = 1; //Support add of a watermark on drafts
// Get source company // Get source company

View File

@ -581,8 +581,27 @@ class ImportCsv extends ModeleImports
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
$newval=$defaultref; $newval=$defaultref;
} }
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='compute')
{
$file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']);
$class=$objimport->array_import_convertvalue[0][$val]['class'];
$method=$objimport->array_import_convertvalue[0][$val]['method'];
$resultload = dol_include_once($file);
if (empty($resultload))
{
dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method);
break;
}
$classinstance=new $class($this->db);
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
if ($res<0) {
if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
else $this->errors[$error]['lib']='ErrorFieldValueNotIn';
$this->errors[$error]['type']='FOREIGNKEY';
$errorforthistable++;
$error++;
}
}
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric')
{ {
$newval = price2num($newval); $newval = price2num($newval);

View File

@ -608,8 +608,27 @@ class ImportXlsx extends ModeleImports
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
$newval=$defaultref; $newval=$defaultref;
} }
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='compute')
{
$file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']);
$class=$objimport->array_import_convertvalue[0][$val]['class'];
$method=$objimport->array_import_convertvalue[0][$val]['method'];
$resultload = dol_include_once($file);
if (empty($resultload))
{
dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method);
break;
}
$classinstance=new $class($this->db);
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
if ($res<0) {
if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
else $this->errors[$error]['lib']='ErrorFieldValueNotIn';
$this->errors[$error]['type']='FOREIGNKEY';
$errorforthistable++;
$error++;
}
}
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric')
{ {
$newval = price2num($newval); $newval = price2num($newval);

View File

@ -139,9 +139,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO $this->option_logo = 1; // Display logo FAC_PDF_LOGO
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Display product-service code
$this->franchise=!$mysoc->tva_assuj; $this->franchise=!$mysoc->tva_assuj;

View File

@ -438,7 +438,7 @@ class pdf_beluga extends ModelePDFProjects
$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
} }
$pdf->SetXY($this->posxstatut, $curY); $pdf->SetXY($this->posxstatut, $curY);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R');
if (is_array($elementarray) && count($elementarray) > 0) if (is_array($elementarray) && count($elementarray) > 0)
{ {

View File

@ -209,7 +209,10 @@ if ($captcha) {
<div id="login_line2" style="clear: both"> <div id="login_line2" style="clear: both">
<!-- Button Connection --> <!-- Button Connection -->
<br><input type="submit" class="button" value="&nbsp; <?php echo $langs->trans('Connection'); ?> &nbsp;" tabindex="5" /> <br>
<div id="login-submit-wrapper">
<input type="submit" class="button" value="&nbsp; <?php echo $langs->trans('Connection'); ?> &nbsp;" tabindex="5" />
</div>
<?php <?php
if ($forgetpasslink || $helpcenterlink) if ($forgetpasslink || $helpcenterlink)
@ -221,7 +224,7 @@ if ($forgetpasslink || $helpcenterlink)
if ($dol_use_jmobile) $moreparam.=(strpos($moreparam, '?')===false?'?':'&').'dol_use_jmobile='.$dol_use_jmobile; if ($dol_use_jmobile) $moreparam.=(strpos($moreparam, '?')===false?'?':'&').'dol_use_jmobile='.$dol_use_jmobile;
echo '<br>'; echo '<br>';
echo '<div class="center" style="margin-top: 15px;">'; echo '<div class="center" style="margin-top: 5px;">';
if ($forgetpasslink) { if ($forgetpasslink) {
$url=DOL_URL_ROOT.'/user/passwordforgotten.php'.$moreparam; $url=DOL_URL_ROOT.'/user/passwordforgotten.php'.$moreparam;
if (! empty($conf->global->MAIN_PASSWORD_FORGOTLINK)) $url=$conf->global->MAIN_PASSWORD_FORGOTLINK; if (! empty($conf->global->MAIN_PASSWORD_FORGOTLINK)) $url=$conf->global->MAIN_PASSWORD_FORGOTLINK;

View File

@ -114,7 +114,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht;
} }
dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
{ {
foreach($object->linkedObjects['propal'] as $element) foreach($object->linkedObjects['propal'] as $element)
{ {
@ -130,6 +130,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($action == 'BILL_VALIDATE') if ($action == 'BILL_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ret = 0;
// First classify billed the order to allow the proposal classify process // First classify billed the order to allow the proposal classify process
if (! empty($conf->commande->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) if (! empty($conf->commande->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER))
@ -143,7 +144,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht;
} }
dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
{ {
foreach($object->linkedObjects['commande'] as $element) foreach($object->linkedObjects['commande'] as $element)
{ {
@ -151,7 +152,6 @@ class InterfaceWorkflowManager extends DolibarrTriggers
} }
} }
} }
return $ret;
} }
// Second classify billed the proposal. // Second classify billed the proposal.
@ -166,7 +166,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht;
} }
dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
{ {
foreach($object->linkedObjects['propal'] as $element) foreach($object->linkedObjects['propal'] as $element)
{ {
@ -174,8 +174,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers
} }
} }
} }
return $ret;
} }
return $ret;
} }
// classify billed order & billed propososal // classify billed order & billed propososal
@ -195,7 +196,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($element->statut == CommandeFournisseur::STATUS_ACCEPTED || $element->statut == CommandeFournisseur::STATUS_ORDERSENT || $element->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY || $element->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) $totalonlinkedelements += $element->total_ht; if ($element->statut == CommandeFournisseur::STATUS_ACCEPTED || $element->statut == CommandeFournisseur::STATUS_ORDERSENT || $element->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY || $element->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) $totalonlinkedelements += $element->total_ht;
} }
dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
{ {
foreach($object->linkedObjects['order_supplier'] as $element) foreach($object->linkedObjects['order_supplier'] as $element)
{ {
@ -218,7 +219,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht;
} }
dol_syslog("Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); dol_syslog("Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
{ {
foreach($object->linkedObjects['supplier_proposal'] as $element) foreach($object->linkedObjects['supplier_proposal'] as $element)
{ {
@ -246,7 +247,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht;
} }
dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
{ {
foreach($object->linkedObjects['commande'] as $element) foreach($object->linkedObjects['commande'] as $element)
{ {
@ -345,4 +346,24 @@ class InterfaceWorkflowManager extends DolibarrTriggers
return 0; return 0;
} }
/**
* @param Object $conf Dolibarr settings object
* @param float $totalonlinkedelements Sum of total amounts (excl VAT) of
* invoices linked to $object
* @param float $object_total_ht The total amount (excl VAT) of the object
* (an order, a proposal, a bill, etc.)
* @return bool True if the amounts are equal (rounded on total amount)
* True if the module is configured to skip the amount equality check
* False otherwise.
*/
private function shouldClassify($conf, $totalonlinkedelements, $object_total_ht)
{
// if the configuration allows unmatching amounts, allow classification anyway
if (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) {
return true;
}
// if the amount are same, allow classification, else deny
return (price2num($totalonlinkedelements, 'MT') == price2num($object_total_ht, 'MT'));
}
} }

View File

@ -649,12 +649,20 @@ class InterfaceActionsAuto extends DolibarrTriggers
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("agenda","other","members")); $langs->loadLangs(array("agenda","other","members"));
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs)); $member = $this->context['member'];
$object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs)); if (! is_object($member)) // This should not happen
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); {
$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; $member = new Adherent($this->db);
$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); $member->fetch($this->fk_adherent);
}
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs));
$object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs));
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs);
$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type;
$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount;
$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
$object->sendtoid=0; $object->sendtoid=0;
if ($object->fk_soc > 0) $object->socid=$object->fk_soc; if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
@ -664,12 +672,20 @@ class InterfaceActionsAuto extends DolibarrTriggers
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("agenda","other","members")); $langs->loadLangs(array("agenda","other","members"));
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs)); $member = $this->context['member'];
$object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs)); if (! is_object($member)) // This should not happen
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); {
$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; $member = new Adherent($this->db);
$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); $member->fetch($this->fk_adherent);
}
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs));
$object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs));
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs);
$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type;
$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount;
$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
$object->sendtoid=0; $object->sendtoid=0;
if ($object->fk_soc > 0) $object->socid=$object->fk_soc; if ($object->fk_soc > 0) $object->socid=$object->fk_soc;

View File

@ -94,5 +94,11 @@ if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') // If we browsing
} }
} }
// Load websitepage class // Show off line message
include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; if (! defined('USEDOLIBARREDITOR') && empty($website->status))
{
$weblangs->load("website");
http_response_code(503);
print '<center><br><br>'.$weblangs->trans("SorryWebsiteIsCurrentlyOffLine").'</center>';
exit;
}

View File

@ -143,7 +143,7 @@ class TraceableDB extends DoliDB
*/ */
public static function convertSQLFromMysql($line, $type = 'ddl') public static function convertSQLFromMysql($line, $type = 'ddl')
{ {
return $this->db->convertSQLFromMysql($line); return self::$db->convertSQLFromMysql($line);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

View File

@ -353,7 +353,7 @@ class Expedition extends CommonObject
{ {
if (! isset($this->lines[$i]->detail_batch)) if (! isset($this->lines[$i]->detail_batch))
{ // no batch management { // no batch management
if (! $this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->array_options) > 0) if (! $this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) > 0)
{ {
$error++; $error++;
} }
@ -441,10 +441,11 @@ class Expedition extends CommonObject
* @param int $entrepot_id Id of warehouse * @param int $entrepot_id Id of warehouse
* @param int $origin_line_id Id of source line * @param int $origin_line_id Id of source line
* @param int $qty Quantity * @param int $qty Quantity
* @param int $rang Rang
* @param array $array_options extrafields array * @param array $array_options extrafields array
* @return int <0 if KO, line_id if OK * @return int <0 if KO, line_id if OK
*/ */
public function create_line($entrepot_id, $origin_line_id, $qty, $array_options = 0) public function create_line($entrepot_id, $origin_line_id, $qty, $rang, $array_options = 0)
{ {
//phpcs:enable //phpcs:enable
global $user; global $user;
@ -454,6 +455,7 @@ class Expedition extends CommonObject
$expeditionline->entrepot_id = $entrepot_id; $expeditionline->entrepot_id = $entrepot_id;
$expeditionline->fk_origin_line = $origin_line_id; $expeditionline->fk_origin_line = $origin_line_id;
$expeditionline->qty = $qty; $expeditionline->qty = $qty;
$expeditionline->rang = $rang;
$expeditionline->array_options = $array_options; $expeditionline->array_options = $array_options;
if (($lineId = $expeditionline->insert($user)) < 0) if (($lineId = $expeditionline->insert($user)) < 0)
@ -490,7 +492,7 @@ class Expedition extends CommonObject
// create shipment lines // create shipment lines
foreach ($stockLocationQty as $stockLocation => $qty) foreach ($stockLocationQty as $stockLocation => $qty)
{ {
if (($line_id = $this->create_line($stockLocation, $line_ext->origin_line_id, $qty, $array_options)) < 0) if (($line_id = $this->create_line($stockLocation, $line_ext->origin_line_id, $qty, $line_ext->rang, $array_options)) < 0)
{ {
$error++; $error++;
} }
@ -926,6 +928,9 @@ class Expedition extends CommonObject
$orderline = new OrderLine($this->db); $orderline = new OrderLine($this->db);
$orderline->fetch($id); $orderline->fetch($id);
// Copy the rang of the order line to the expedition line
$line->rang = $orderline->rang;
if (! empty($conf->stock->enabled) && ! empty($orderline->fk_product)) if (! empty($conf->stock->enabled) && ! empty($orderline->fk_product))
{ {
$fk_product = $orderline->fk_product; $fk_product = $orderline->fk_product;
@ -1383,7 +1388,7 @@ class Expedition extends CommonObject
$sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type"; $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type";
$sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; $sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva";
$sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht";
$sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc"; $sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc, cd.rang";
$sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
$sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type";
$sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch";
@ -1452,6 +1457,7 @@ class Expedition extends CommonObject
$line->label = $obj->custom_label; $line->label = $obj->custom_label;
$line->description = $obj->description; $line->description = $obj->description;
$line->qty_asked = $obj->qty_asked; $line->qty_asked = $obj->qty_asked;
$line->rang = $obj->rang;
$line->weight = $obj->weight; $line->weight = $obj->weight;
$line->weight_units = $obj->weight_units; $line->weight_units = $obj->weight_units;
$line->length = $obj->length; $line->length = $obj->length;
@ -2459,6 +2465,11 @@ class ExpeditionLigne extends CommonObjectLine
*/ */
public $product_desc; public $product_desc;
/**
* @var int rang of line
*/
public $rang;
/** /**
* @var float weight * @var float weight
*/ */
@ -2579,16 +2590,28 @@ class ExpeditionLigne extends CommonObjectLine
$this->db->begin(); $this->db->begin();
if (empty($this->rang)) $this->rang = 0;
// Rank to use
$ranktouse = $this->rang;
if ($ranktouse == -1)
{
$rangmax = $this->line_max($fk_expedition);
$ranktouse = $rangmax + 1;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (";
$sql.= "fk_expedition"; $sql.= "fk_expedition";
$sql.= ", fk_entrepot"; $sql.= ", fk_entrepot";
$sql.= ", fk_origin_line"; $sql.= ", fk_origin_line";
$sql.= ", qty"; $sql.= ", qty";
$sql.= ", rang";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= $this->fk_expedition; $sql.= $this->fk_expedition;
$sql.= ", ".(empty($this->entrepot_id) ? 'NULL' : $this->entrepot_id); $sql.= ", ".(empty($this->entrepot_id) ? 'NULL' : $this->entrepot_id);
$sql.= ", ".$this->fk_origin_line; $sql.= ", ".$this->fk_origin_line;
$sql.= ", ".$this->qty; $sql.= ", ".$this->qty;
$sql.= ", ".$ranktouse;
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::insert", LOG_DEBUG); dol_syslog(get_class($this)."::insert", LOG_DEBUG);

View File

@ -996,6 +996,62 @@ if (empty($reshook))
} }
} }
if ($action == 'set_unpaid' && $id > 0 && $user->rights->expensereport->to_paid)
{
$object = new ExpenseReport($db);
$object->fetch($id);
$result = $object->set_unpaid($user);
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
if ($action == 'set_unpaid' && $id > 0 && $user->rights->expensereport->to_paid)
{
$object = new ExpenseReport($db);
$object->fetch($id);
$result = $object->set_unpaid($user);
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid)
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
@ -1679,7 +1735,7 @@ else
if ($action == 'cancel') if ($action == 'cancel')
{ {
$array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text",'label'=>'<strong>'.$langs->trans("Comment").'</strong>','name'=>"detail_cancel",'size'=>"50",'value'=>"")); $array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text",'label'=>'<strong>'.$langs->trans("Comment").'</strong>','name'=>"detail_cancel",'value'=>""));
$formconfirm=$form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1); $formconfirm=$form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1);
} }
@ -1690,7 +1746,7 @@ else
if ($action == 'refuse') // Deny if ($action == 'refuse') // Deny
{ {
$array_input = array('text'=>$langs->trans("ConfirmRefuseTrip"), array('type'=>"text",'label'=>$langs->trans("Comment"),'name'=>"detail_refuse",'size'=>"50",'value'=>"")); $array_input = array('text'=>$langs->trans("ConfirmRefuseTrip"), array('type'=>"text",'label'=>$langs->trans("Comment"),'name'=>"detail_refuse",'value'=>""));
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Deny"), '', "confirm_refuse", $array_input, "yes", 1); $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Deny"), '', "confirm_refuse", $array_input, "yes", 1);
} }
@ -1958,7 +2014,7 @@ else
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $total = 0; $i = 0; $totalpaid = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
@ -2662,8 +2718,8 @@ if ($action != 'create' && $action != 'edit')
} }
// If status is Appoved // If status is Approved
// -------------------- // ---------------------
if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_APPROVED) if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
{ {
@ -2707,9 +2763,15 @@ if ($action != 'create' && $action != 'edit')
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$object->id.'">'.$langs->trans('Cancel').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$object->id.'">'.$langs->trans('Cancel').'</a></div>';
} }
if ($user->rights->expensereport->to_paid && $object->paid && $object->fk_statut == ExpenseReport::STATUS_CLOSED)
{
// Set unpaid
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=set_unpaid&id='.$object->id.'">'.$langs->trans('ClassifyUnPaid').'</a></div>';
}
// Clone // Clone
if ($user->rights->expensereport->creer) { if ($user->rights->expensereport->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;action=clone">' . $langs->trans("ToClone") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=clone">' . $langs->trans("ToClone") . '</a></div>';
} }
/* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */

View File

@ -1397,12 +1397,12 @@ class ExpenseReport extends CommonObject
// phpcs:enable // phpcs:enable
$error = 0; $error = 0;
if ($this->fk_c_deplacement_statuts != 5) if ($this->paid)
{ {
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_statut = 5"; $sql.= " SET paid = 0";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG);

View File

@ -286,7 +286,6 @@ else
dol_print_error($db); dol_print_error($db);
} }
print '</div>';
/* /*

View File

@ -701,7 +701,7 @@ class PaiementFourn extends Paiement
else else
{ {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Supplier"));
return ""; return "";
} }
} }

View File

@ -98,7 +98,7 @@ class EvalMath
'sin','sinh','arcsin','asin','arcsinh','asinh', 'sin','sinh','arcsin','asin','arcsinh','asinh',
'cos','cosh','arccos','acos','arccosh','acosh', 'cos','cosh','arccos','acos','arccosh','acosh',
'tan','tanh','arctan','atan','arctanh','atanh', 'tan','tanh','arctan','atan','arctanh','atanh',
'sqrt','abs','ln','log'); 'sqrt','abs','ln','log','intval');
/** /**
* Constructor * Constructor

View File

@ -1,5 +1,45 @@
# Changelog # Changelog
## 6.41.0 - 2019-07-31
* [#683](https://github.com/stripe/stripe-php/pull/683) Move the List Balance History API to `/v1/balance_transactions`
## 6.40.0 - 2019-06-27
* [#675](https://github.com/stripe/stripe-php/pull/675) Add support for `SetupIntent` resource and APIs
## 6.39.2 - 2019-06-26
* [#676](https://github.com/stripe/stripe-php/pull/676) Fix exception message in `CustomerBalanceTransaction::update()`
## 6.39.1 - 2019-06-25
* [#674](https://github.com/stripe/stripe-php/pull/674) Add new constants for `collection_method` on `Invoice`
## 6.39.0 - 2019-06-24
* [#673](https://github.com/stripe/stripe-php/pull/673) Enable request latency telemetry by default
## 6.38.0 - 2019-06-17
* [#649](https://github.com/stripe/stripe-php/pull/649) Add support for `CustomerBalanceTransaction` resource and APIs
## 6.37.2 - 2019-06-17
* [#671](https://github.com/stripe/stripe-php/pull/671) Add new PHPDoc
* [#672](https://github.com/stripe/stripe-php/pull/672) Add constants for `submit_type` on Checkout `Session`
## 6.37.1 - 2019-06-14
* [#670](https://github.com/stripe/stripe-php/pull/670) Add new PHPDoc
## 6.37.0 - 2019-05-23
* [#663](https://github.com/stripe/stripe-php/pull/663) Add support for `radar.early_fraud_warning` resource
## 6.36.0 - 2019-05-22
* [#661](https://github.com/stripe/stripe-php/pull/661) Add constants for new TaxId types
* [#662](https://github.com/stripe/stripe-php/pull/662) Add constants for BalanceTransaction types
## 6.35.2 - 2019-05-20
* [#655](https://github.com/stripe/stripe-php/pull/655) Add constants for payment intent statuses
* [#659](https://github.com/stripe/stripe-php/pull/659) Fix PHPDoc for various nested Account actions
* [#660](https://github.com/stripe/stripe-php/pull/660) Fix various PHPDoc
## 6.35.1 - 2019-05-20
* [#658](https://github.com/stripe/stripe-php/pull/658) Use absolute value when checking timestamp tolerance
## 6.35.0 - 2019-05-14 ## 6.35.0 - 2019-05-14
* [#651](https://github.com/stripe/stripe-php/pull/651) Add support for the Capability resource and APIs * [#651](https://github.com/stripe/stripe-php/pull/651) Add support for the Capability resource and APIs

View File

@ -6,7 +6,11 @@
[![License](https://poser.pugx.org/stripe/stripe-php/license.svg)](https://packagist.org/packages/stripe/stripe-php) [![License](https://poser.pugx.org/stripe/stripe-php/license.svg)](https://packagist.org/packages/stripe/stripe-php)
[![Code Coverage](https://coveralls.io/repos/stripe/stripe-php/badge.svg?branch=master)](https://coveralls.io/r/stripe/stripe-php?branch=master) [![Code Coverage](https://coveralls.io/repos/stripe/stripe-php/badge.svg?branch=master)](https://coveralls.io/r/stripe/stripe-php?branch=master)
You can sign up for a Stripe account at https://stripe.com. The Stripe PHP library provides convenient access to the Stripe API from
applications written in the PHP language. It includes a pre-defined set of
classes for API resources that initialize themselves dynamically from API
responses which makes it compatible with a wide range of versions of the Stripe
API.
## Requirements ## Requirements
@ -56,7 +60,7 @@ echo $charge;
## Documentation ## Documentation
Please see https://stripe.com/docs/api for up-to-date documentation. See the [PHP API docs](https://stripe.com/docs/api/php#intro).
## Legacy Version Support ## Legacy Version Support
@ -179,6 +183,17 @@ an intermittent network problem:
[Idempotency keys][idempotency-keys] are added to requests to guarantee that [Idempotency keys][idempotency-keys] are added to requests to guarantee that
retries are safe. retries are safe.
### Request latency telemetry
By default, the library sends request latency telemetry to Stripe. These
numbers help Stripe improve the overall latency of its API for all users.
You can disable this behavior if you prefer:
```php
\Stripe\Stripe::setEnableTelemetry(false);
```
## Development ## Development
Get [Composer][composer]. For example, on Mac OS: Get [Composer][composer]. For example, on Mac OS:

View File

@ -1 +1 @@
6.35.0 6.41.0

View File

@ -76,6 +76,7 @@ require(dirname(__FILE__) . '/lib/CountrySpec.php');
require(dirname(__FILE__) . '/lib/Coupon.php'); require(dirname(__FILE__) . '/lib/Coupon.php');
require(dirname(__FILE__) . '/lib/CreditNote.php'); require(dirname(__FILE__) . '/lib/CreditNote.php');
require(dirname(__FILE__) . '/lib/Customer.php'); require(dirname(__FILE__) . '/lib/Customer.php');
require(dirname(__FILE__) . '/lib/CustomerBalanceTransaction.php');
require(dirname(__FILE__) . '/lib/Discount.php'); require(dirname(__FILE__) . '/lib/Discount.php');
require(dirname(__FILE__) . '/lib/Dispute.php'); require(dirname(__FILE__) . '/lib/Dispute.php');
require(dirname(__FILE__) . '/lib/EphemeralKey.php'); require(dirname(__FILE__) . '/lib/EphemeralKey.php');
@ -104,6 +105,7 @@ require(dirname(__FILE__) . '/lib/Payout.php');
require(dirname(__FILE__) . '/lib/Person.php'); require(dirname(__FILE__) . '/lib/Person.php');
require(dirname(__FILE__) . '/lib/Plan.php'); require(dirname(__FILE__) . '/lib/Plan.php');
require(dirname(__FILE__) . '/lib/Product.php'); require(dirname(__FILE__) . '/lib/Product.php');
require(dirname(__FILE__) . '/lib/Radar/EarlyFraudWarning.php');
require(dirname(__FILE__) . '/lib/Radar/ValueList.php'); require(dirname(__FILE__) . '/lib/Radar/ValueList.php');
require(dirname(__FILE__) . '/lib/Radar/ValueListItem.php'); require(dirname(__FILE__) . '/lib/Radar/ValueListItem.php');
require(dirname(__FILE__) . '/lib/Recipient.php'); require(dirname(__FILE__) . '/lib/Recipient.php');
@ -112,6 +114,7 @@ require(dirname(__FILE__) . '/lib/Refund.php');
require(dirname(__FILE__) . '/lib/Reporting/ReportRun.php'); require(dirname(__FILE__) . '/lib/Reporting/ReportRun.php');
require(dirname(__FILE__) . '/lib/Reporting/ReportType.php'); require(dirname(__FILE__) . '/lib/Reporting/ReportType.php');
require(dirname(__FILE__) . '/lib/Review.php'); require(dirname(__FILE__) . '/lib/Review.php');
require(dirname(__FILE__) . '/lib/SetupIntent.php');
require(dirname(__FILE__) . '/lib/SKU.php'); require(dirname(__FILE__) . '/lib/SKU.php');
require(dirname(__FILE__) . '/lib/Sigma/ScheduledQueryRun.php'); require(dirname(__FILE__) . '/lib/Sigma/ScheduledQueryRun.php');
require(dirname(__FILE__) . '/lib/Source.php'); require(dirname(__FILE__) . '/lib/Source.php');

View File

@ -152,8 +152,8 @@ class Account extends ApiResource
/** /**
* @param string|null $id The ID of the account to which the capability belongs. * @param string $id The ID of the account to which the capability belongs.
* @param string|null $capabilityId The ID of the capability to retrieve. * @param string $capabilityId The ID of the capability to retrieve.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -165,8 +165,8 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account to which the capability belongs. * @param string $id The ID of the account to which the capability belongs.
* @param string|null $capabilityId The ID of the capability to update. * @param string $capabilityId The ID of the capability to update.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -178,7 +178,7 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account on which to retrieve the capabilities. * @param string $id The ID of the account on which to retrieve the capabilities.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -190,7 +190,7 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account on which to create the external account. * @param string $id The ID of the account on which to create the external account.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -202,8 +202,8 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account to which the external account belongs. * @param string $id The ID of the account to which the external account belongs.
* @param array|null $externalAccountId The ID of the external account to retrieve. * @param string $externalAccountId The ID of the external account to retrieve.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -215,8 +215,8 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account to which the external account belongs. * @param string $id The ID of the account to which the external account belongs.
* @param array|null $externalAccountId The ID of the external account to update. * @param string $externalAccountId The ID of the external account to update.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -228,8 +228,8 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account to which the external account belongs. * @param string $id The ID of the account to which the external account belongs.
* @param array|null $externalAccountId The ID of the external account to delete. * @param string $externalAccountId The ID of the external account to delete.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -241,7 +241,7 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account on which to retrieve the external accounts. * @param string $id The ID of the account on which to retrieve the external accounts.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -253,7 +253,7 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account on which to create the login link. * @param string $id The ID of the account on which to create the login link.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -280,7 +280,7 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account on which to create the person. * @param string $id The ID of the account on which to create the person.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -292,8 +292,8 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account to which the person belongs. * @param string $id The ID of the account to which the person belongs.
* @param string|null $personId The ID of the person to retrieve. * @param string $personId The ID of the person to retrieve.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -305,8 +305,8 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account to which the person belongs. * @param string $id The ID of the account to which the person belongs.
* @param string|null $personId The ID of the person to update. * @param string $personId The ID of the person to update.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -318,8 +318,8 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account to which the person belongs. * @param string $id The ID of the account to which the person belongs.
* @param string|null $personId The ID of the person to delete. * @param string $personId The ID of the person to delete.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *
@ -331,7 +331,7 @@ class Account extends ApiResource
} }
/** /**
* @param string|null $id The ID of the account on which to retrieve the persons. * @param string $id The ID of the account on which to retrieve the persons.
* @param array|null $params * @param array|null $params
* @param array|string|null $opts * @param array|string|null $opts
* *

View File

@ -31,11 +31,36 @@ class BalanceTransaction extends ApiResource
use ApiOperations\Retrieve; use ApiOperations\Retrieve;
/** /**
* @return string The class URL for this resource. It needs to be special * Possible string representations of the type of balance transaction.
* cased because it doesn't fit into the standard resource pattern. * @link https://stripe.com/docs/api/balance/balance_transaction#balance_transaction_object-type
*/ */
public static function classUrl() const TYPE_ADJUSTMENT = 'adjustment';
{ const TYPE_ADVANCE = 'advance';
return "/v1/balance/history"; const TYPE_ADVANCE_FUNDING = 'advance_funding';
} const TYPE_APPLICATION_FEE = 'application_fee';
const TYPE_APPLICATION_FEE_REFUND = 'application_fee_refund';
const TYPE_CHARGE = 'charge';
const TYPE_CONNECT_COLLECTION_TRANSFER = 'connect_collection_transfer';
const TYPE_ISSUING_AUTHORIZATION_HOLD = 'issuing_authorization_hold';
const TYPE_ISSUING_AUTHORIZATION_RELEASE = 'issuing_authorization_release';
const TYPE_ISSUING_TRANSACTION = 'issuing_transaction';
const TYPE_PAYMENT = 'payment';
const TYPE_PAYMENT_FAILURE_REFUND = 'payment_failure_refund';
const TYPE_PAYMENT_REFUND = 'payment_refund';
const TYPE_PAYOUT = 'payout';
const TYPE_PAYOUT_CANCEL = 'payout_cancel';
const TYPE_PAYOUT_FAILURE = 'payout_failure';
const TYPE_REFUND = 'refund';
const TYPE_REFUND_FAILURE = 'refund_failure';
const TYPE_RESERVE_TRANSACTION = 'reserve_transaction';
const TYPE_RESERVED_FUNDS = 'reserved_funds';
const TYPE_STRIPE_FEE = 'stripe_fee';
const TYPE_STRIPE_FX_FEE = 'stripe_fx_fee';
const TYPE_TAX_FEE = 'tax_fee';
const TYPE_TOPUP = 'topup';
const TYPE_TOPUP_REVERSAL = 'topup_reversal';
const TYPE_TRANSFER = 'transfer';
const TYPE_TRANSFER_CANCEL = 'transfer_cancel';
const TYPE_TRANSFER_FAILURE = 'transfer_failure';
const TYPE_TRANSFER_REFUND = 'transfer_refund';
} }

View File

@ -31,6 +31,16 @@ class BankAccount extends ApiResource
use ApiOperations\Delete; use ApiOperations\Delete;
use ApiOperations\Update; use ApiOperations\Update;
/**
* Possible string representations of the bank verification status.
* @link https://stripe.com/docs/api/external_account_bank_accounts/object#account_bank_account_object-status
*/
const STATUS_NEW = 'new';
const STATUS_VALIDATED = 'validated';
const STATUS_VERIFIED = 'verified';
const STATUS_VERIFICATION_FAILED = 'verification_failed';
const STATUS_ERRORED = 'errored';
/** /**
* @return string The instance URL for this resource. It needs to be special * @return string The instance URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern. * cased because it doesn't fit into the standard resource pattern.

View File

@ -11,7 +11,9 @@ namespace Stripe;
* @property int $amount_refunded * @property int $amount_refunded
* @property string $application * @property string $application
* @property string $application_fee * @property string $application_fee
* @property int $application_fee_amount
* @property string $balance_transaction * @property string $balance_transaction
* @property mixed $billing_details
* @property bool $captured * @property bool $captured
* @property int $created * @property int $created
* @property string $currency * @property string $currency
@ -30,6 +32,8 @@ namespace Stripe;
* @property mixed $outcome * @property mixed $outcome
* @property bool $paid * @property bool $paid
* @property string $payment_intent * @property string $payment_intent
* @property string $payment_method
* @property mixed $payment_method_details
* @property string $receipt_email * @property string $receipt_email
* @property string $receipt_number * @property string $receipt_number
* @property string $receipt_url * @property string $receipt_url
@ -86,6 +90,7 @@ class Charge extends ApiResource
const DECLINED_INVALID_PIN = 'invalid_pin'; const DECLINED_INVALID_PIN = 'invalid_pin';
const DECLINED_ISSUER_NOT_AVAILABLE = 'issuer_not_available'; const DECLINED_ISSUER_NOT_AVAILABLE = 'issuer_not_available';
const DECLINED_LOST_CARD = 'lost_card'; const DECLINED_LOST_CARD = 'lost_card';
const DECLINED_MERCHANT_BLACKLIST = 'merchant_blacklist';
const DECLINED_NEW_ACCOUNT_INFORMATION_AVAILABLE = 'new_account_information_available'; const DECLINED_NEW_ACCOUNT_INFORMATION_AVAILABLE = 'new_account_information_available';
const DECLINED_NO_ACTION_TAKEN = 'no_action_taken'; const DECLINED_NO_ACTION_TAKEN = 'no_action_taken';
const DECLINED_NOT_PERMITTED = 'not_permitted'; const DECLINED_NOT_PERMITTED = 'not_permitted';

View File

@ -15,6 +15,7 @@ namespace Stripe\Checkout;
* @property bool $livemode * @property bool $livemode
* @property string $payment_intent * @property string $payment_intent
* @property string[] $payment_method_types * @property string[] $payment_method_types
* @property string $submit_type
* @property string $subscription * @property string $subscription
* @property string $success_url * @property string $success_url
* *
@ -27,4 +28,13 @@ class Session extends \Stripe\ApiResource
use \Stripe\ApiOperations\Create; use \Stripe\ApiOperations\Create;
use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Retrieve;
/**
* Possible string representations of submit type.
* @link https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-submit_type
*/
const SUBMIT_TYPE_AUTO = 'auto';
const SUBMIT_TYPE_BOOK = 'book';
const SUBMIT_TYPE_DONATE = 'donate';
const SUBMIT_TYPE_PAY = 'pay';
} }

View File

@ -8,6 +8,7 @@ namespace Stripe;
* @property string $id * @property string $id
* @property string $object * @property string $object
* @property int $amount * @property int $amount
* @property string $customer_balance_transaction
* @property int $created * @property int $created
* @property string $currency * @property string $currency
* @property string $customer * @property string $customer

View File

@ -7,8 +7,8 @@ namespace Stripe;
* *
* @property string $id * @property string $id
* @property string $object * @property string $object
* @property int $account_balance
* @property mixed $address * @property mixed $address
* @property int $balance
* @property string $created * @property string $created
* @property string $currency * @property string $currency
* @property string $default_source * @property string $default_source
@ -26,6 +26,7 @@ namespace Stripe;
* @property mixed $shipping * @property mixed $shipping
* @property Collection $sources * @property Collection $sources
* @property Collection $subscriptions * @property Collection $subscriptions
* @property string $tax_exempt
* @property Collection $tax_ids * @property Collection $tax_ids
* *
* @package Stripe * @package Stripe
@ -61,6 +62,7 @@ class Customer extends ApiResource
return $savedNestedResources; return $savedNestedResources;
} }
const PATH_BALANCE_TRANSACTIONS = '/balance_transactions';
const PATH_SOURCES = '/sources'; const PATH_SOURCES = '/sources';
const PATH_TAX_IDS = '/tax_ids'; const PATH_TAX_IDS = '/tax_ids';
@ -264,4 +266,55 @@ class Customer extends ApiResource
{ {
return self::_allNestedResources($id, static::PATH_TAX_IDS, $params, $opts); return self::_allNestedResources($id, static::PATH_TAX_IDS, $params, $opts);
} }
/**
* @param string|null $id The ID of the customer on which to create the balance transaction.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function createBalanceTransaction($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts);
}
/**
* @param string|null $id The ID of the customer to which the balance transaction belongs.
* @param string|null $balanceTransactionId The ID of the balance transaction to retrieve.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function retrieveBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts);
}
/**
* @param string|null $id The ID of the customer on which to update the balance transaction.
* @param string|null $balanceTransactionId The ID of the balance transaction to update.
* @param array|null $params
* @param array|string|null $opts
*
*
* @return ApiResource
*/
public static function updateBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts);
}
/**
* @param string|null $id The ID of the customer on which to retrieve the customer balance transactions.
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection The list of customer balance transactions.
*/
public static function allBalanceTransactions($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts);
}
} }

View File

@ -0,0 +1,88 @@
<?php
namespace Stripe;
/**
* Class CustomerBalanceTransaction
*
* @package Stripe
*
* @property string $id
* @property string $object
* @property int $amount
* @property string $credit_note
* @property int $created
* @property string $currency
* @property string $customer
* @property string $description
* @property int $ending_balance
* @property string $invoice
* @property bool $livemode
* @property StripeObject $metadata
* @property string $type
*/
class CustomerBalanceTransaction extends ApiResource
{
const OBJECT_NAME = "customer_balance_transaction";
/**
* Possible string representations of a balance transaction's type.
* @link https://stripe.com/docs/api/customers/customer_balance_transaction_object#customer_balance_transaction_object-type
*/
const TYPE_ADJUSTEMENT = 'adjustment';
const TYPE_APPLIED_TO_INVOICE = 'applied_to_invoice';
const TYPE_CREDIT_NOTE = 'credit_note';
const TYPE_INITIAL = 'initial';
const TYPE_INVOICE_TOO_LARGE = 'invoice_too_large';
const TYPE_INVOICE_TOO_SMALL = 'invoice_too_small';
const TYPE_UNSPENT_RECEIVER_CREDIT = 'unspent_receiver_credit';
/**
* @return string The API URL for this balance transaction.
*/
public function instanceUrl()
{
$id = $this['id'];
$customer = $this['customer'];
if (!$id) {
throw new Error\InvalidRequest(
"Could not determine which URL to request: class instance has invalid ID: $id",
null
);
}
$id = Util\Util::utf8($id);
$customer = Util\Util::utf8($customer);
$base = Customer::classUrl();
$customerExtn = urlencode($customer);
$extn = urlencode($id);
return "$base/$customerExtn/balance_transactions/$extn";
}
/**
* @param array|string $_id
* @param array|string|null $_opts
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function retrieve($_id, $_opts = null)
{
$msg = "Customer Balance Transactions cannot be accessed without a customer ID. " .
"Retrieve a balance transaction using Customer::retrieveBalanceTransaction('cus_123', 'cbtxn_123') instead.";
throw new Error\InvalidRequest($msg, null);
}
/**
* @param string $_id
* @param array|null $_params
* @param array|string|null $_options
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = "Customer Balance Transactions cannot be accessed without a customer ID. " .
"Update a balance transaction using Customer::updateBalanceTransaction('cus_123', 'cbtxn_123', \$params) instead.";
throw new Error\InvalidRequest($msg, null);
}
}

View File

@ -19,6 +19,7 @@ namespace Stripe;
* @property string $billing * @property string $billing
* @property string $billing_reason * @property string $billing_reason
* @property string $charge * @property string $charge
* @property string $collection_method
* @property int $created * @property int $created
* @property string $currency * @property string $currency
* @property array $custom_fields * @property array $custom_fields
@ -28,6 +29,7 @@ namespace Stripe;
* @property string $customer_name * @property string $customer_name
* @property string $customer_phone * @property string $customer_phone
* @property mixed $customer_shipping * @property mixed $customer_shipping
* @property string $customer_tax_exempt
* @property array $customer_tax_ids * @property array $customer_tax_ids
* @property string $default_payment_method * @property string $default_payment_method
* @property string $default_source * @property string $default_source
@ -77,6 +79,25 @@ class Invoice extends ApiResource
use ApiOperations\Retrieve; use ApiOperations\Retrieve;
use ApiOperations\Update; use ApiOperations\Update;
/**
* Possible string representations of the billing reason.
* @link https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason
*/
const BILLING_REASON_MANUAL = 'manual';
const BILLING_REASON_SUBSCRIPTION = 'subscription';
const BILLING_REASON_SUBSCRIPTION_CREATE = 'subscription_create';
const BILLING_REASON_SUBSCRIPTION_CYCLE = 'subscription_cycle';
const BILLING_REASON_SUBSCRIPTION_THRESHOLD = 'subscription_threshold';
const BILLING_REASON_SUBSCRIPTION_UPDATE = 'subscription_update';
const BILLING_REASON_UPCOMING = 'upcoming';
/**
* Possible string representations of the `collection_method` property.
* @link https://stripe.com/docs/api/invoices/object#invoice_object-collection_method
*/
const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically';
const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice';
/** /**
* Possible string representations of the invoice status. * Possible string representations of the invoice status.
* @link https://stripe.com/docs/api/invoices/object#invoice_object-status * @link https://stripe.com/docs/api/invoices/object#invoice_object-status
@ -88,23 +109,12 @@ class Invoice extends ApiResource
const STATUS_VOID = 'void'; const STATUS_VOID = 'void';
/** /**
* Possible string representations of the billing. * Possible string representations of the `billing` property.
* @deprecated Use `collection_method` instead.
* @link https://stripe.com/docs/api/invoices/object#invoice_object-billing * @link https://stripe.com/docs/api/invoices/object#invoice_object-billing
*/ */
const BILLING_SEND_INVOICE = 'send_invoice';
const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically'; const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically';
const BILLING_SEND_INVOICE = 'send_invoice';
/**
* Possible string representations of the billing reason.
* @link https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason
*/
const BILLING_REASON_SUBSCRIPTION = 'subscription';
const BILLING_REASON_SUBSCRIPTION_CREATE = 'subscription_create';
const BILLING_REASON_SUBSCRIPTION_CYCLE = 'subscription_cycle';
const BILLING_REASON_SUBSCRIPTION_UPDATE = 'subscription_update';
const BILLING_REASON_SUBSCRIPTION_THRESHOLD = 'subscription_threshold';
const BILLING_REASON_MANUAL = 'manual';
const BILLING_REASON_UPCOMING = 'upcoming';
/** /**
* @param array|null $params * @param array|null $params

View File

@ -17,6 +17,8 @@ namespace Stripe\Issuing;
* @property string $dispute * @property string $dispute
* @property bool $livemode * @property bool $livemode
* @property mixed $merchant_data * @property mixed $merchant_data
* @property int $merchant_amount
* @property string $merchant_currency
* @property \Stripe\StripeObject $metadata * @property \Stripe\StripeObject $metadata
* @property string $type * @property string $type
* *

View File

@ -23,7 +23,7 @@ namespace Stripe;
* @property Collection $returns * @property Collection $returns
* @property string $selected_shipping_method * @property string $selected_shipping_method
* @property mixed $shipping * @property mixed $shipping
* @property mixed $shipping_methods * @property array $shipping_methods
* @property string $status * @property string $status
* @property mixed $status_transitions * @property mixed $status_transitions
* @property int $updated * @property int $updated

View File

@ -50,6 +50,19 @@ class PaymentIntent extends ApiResource
use ApiOperations\Retrieve; use ApiOperations\Retrieve;
use ApiOperations\Update; use ApiOperations\Update;
/**
* These constants are possible representations of the status field.
*
* @link https://stripe.com/docs/api/payment_intents/object#payment_intent_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_PROCESSING = 'processing';
const STATUS_REQUIRES_ACTION = 'requires_action';
const STATUS_REQUIRES_CAPTURE = 'requires_capture';
const STATUS_REQUIRES_CONFIRMATION = 'requires_confirmation';
const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method';
const STATUS_SUCCEEDED = 'succeeded';
/** /**
* @param array|null $params * @param array|null $params
* @param array|string|null $options * @param array|string|null $options

View File

@ -0,0 +1,36 @@
<?php
namespace Stripe\Radar;
/**
* Class EarlyFraudWarning
*
* @property string $id
* @property string $object
* @property bool $actionable
* @property string $charge
* @property int $created
* @property string $fraud_type
* @property bool $livemode
*
* @package Stripe\Radar
*/
class EarlyFraudWarning extends \Stripe\ApiResource
{
const OBJECT_NAME = "radar.early_fraud_warning";
use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Retrieve;
/**
* Possible string representations of an early fraud warning's fraud type.
* @link https://stripe.com/docs/api/early_fraud_warnings/object#early_fraud_warning_object-fraud_type
*/
const FRAUD_TYPE_CARD_NEVER_RECEIVED = 'card_never_received';
const FRAUD_TYPE_FRAUDULENT_CARD_APPLICATION = 'fraudulent_card_application';
const FRAUD_TYPE_MADE_WITH_COUNTERFEIT_CARD = 'made_with_counterfeit_card';
const FRAUD_TYPE_MADE_WITH_LOST_CARD = 'made_with_lost_card';
const FRAUD_TYPE_MADE_WITH_STOLEN_CARD = 'made_with_stolen_card';
const FRAUD_TYPE_MISC = 'misc';
const FRAUD_TYPE_UNAUTHORIZED_USE_OF_CARD = 'unauthorized_use_of_card';
}

View File

@ -0,0 +1,75 @@
<?php
namespace Stripe;
/**
* Class SetupIntent
*
* @property string $id
* @property string $object
* @property string $application
* @property string $client_secret
* @property int $created
* @property string $customer
* @property string $description
* @property mixed $last_setup_error
* @property bool $livemode
* @property StripeObject $metadata
* @property mixed $next_action
* @property string $on_behalf_of
* @property string $payment_method
* @property string[] $payment_method_types
* @property string $status
*
* @package Stripe
*/
class SetupIntent extends ApiResource
{
const OBJECT_NAME = "setup_intent";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* These constants are possible representations of the status field.
*
* @link https://stripe.com/docs/api/setup_intents/object#setup_intent_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_PROCESSING = 'processing';
const STATUS_REQUIRES_ACTION = 'requires_action';
const STATUS_REQUIRES_CONFIRMATION = 'requires_confirmation';
const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method';
const STATUS_SUCCEEDED = 'succeeded';
/**
* @param array|null $params
* @param array|string|null $options
*
* @return SetupIntent The canceled setup intent.
*/
public function cancel($params = null, $options = null)
{
$url = $this->instanceUrl() . '/cancel';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return SetupIntent The confirmed setup intent.
*/
public function confirm($params = null, $options = null)
{
$url = $this->instanceUrl() . '/confirm';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -18,6 +18,7 @@ namespace Stripe;
* @property mixed $code_verification * @property mixed $code_verification
* @property int $created * @property int $created
* @property string $currency * @property string $currency
* @property string $customer
* @property mixed $eps * @property mixed $eps
* @property string $flow * @property string $flow
* @property mixed $giropay * @property mixed $giropay

View File

@ -47,7 +47,7 @@ class Stripe
public static $maxNetworkRetries = 0; public static $maxNetworkRetries = 0;
// @var boolean Whether client telemetry is enabled. Defaults to false. // @var boolean Whether client telemetry is enabled. Defaults to false.
public static $enableTelemetry = false; public static $enableTelemetry = true;
// @var float Maximum delay between retries, in seconds // @var float Maximum delay between retries, in seconds
private static $maxNetworkRetryDelay = 2.0; private static $maxNetworkRetryDelay = 2.0;
@ -55,7 +55,7 @@ class Stripe
// @var float Initial delay between retries, in seconds // @var float Initial delay between retries, in seconds
private static $initialNetworkRetryDelay = 0.5; private static $initialNetworkRetryDelay = 0.5;
const VERSION = '6.35.0'; const VERSION = '6.41.0';
/** /**
* @return string The API key used for requests. * @return string The API key used for requests.

View File

@ -13,6 +13,7 @@ namespace Stripe;
* @property mixed $billing_thresholds * @property mixed $billing_thresholds
* @property bool $cancel_at_period_end * @property bool $cancel_at_period_end
* @property int $canceled_at * @property int $canceled_at
* @property string $collection_method
* @property int $created * @property int $created
* @property int $current_period_end * @property int $current_period_end
* @property int $current_period_start * @property int $current_period_start
@ -31,6 +32,7 @@ namespace Stripe;
* @property int $quantity * @property int $quantity
* @property SubscriptionSchedule $schedule * @property SubscriptionSchedule $schedule
* @property int $start * @property int $start
* @property int $start_date
* @property string $status * @property string $status
* @property float $tax_percent * @property float $tax_percent
* @property int $trial_end * @property int $trial_end

View File

@ -12,7 +12,6 @@ namespace Stripe;
* @property string $country * @property string $country
* @property int $created * @property int $created
* @property string $customer * @property string $customer
* @property bool $deleted
* @property bool $livemode * @property bool $livemode
* @property string $type * @property string $type
* @property string $value * @property string $value
@ -27,10 +26,12 @@ class TaxId extends ApiResource
/** /**
* Possible string representations of a tax id's type. * Possible string representations of a tax id's type.
* @link https://stripe.com/docs/api/customers/tax_id_object#tax_id_object-type * @link https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-type
*/ */
const TYPE_AU_ABN = 'au_abn'; const TYPE_AU_ABN = 'au_abn';
const TYPE_EU_VAT = 'eu_vat'; const TYPE_EU_VAT = 'eu_vat';
const TYPE_IN_GST = 'in_gst';
const TYPE_NO_VAT = 'no_vat';
const TYPE_NZ_GST = 'nz_gst'; const TYPE_NZ_GST = 'nz_gst';
const TYPE_UNKNOWN = 'unknown'; const TYPE_UNKNOWN = 'unknown';

View File

@ -88,6 +88,7 @@ abstract class Util
\Stripe\Coupon::OBJECT_NAME => 'Stripe\\Coupon', \Stripe\Coupon::OBJECT_NAME => 'Stripe\\Coupon',
\Stripe\CreditNote::OBJECT_NAME => 'Stripe\\CreditNote', \Stripe\CreditNote::OBJECT_NAME => 'Stripe\\CreditNote',
\Stripe\Customer::OBJECT_NAME => 'Stripe\\Customer', \Stripe\Customer::OBJECT_NAME => 'Stripe\\Customer',
\Stripe\CustomerBalanceTransaction::OBJECT_NAME => 'Stripe\\CustomerBalanceTransaction',
\Stripe\Discount::OBJECT_NAME => 'Stripe\\Discount', \Stripe\Discount::OBJECT_NAME => 'Stripe\\Discount',
\Stripe\Dispute::OBJECT_NAME => 'Stripe\\Dispute', \Stripe\Dispute::OBJECT_NAME => 'Stripe\\Dispute',
\Stripe\EphemeralKey::OBJECT_NAME => 'Stripe\\EphemeralKey', \Stripe\EphemeralKey::OBJECT_NAME => 'Stripe\\EphemeralKey',
@ -117,6 +118,7 @@ abstract class Util
\Stripe\Person::OBJECT_NAME => 'Stripe\\Person', \Stripe\Person::OBJECT_NAME => 'Stripe\\Person',
\Stripe\Plan::OBJECT_NAME => 'Stripe\\Plan', \Stripe\Plan::OBJECT_NAME => 'Stripe\\Plan',
\Stripe\Product::OBJECT_NAME => 'Stripe\\Product', \Stripe\Product::OBJECT_NAME => 'Stripe\\Product',
\Stripe\Radar\EarlyFraudWarning::OBJECT_NAME => 'Stripe\\Radar\\EarlyFraudWarning',
\Stripe\Radar\ValueList::OBJECT_NAME => 'Stripe\\Radar\\ValueList', \Stripe\Radar\ValueList::OBJECT_NAME => 'Stripe\\Radar\\ValueList',
\Stripe\Radar\ValueListItem::OBJECT_NAME => 'Stripe\\Radar\\ValueListItem', \Stripe\Radar\ValueListItem::OBJECT_NAME => 'Stripe\\Radar\\ValueListItem',
\Stripe\Recipient::OBJECT_NAME => 'Stripe\\Recipient', \Stripe\Recipient::OBJECT_NAME => 'Stripe\\Recipient',
@ -125,6 +127,7 @@ abstract class Util
\Stripe\Reporting\ReportRun::OBJECT_NAME => 'Stripe\\Reporting\\ReportRun', \Stripe\Reporting\ReportRun::OBJECT_NAME => 'Stripe\\Reporting\\ReportRun',
\Stripe\Reporting\ReportType::OBJECT_NAME => 'Stripe\\Reporting\\ReportType', \Stripe\Reporting\ReportType::OBJECT_NAME => 'Stripe\\Reporting\\ReportType',
\Stripe\Review::OBJECT_NAME => 'Stripe\\Review', \Stripe\Review::OBJECT_NAME => 'Stripe\\Review',
\Stripe\SetupIntent::OBJECT_NAME => 'Stripe\\SetupIntent',
\Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU', \Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU',
\Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun', \Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun',
\Stripe\Source::OBJECT_NAME => 'Stripe\\Source', \Stripe\Source::OBJECT_NAME => 'Stripe\\Source',

View File

@ -24,6 +24,8 @@ abstract class Webhook
*/ */
public static function constructEvent($payload, $sigHeader, $secret, $tolerance = self::DEFAULT_TOLERANCE) public static function constructEvent($payload, $sigHeader, $secret, $tolerance = self::DEFAULT_TOLERANCE)
{ {
WebhookSignature::verifyHeader($payload, $sigHeader, $secret, $tolerance);
$data = json_decode($payload, true); $data = json_decode($payload, true);
$jsonError = json_last_error(); $jsonError = json_last_error();
if ($data === null && $jsonError !== JSON_ERROR_NONE) { if ($data === null && $jsonError !== JSON_ERROR_NONE) {
@ -33,8 +35,6 @@ abstract class Webhook
} }
$event = Event::constructFrom($data); $event = Event::constructFrom($data);
WebhookSignature::verifyHeader($payload, $sigHeader, $secret, $tolerance);
return $event; return $event;
} }
} }

View File

@ -60,7 +60,7 @@ abstract class WebhookSignature
} }
// Check if timestamp is within tolerance // Check if timestamp is within tolerance
if (($tolerance > 0) && ((time() - $timestamp) > $tolerance)) { if (($tolerance > 0) && (abs(time() - $timestamp) > $tolerance)) {
throw new Error\SignatureVerification( throw new Error\SignatureVerification(
"Timestamp outside the tolerance zone", "Timestamp outside the tolerance zone",
$header, $header,

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