Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git in…
Browse files Browse the repository at this point in the history
…to develop_dict
  • Loading branch information
hregis committed Jul 3, 2017
2 parents fa247ff + db1d97c commit 3f882cb
Show file tree
Hide file tree
Showing 65 changed files with 857 additions and 644 deletions.
44 changes: 22 additions & 22 deletions htdocs/accountancy/admin/export.php
Expand Up @@ -47,7 +47,7 @@

// Parameters ACCOUNTING_EXPORT_*
$main_option = array (
'ACCOUNTING_EXPORT_PREFIX_SPEC'
'ACCOUNTING_EXPORT_PREFIX_SPEC'
);

$model_option = array (
Expand All @@ -67,18 +67,18 @@
*/
if ($action == 'update') {
$error = 0;

$format = GETPOST('format', 'alpha');
$modelcsv = GETPOST('modelcsv', 'int');

if (! empty($format)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', $format, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}

if (! empty($modelcsv)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
$error ++;
Expand All @@ -89,23 +89,23 @@
} else {
$error ++;
}

foreach ( $main_option as $constname ) {
$constvalue = GETPOST($constname, 'alpha');

if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}

foreach ( $model_option as $constname ) {
$constvalue = GETPOST($constname, 'alpha');

if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}

if (! $error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
Expand Down Expand Up @@ -148,13 +148,13 @@
$num = count($main_option);
if ($num) {
foreach ( $main_option as $key ) {

print '<tr class="oddeven value">';

// Param
$label = $langs->trans($key);
print '<td width="50%">' . $label . '</td>';

// Value
print '<td>';
print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
Expand Down Expand Up @@ -187,7 +187,7 @@
print '<td>';
$listmodelcsv = AccountancyExport::getType();
print $form->selectarray("modelcsv", $listmodelcsv, $conf->global->ACCOUNTING_EXPORT_MODELCSV, 0);

print '</td>';
}
print "</td></tr>";
Expand All @@ -205,12 +205,12 @@
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
print "</tr>\n";
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1)

if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > AccountancyExport::$EXPORT_TYPE_NORMAL)
{
print '<tr><td colspan="2" bgcolor="red"><b>' . $langs->trans('OptionsDeactivatedForThisExportModel') . '</b></td></tr>';
}

print '<tr class="oddeven">';
print '<td width="50%">' . $langs->trans("Selectformat") . '</td>';
if (! $conf->use_javascript_ajax) {
Expand All @@ -224,24 +224,24 @@
'txt' => $langs->trans("txt")
);
print $form->selectarray("format", $listformat, $conf->global->ACCOUNTING_EXPORT_FORMAT, 0);

print '</td>';
}
print "</td></tr>";
foreach ( $model_option as $key ) {

foreach ( $model_option as $key ) {
print '<tr class="oddeven value">';

// Param
$label = $langs->trans($key);
print '<td width="50%">' . $label . '</td>';

// Value
print '<td>';
print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
print '</td></tr>';
}

print "</table>\n";
}

Expand Down
13 changes: 6 additions & 7 deletions htdocs/accountancy/bookkeeping/balance.php
Expand Up @@ -51,7 +51,7 @@
$search_accountancy_code_end = '';
}

if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) {
if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv.x") || GETPOST("button_export_csv")) {
$action = 'export_csv';
}

Expand Down Expand Up @@ -112,7 +112,10 @@
*/

if ($action == 'export_csv') {

$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == AccountancyExport::$EXPORT_TYPE_CEGID) $sep = ";"; // For CEGID, we force separator.

$journal = 'bookkepping';

include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
Expand All @@ -122,11 +125,7 @@
setEventMessages($object->error, $object->errors, 'errors');
}

foreach ( $object->lines as $line ) {

if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
$sep = ";";
}
foreach ($object->lines as $line) {
print length_accountg($line->numero_compte) . $sep;
print $line->debit . $sep;
print $line->credit . $sep;
Expand Down Expand Up @@ -157,7 +156,7 @@

print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';

$button = '<input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" />';
$button = '<input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . ' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button);

$moreforfilter = '';
Expand Down
20 changes: 10 additions & 10 deletions htdocs/accountancy/bookkeeping/list.php
Expand Up @@ -25,8 +25,7 @@
* \brief List operation of book keeping
*/
require '../../main.inc.php';

// Class
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
Expand All @@ -47,11 +46,11 @@
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));

if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt")) {
if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
$action = 'delbookkeepingyear';
}
if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) {
$action = 'export_csv';
if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOST("button_export_file")) {
$action = 'export_file';
}

$search_accountancy_code = GETPOST("search_accountancy_code");
Expand Down Expand Up @@ -99,7 +98,7 @@
$form = new Form($db);


if ($action != 'export_csv' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && empty($page)) {
if ($action != 'export_file' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && empty($page)) {
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
}
Expand Down Expand Up @@ -261,9 +260,8 @@
}
}

if ($action == 'export_csv') {

include DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
// Export into a file with format defined into setup
if ($action == 'export_file') {

$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);

Expand Down Expand Up @@ -356,9 +354,11 @@
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';

$button = '<a class="butAction" name="button_export_csv" href="'.$_SERVER["PHP_SELF"].'?action=export_csv'.($param?'&'.$param:'').'">';
$listofformat=AccountancyExport::getType();
$button = '<a class="butAction" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'').'">';
if (count($filter)) $button.= $langs->trans("ExportFilteredList");
else $button.= $langs->trans("ExportList");
$button.=' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')';
$button.= '</a>';

$groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php"">' . $langs->trans("GroupByAccountAccounting") . '</a>';
Expand Down
21 changes: 11 additions & 10 deletions htdocs/accountancy/class/accountancycategory.class.php
Expand Up @@ -429,7 +429,7 @@ public function getCatsCal() {
return - 1;
}
}

public function getCats() {
global $db, $langs, $user, $mysoc;

Expand Down Expand Up @@ -462,7 +462,7 @@ public function getCats() {
if ($num) {
while ( $i < $num ) {
$obj = $this->db->fetch_object($resql);

$data[] = array (
'rowid' => $obj->rowid,
'code' => $obj->code,
Expand All @@ -483,10 +483,10 @@ public function getCats() {
return - 1;
}
}
// calcule


// calcule

const PATTERN = '/(?:\-?\d+(?:\.?\d+)?[\+\-\*\/])+\-?\d+(?:\.?\d+)?/';

const PARENTHESIS_DEPTH = 10;
Expand Down Expand Up @@ -535,11 +535,12 @@ private function callback($input){

return 0;
}

/**
* get cpts of category
*
* @return array Result in table
* @param int $cat_id Category id
* @return array Result in table
*/
public function getCptsCat($cat_id) {
global $mysoc;
Expand All @@ -554,7 +555,7 @@ public function getCptsCat($cat_id) {
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = ".$cat_id;
$sql .= " ORDER BY t.account_number ";

//echo $sql;

$resql = $this->db->query($sql);
Expand Down Expand Up @@ -582,5 +583,5 @@ public function getCptsCat($cat_id) {
return -1;
}
}

}
9 changes: 5 additions & 4 deletions htdocs/accountancy/class/accountancyexport.class.php
Expand Up @@ -32,14 +32,15 @@
*
* Manage the different format accountancy export
*/

require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';

class AccountancyExport
{
/**
*
* @var Type of export
* @var Type of export. Defined by $conf->global->ACCOUNTING_EXPORT_MODELCSV
*/
public static $EXPORT_TYPE_NORMAL = 1;
public static $EXPORT_TYPE_NORMAL = 1; // Classic CSV
public static $EXPORT_TYPE_CEGID = 2;
public static $EXPORT_TYPE_COALA = 3;
public static $EXPORT_TYPE_BOB50 = 4;
Expand Down Expand Up @@ -81,7 +82,7 @@ public function __construct(DoliDB &$db) {
}

/**
* Get all export type are available
* Array wit all export type available (key + label)
*
* @return array of type
*/
Expand Down

0 comments on commit 3f882cb

Please sign in to comment.