From 59f356905af1a1b924689b9faec1e1cf67d4e12a Mon Sep 17 00:00:00 2001 From: bobby Date: Mon, 25 Jan 2016 12:42:18 +0100 Subject: [PATCH 01/41] Accoutancy update --- htdocs/accountancy/admin/export.php | 3 +- htdocs/accountancy/bookkeeping/list.php | 593 ++++--- .../accountancy/class/bookkeeping.class.php | 1476 +++++++++++------ .../class/html.formventilation.class.php | 62 + 4 files changed, 1384 insertions(+), 750 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index c0a987ddf82..9f060179910 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -206,7 +206,8 @@ else print ''; $listmodelcsv=array( '1'=>$langs->trans("Modelcsv_normal"), - '2'=>$langs->trans("Modelcsv_CEGID") + '2'=>$langs->trans("Modelcsv_CEGID"), + '3'=>$langs->trans("Modelcsv_COALA") ); print $form->selectarray("modelcsv",$listmodelcsv,$conf->global->ACCOUNTING_EXPORT_MODELCSV,0); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index c5fea407a12..c517df2d129 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -38,32 +38,150 @@ $page = GETPOST("page"); $sortorder = GETPOST("sortorder"); $sortfield = GETPOST("sortfield"); $action = GETPOST('action', 'alpha'); +$search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_doc_type = GETPOST("search_doc_type"); $search_doc_ref = GETPOST("search_doc_ref"); -$search_account = GETPOST("search_account"); -$search_thirdparty = GETPOST("search_thirdparty"); -$search_journal = GETPOST("search_journal"); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); +$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")) { + $action='delbookkeepingyear'; +} +if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { + $action='export_csv'; +} + +$search_accountancy_code = GETPOST("search_accountancy_code"); + +$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); +if ($search_accountancy_code_start == - 1) { + $search_accountancy_code_start = ''; +} +$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); +if ($search_accountancy_code_end == - 1) { + $search_accountancy_code_end = ''; +} + +$search_accountancy_aux_code = GETPOST("search_accountancy_aux_code"); + +$search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha'); +if ($search_accountancy_aux_code_start == - 1) { + $search_accountancy_aux_code_start = ''; +} +$search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha'); +if ($search_accountancy_aux_code_end == - 1) { + $search_accountancy_aux_code_end = ''; +} +$search_mvt_label = GETPOST('search_mvt_label', 'alpha'); +$search_direction = GETPOST('search_direction', 'alpha'); +$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); + +$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; + -if ($sortorder == "") - $sortorder = "ASC"; -if ($sortfield == "") - $sortfield = "bk.rowid"; $offset = $limit * $page; +$object = new BookKeeping($db); + $formventilation = new FormVentilation($db); $formother = new FormOther($db); +$form = new Form($db); if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { - $search_piece_num = ""; - $search_doc_ref = ""; - $search_account = ""; - $search_thirdparty = ""; - $search_journal = ""; + $search_mvt_num = ''; + $search_doc_type = ''; + $search_doc_ref = ''; + $search_doc_date = ''; + $search_accountancy_code = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_accountancy_aux_code = ''; + $search_accountancy_aux_code_start = ''; + $search_accountancy_aux_code_end = ''; + $search_mvt_label = ''; + $search_direction = ''; + $search_ledger_code = ''; + $search_date_start = ''; + $search_date_end = ''; } +if (empty($search_date_start)) { + $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')); +} +if ($sortorder == "") + $sortorder = "ASC"; + if ($sortfield == "") + $sortfield = "t.rowid"; + + +$options = ''; +$filter = array (); +if (! empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); +} +if (! empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); +} +if (! empty($search_doc_type)) { + $filter['t.doc_type'] = $search_doc_type; + $options .= '&search_doc_type=' . $search_doc_type; +} +if (! empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); +} +if (! empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $options .= '&search_doc_ref=' . $search_doc_ref; +} +if (! empty($search_accountancy_code)) { + $filter['t.numero_compte'] = $search_accountancy_code; + $options .= '&search_accountancy_code=' . $search_accountancy_code; +} +if (! empty($search_accountancy_code_start)) { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + $options .= '&search_accountancy_code_start=' . $search_accountancy_code_start; +} +if (! empty($search_accountancy_code_end)) { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + $options .= '&search_accountancy_code_end=' . $search_accountancy_code_end; +} +if (! empty($search_accountancy_aux_code)) { + $filter['t.code_tiers'] = $search_accountancy_aux_code; + $options .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code; +} +if (! empty($search_accountancy_aux_code_start)) { + $filter['t.code_tiers>='] = $search_accountancy_aux_code_start; + $options .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start; +} +if (! empty($search_accountancy_aux_code_end)) { + $filter['t.code_tiers<='] = $search_accountancy_aux_code_end; + $options .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; +} +if (! empty($search_mvt_label)) { + $filter['t.label_compte'] = $search_mvt_label; + $options .= '&search_mvt_label=' . $search_mvt_label; +} +if (! empty($search_direction)) { + $filter['t.sens'] = $search_direction; + $options .= '&search_direction=' . $search_direction; +} +if (! empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + $options .= '&search_ledger_code=' . $search_ledger_code; +} +if (! empty($search_mvt_num)) { + $filter['t.piece_num'] = $search_mvt_num; + $options .= '&search_mvt_num=' . $search_mvt_num; +} + + /* * Action */ @@ -72,96 +190,106 @@ if ($action == 'delbookkeeping') { $import_key = GETPOST('importkey', 'alpha'); if (! empty($import_key)) { - $object = new BookKeeping($db); - $result = $object->delete_by_importkey($import_key); - Header("Location: list.php"); + $result = $object->deleteByImportkey($import_key); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } + Header("Location: list.php"); + exit(); } -} elseif ($action == 'delbookkeepingyear') { +} elseif ($action == 'delbookkeepingyearconfirm') { $delyear = GETPOST('delyear', 'int'); if (! empty($delyear)) { - $object = new BookKeeping($db); - $result = $object->delete_by_year($delyear); - Header("Location: list.php"); + $result = $object->deleteByYear($delyear); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } -} elseif ($action == 'delbookkeepingyear') { - - $delyear = GETPOST('delyear', 'int'); - - if (! empty($delyear)) { - $object = new BookKeeping($db); - $result = $object->delete_by_year($delyear); Header("Location: list.php"); + exit(); + } +} elseif ($action == 'delmouvconfirm') { + + $mvt_num = GETPOST('mvt_num', 'int'); + + if (! empty($mvt_num)) { + $result = $object->deleteMvtNum($mvt_num); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } + //if (!empty($options)) { + // Header("Location: list.php?".urldecode($options)); + //} else { + Header("Location: list.php"); + //} + exit(); } -} // Export -else if ($action == 'export_csv') { +} elseif ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $journal = 'bookkepping'; - header('Content-Type: text/csv'); - header('Content-Disposition: attachment;filename=export_csv.csv'); + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; - $object = new BookKeeping($db); - $result = $object->export_bookkeping('ebp'); + $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - // Model classic Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { - - foreach ( $object->linesexport as $line ) { - print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; - print '"' . $line->code_journal . '",'; - print '"' . $line->numero_compte . '",'; - print '"' . substr($line->code_journal, 0, 2) . '",'; - print '"' . substr($line->doc_ref, 0, 40) . '",'; - print '"' . $line->num_piece . '",'; - print '"' . $line->debit . '",'; - print '"' . $line->credit . '",'; - print '"' . $conf->currency . '",'; + foreach ( $object->lines as $line ) { + + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) + { + $sep = ";"; + // Model Cegid Expert Export + $date = dol_print_date($line->doc_date, '%d%m%Y'); + print $date . $sep; + print $line->code_journal . $sep; + print length_accountg($line->numero_compte) . $sep; + print ' '. $sep; + print $line->sens . $sep; + print price($line->montant) . $sep; + print dol_trunc($line->label_compte, 32) . $sep; + print $line->doc_ref . $sep; + + /*print $line->piece_num . $sep; + print length_accounta($line->code_tiers) . $sep; + print . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep;*/ + print "\n"; } - } - // Model cegid Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { - foreach ( $object->linesexport as $line ) { - print $line->id . ','; - print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; - print '"' . $line->code_journal . '",'; - print '"' . $line->numero_compte . '",'; - print '"' . substr($line->code_journal, 0, 2) . '",'; - print '"' . substr($line->doc_ref, 0, 40) . '",'; - print '"' . $line->num_piece . '",'; - print '"' . $line->montant . '",'; - print '"' . $line->sens . '",'; - print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; - print '"' . $conf->currency . '",'; + elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { + + //Std export + $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); + print $date . $sep; + print $line->doc_ref . $sep; + print length_accounta($line->numero_compte) . $sep; + print length_accountg($line->code_tiers) . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep; + + /*print $line->piece_num . $sep; + print $line->label_compte . $sep; + print price($line->montant) . $sep; + print $line->sens . $sep;*/ + print $line->code_journal . $sep; print "\n"; - } - } - // Model Coala Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { - foreach ( $object->linesexport as $line ) { - print $line->id . ','; - print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; - print '"' . $line->code_journal . '",'; - print '"' . $line->numero_compte . '",'; - print '"' . substr($line->code_journal, 0, 2) . '",'; - print '"' . substr($line->doc_ref, 0, 40) . '",'; - print '"' . $line->num_piece . '",'; - print '"' . $line->montant . '",'; - print '"' . $line->sens . '",'; - print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; - print '"' . $conf->currency . '",'; + }elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { + + //Coala export + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $sep; + print $line->code_journal . $sep; + print length_accounta($line->numero_compte) . $sep; + print $line->piece_num . $sep; + print $line->doc_ref . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep; + print 'E' . $sep; + print length_accountg($line->code_tiers) . $sep; print "\n"; } } @@ -169,156 +297,199 @@ else if ($action == 'export_csv') { else { - llxHeader('', $langs->trans("Bookkeeping")); + $title_page=$langs->trans("Bookkeeping") .' '. dol_print_date($search_date_start).'-'.dol_print_date($search_date_end); + + llxHeader('', $title_page); /* * List */ - $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num "; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; - - if (dol_strlen(trim($search_doc_type))) { - - $sql .= " WHERE bk.piece_num LIKE '%" . $search_piece_num . "%'"; - - if (dol_strlen(trim($search_doc_ref))) { - $sql .= " AND bk.doc_ref LIKE '%" . $search_doc_ref . "%'"; + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); } } - if (dol_strlen(trim($search_doc_ref))) { - $sql .= " WHERE bk.doc_ref LIKE '%" . $search_doc_ref . "%'"; - } - if (dol_strlen(trim($search_account))) { - $sql .= " WHERE bk.numero_compte LIKE '%" . $search_account . "%'"; - } - if (dol_strlen(trim($search_thirdparty))) { - $sql .= " WHERE bk.code_tiers LIKE '%" . $search_thirdparty . "%'"; - } - if (dol_strlen(trim($search_journal))) { - $sql .= " WHERE bk.code_journal LIKE '%" . $search_journal . "%'"; + + $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); } - $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset); + if ($action == 'delmouv') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); + print $formconfirm; + } + if ($action == 'delbookkeepingyear') { + + $form_question=array(); + $delyear=GETPOST('delyear'); + + if (empty($delyear)) { + $delyear=dol_print_date(dol_now(),'%Y'); + } + $year_array=$formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear',0,'array'); + + $form_question['delyear']=array('name'=>'delyear','type'=>'select','label'=>$langs->trans('DelYear'),'values'=>$year_array,'default'=>$delyear); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); + print $formconfirm; + } - dol_syslog('accountancy/bookkeeping/list.php:: $sql=' . $sql); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); + + /*print '
'; + print ''; + print ''; + + print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey')); + + print '
'; + + print '
';*/ + + print '
'; + print '
'."\n"; + print '
'; + print '' . $langs->trans("NewAccountingMvt") . ''; + //print '' . $langs->trans("Export") . ''; + print '
'; + + print '
'; + + + /*print '
'; + print $langs->trans('DateStart') . ': '; + print $form->select_date($search_date_start, 'date_start', 0, 0, 1); + print $langs->trans('DateEnd') . ': '; + print $form->select_date($search_date_end, 'date_end', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; + print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); + print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; + print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); + print '
'; + print '
'; + print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); + print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); + print '
';*/ + + print ''; + print ''; + print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); + //print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); + //print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + //print ''; + + print ''; + print ''; + print ''; + //print ''; + //print ''; + print ''; + print ''; + + print ''; + + $var = True; + + $total_debit=0; + $total_credit=0; + + foreach ( $object->lines as $line ) { + $var = ! $var; - print_barre_liste($langs->trans("Bookkeeping"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); + $total_debit+=$line->debit; + $total_credit+=$line->credit; - /*print ''; - print ''; - print ''; - - print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey')); - - print '
'; - - print '';*/ + print ""; - print ''; - print ''; - print ''; - - print $formother->select_year(GETPOST('delyear'), 'delyear'); - - print '
'; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'; + print $langs->trans('From') . ': '; + print $form->select_date($search_date_start, 'date_start', 0, 0, 1); + print '
'; + print $langs->trans('To') . ': '; + print $form->select_date($search_date_end, 'date_end', 0, 0, 1); + //print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1); + print '
'; + //print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; + print $langs->trans('From'); + print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); + //print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; + print '
'; + print $langs->trans('To'); + print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); + print '
'; + //print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print $langs->trans('From'); + print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); + //print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print '
'; + print $langs->trans('To'); + print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); + print '
'; + print ''; + print '    '; + print ''; + print ' '; + print ''; + print '
'; - print ''; - print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "bk.piece_num", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); - print "\n"; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + //print ''; + print ''; + print ''; - print ''; - print ''; - - $var = True; - - while ( $i < min($num, $conf->liste_limit) ) { - $obj = $db->fetch_object($resql); - $var = ! $var; - - print ""; - - /* if ($old_piecenum!=$obj->piece_num) { - $total_debit=0; - $total_credit=0; - } else { - $total_debit+=$obj->debit; - $total_credit+=$obj->credit; - } - */ - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - //$old_piecenum= $obj->piece_num; - $i ++; - } - print "
      '; - print ''; - print ' '; - print ''; + print '' . $line->piece_num . '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->montant) . '' . $line->sens . '' . $line->code_journal . ''; + print '' . img_edit() . ''; + print '' . img_delete() . ''; print '
' . $obj->piece_num . '' . dol_print_date($db->jdate($obj->doc_date), 'day') . '' . $obj->doc_ref . '' . length_accountg($obj->numero_compte) . '' . length_accounta($obj->code_tiers) . '' . $obj->label_compte . '' . price($obj->debit) . '' . price($obj->credit) . '' . price($obj->montant) . '' . $obj->sens . '' . $obj->code_journal . '' . img_edit() . '
"; - - print ''; - - $db->free($resql); - } else { - dol_print_error($db); + print "\n"; } + print ''; + print ''; + print ''; + print price($total_debit); + print ''; + print ''; + print price($total_credit); + print ''; + print ''; + print ''; + + print ""; + print ''; + llxFooter(); } - $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index d3801b4a4d1..efcd972cd71 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2014 Olivier Geffroy - * Copyright (C) 2013-2015 Alexandre Spangaro - * Copyright (C) 2013-2014 Florian Henry +/* Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 RaphaĆ«l Doursenaud * * 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 @@ -19,245 +19,188 @@ */ /** - * \file htdocs/accountancy/class/bookkeeping.class.php - * \ingroup Accounting Expert - * \brief File of class to manage book keeping + * \file accountancy/bookkeeping.class.php + * \ingroup accountancy + * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * Put some comments here */ +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +// require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +// require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + /** - * Class to manage accountancy book keeping + * Class Accountingbookkeeping + * + * Put here description of your class */ -class BookKeeping extends CommonObject +class BookKeeping extends CommonObject { - var $doc_date; - var $doc_type; - var $doc_ref; - var $date_create; - var $fk_doc; - var $fk_docdet; - var $code_tiers; - var $numero_compte; - var $label_compte; - var $debit; - var $credit; - var $montant; - var $sens; - var $fk_user_author; - var $code_journal; - var $piece_num; - var $linesexport = array (); - var $linesmvt = array (); - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } - /** - * Load a line into memory from database - * - * @param int $id id of line to get - * @return int <0 if KO, >0 if OK - */ - function fetch($id) - { - $sql = "SELECT rowid, doc_date, doc_type,"; - $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers, "; - $sql .= " numero_compte, label_compte, debit, credit, "; - $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; - $sql .= " WHERE rowid = '" . $id . "'"; - - dol_syslog(get_class($this) . "fetch sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - - $this->doc_date = $this->db->jdate($obj->doc_date); - $this->doc_type = $obj->doc_type; - $this->doc_ref = $obj->doc_ref; - $this->fk_doc = $obj->fk_doc; - $this->fk_docdet = $obj->fk_docdet; - $this->code_tiers = $obj->code_tiers; - $this->numero_compte = $obj->numero_compte; - $this->label_compte = $obj->label_compte; - $this->debit = $obj->debit; - $this->credit = $obj->credit; - $this->montant = $obj->montant; - $this->sens = $obj->sens; - $this->code_journal = $obj->code_journal; - $this->piece_num = $obj->piece_num; - } - else - { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); - return - 1; - } - - return 1; - } - - /** - * Load an accounting document into memory from database - * - * @param int $piecenum Accounting document to get - * @return int <0 if KO, >0 if OK - */ - function fetch_per_mvt($piecenum) - { - $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - $sql .= " WHERE piece_num = '" . $piecenum . "'"; - - dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); - - $this->piece_num = $obj->piece_num; - $this->code_journal = $obj->code_journal; - $this->doc_date = $this->db->jdate($obj->doc_date); - $this->doc_ref = $obj->doc_ref; - $this->doc_type = $obj->doc_type; - } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); - return - 1; - } - - return 1; - } - - /** - * Return next number movement - * - * @return string Last number - */ - function getNextNumMvt() { - $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - - dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - - if ($result) - { - $obj = $this->db->fetch_object($result); - - return $obj->max; - } - else - { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR); - return - 1; - } - } - - /** - * Load all informations of accountancy document - * - * @param int $piecenum id of line to get - * @return int <0 if KO, >0 if OK - */ - function fetch_all_per_mvt($piecenum) - { - $sql = "SELECT rowid, doc_date, doc_type,"; - $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; - $sql .= " numero_compte, label_compte, debit, credit,"; - $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; - $sql .= " WHERE piece_num = '" . $piecenum . "'"; - - dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - - while ( $obj = $this->db->fetch_object($result) ) { - - $line = new BookKeepingLine(); - - $line->id = $obj->rowid; - - $line->doc_date = $this->db->jdate($obj->doc_date); - $line->doc_type = $obj->doc_type; - $line->doc_ref = $obj->doc_ref; - $line->fk_doc = $obj->fk_doc; - $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; - $line->numero_compte = $obj->numero_compte; - $line->label_compte = $obj->label_compte; - $line->debit = $obj->debit; - $line->credit = $obj->credit; - $line->montant = $obj->montant; - $line->sens = $obj->sens; - $line->code_journal = $obj->code_journal; - $line->piece_num = $obj->piece_num; - - $this->linesmvt[] = $line; - } - } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); - return - 1; - } - - return 1; - } - - /** - * Insert line into bookkeeping * - * @param User $user User who inserted operation - * @return int <0 KO >0 OK + * @var string Error code (or message) + * @deprecated + * + * @see Accountingbookkeeping::errors */ - function create($user='') - { - global $conf; - + public $error; + /** + * + * @var string[] Error codes (or messages) + */ + public $errors = array (); + /** + * + * @var string Id to identify managed objects + */ + public $element = 'accountingbookkeeping'; + /** + * + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'accounting_bookkeeping'; + + /** + * + * @var BookKeepingLine[] Lines + */ + public $lines = array (); + + /** + * + * @var int ID + */ + public $id; + /** + */ + public $doc_date = ''; + public $doc_type; + public $doc_ref; + public $fk_doc; + public $fk_docdet; + public $code_tiers; + public $numero_compte; + public $label_compte; + public $debit; + public $credit; + public $montant; + public $sens; + public $fk_user_author; + public $import_key; + public $code_journal; + public $piece_num; + + /** + */ + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) { + $this->db = $db; + return 1; + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + // Clean parameters + + if (isset($this->doc_type)) { + $this->doc_type = trim($this->doc_type); + } + if (isset($this->doc_ref)) { + $this->doc_ref = trim($this->doc_ref); + } + if (isset($this->fk_doc)) { + $this->fk_doc = trim($this->fk_doc); + } + if (isset($this->fk_docdet)) { + $this->fk_docdet = trim($this->fk_docdet); + } + if (isset($this->code_tiers)) { + $this->code_tiers = trim($this->code_tiers); + } + if (isset($this->numero_compte)) { + $this->numero_compte = trim($this->numero_compte); + } + if (isset($this->label_compte)) { + $this->label_compte = trim($this->label_compte); + } + if (isset($this->debit)) { + $this->debit = trim($this->debit); + } + if (isset($this->credit)) { + $this->credit = trim($this->credit); + } + if (isset($this->montant)) { + $this->montant = trim($this->montant); + } + if (isset($this->sens)) { + $this->sens = trim($this->sens); + } + if (isset($this->fk_user_author)) { + $this->fk_user_author = trim($this->fk_user_author); + } + if (isset($this->import_key)) { + $this->import_key = trim($this->import_key); + } + if (isset($this->code_journal)) { + $this->code_journal = trim($this->code_journal); + } + if (isset($this->piece_num)) { + $this->piece_num = trim($this->piece_num); + } + + $this->db->begin(); + $this->piece_num = 0; - + // first check if line not yet in bookkeeping $sql = "SELECT count(*)"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; + $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE doc_type = '" . $this->doc_type . "'"; $sql .= " AND fk_docdet = " . $this->fk_docdet; $sql .= " AND numero_compte = '" . $this->numero_compte . "'"; - + dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); - + if ($resql) { $row = $this->db->fetch_array($resql); if ($row[0] == 0) { - + // Determine piece_num $sqlnum = "SELECT piece_num"; - $sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; + $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; $sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; $sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; - + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); - if ($resqlnum) - { + if ($resqlnum) { $objnum = $this->db->fetch_object($resqlnum); $this->piece_num = $objnum->piece_num; } dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG); - if (empty($this->piece_num)) - { + if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; - $sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; - + $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { @@ -269,13 +212,13 @@ class BookKeeping extends CommonObject if (empty($this->piece_num)) { $this->piece_num = 1; } - + $now = dol_now(); if (empty($this->date_create)) { $this->date_create = $now; } - - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping ("; + + $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element." ("; $sql .= "doc_date"; $sql .= ", doc_type"; @@ -293,7 +236,7 @@ class BookKeeping extends CommonObject $sql .= ", import_key"; $sql .= ", code_journal"; $sql .= ", piece_num"; - + $sql .= ") VALUES ("; $sql .= "'" . $this->doc_date . "'"; @@ -308,57 +251,587 @@ class BookKeeping extends CommonObject $sql .= "," . $this->credit; $sql .= "," . $this->montant; $sql .= ",'" . $this->sens . "'"; - $sql .= ",'" . $this->fk_user_author."'"; + $sql .= ",'" . $this->fk_user_author . "'"; $sql .= ",'" . $this->date_create . "'"; $sql .= ",'" . $this->code_journal . "'"; $sql .= "," . $this->piece_num; $sql .= ")"; - + dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping"); - + $id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + if ($id > 0) { $this->id = $id; $result = 0; } else { $result = - 2; - dol_syslog("BookKeeping::Create Error $result lecture ID"); + $error ++; + $this->errors[] = 'Error Create Error ' . $result . ' lecture ID'; + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } } else { $result = - 1; - dol_syslog("BookKeeping::Create Error $result INSERT Mysql"); + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } } else { $result = - 3; - dol_syslog("BookKeeping::Create Error $result SELECT Mysql"); + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } } else { $result = - 5; - dol_syslog("BookKeeping::Create Error $result SELECT Mysql"); + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + + if (! $error) { + + if (! $notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. + + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_CREATE',$user); + // if ($result < 0) $error++; + // // End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return $result; } - - return $result; } - + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create_std(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + // Clean parameters + + if (isset($this->doc_type)) { + $this->doc_type = trim($this->doc_type); + } + if (isset($this->doc_ref)) { + $this->doc_ref = trim($this->doc_ref); + } + if (isset($this->fk_doc)) { + $this->fk_doc = trim($this->fk_doc); + } + if (isset($this->fk_docdet)) { + $this->fk_docdet = trim($this->fk_docdet); + } + if (isset($this->code_tiers)) { + $this->code_tiers = trim($this->code_tiers); + } + if (isset($this->numero_compte)) { + $this->numero_compte = trim($this->numero_compte); + } + if (isset($this->label_compte)) { + $this->label_compte = trim($this->label_compte); + } + if (isset($this->debit)) { + $this->debit = trim($this->debit); + } + if (isset($this->credit)) { + $this->credit = trim($this->credit); + } + if (isset($this->montant)) { + $this->montant = trim($this->montant); + } + if (isset($this->sens)) { + $this->sens = trim($this->sens); + } + if (isset($this->fk_user_author)) { + $this->fk_user_author = trim($this->fk_user_author); + } + if (isset($this->import_key)) { + $this->import_key = trim($this->import_key); + } + if (isset($this->code_journal)) { + $this->code_journal = trim($this->code_journal); + } + if (isset($this->piece_num)) { + $this->piece_num = trim($this->piece_num); + } + + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; + + $sql.= 'doc_date,'; + $sql.= 'doc_type,'; + $sql.= 'doc_ref,'; + $sql.= 'fk_doc,'; + $sql.= 'fk_docdet,'; + $sql.= 'code_tiers,'; + $sql.= 'numero_compte,'; + $sql.= 'label_compte,'; + $sql.= 'debit,'; + $sql.= 'credit,'; + $sql.= 'montant,'; + $sql.= 'sens,'; + $sql.= 'fk_user_author,'; + $sql.= 'import_key,'; + $sql.= 'code_journal,'; + $sql.= 'piece_num'; + + + $sql .= ') VALUES ('; + + $sql .= ' '.(! isset($this->doc_date) || dol_strlen($this->doc_date)==0?'NULL':"'".$this->db->idate($this->doc_date)."'").','; + $sql .= ' '.(! isset($this->doc_type)?'NULL':"'".$this->db->escape($this->doc_type)."'").','; + $sql .= ' '.(! isset($this->doc_ref)?'NULL':"'".$this->db->escape($this->doc_ref)."'").','; + $sql .= ' '.(empty($this->fk_doc)?'0':$this->fk_doc).','; + $sql .= ' '.(empty($this->fk_docdet)?'0':$this->fk_docdet).','; + $sql .= ' '.(! isset($this->code_tiers)?'NULL':"'".$this->db->escape($this->code_tiers)."'").','; + $sql .= ' '.(! isset($this->numero_compte)?'NULL':"'".$this->db->escape($this->numero_compte)."'").','; + $sql .= ' '.(! isset($this->label_compte)?'NULL':"'".$this->db->escape($this->label_compte)."'").','; + $sql .= ' '.(! isset($this->debit)?'NULL':"'".$this->debit."'").','; + $sql .= ' '.(! isset($this->credit)?'NULL':"'".$this->credit."'").','; + $sql .= ' '.(! isset($this->montant)?'NULL':"'".$this->montant."'").','; + $sql .= ' '.(! isset($this->sens)?'NULL':"'".$this->db->escape($this->sens)."'").','; + $sql .= ' '.$user->id.','; + $sql .= ' '.(! isset($this->import_key)?'NULL':"'".$this->db->escape($this->import_key)."'").','; + $sql .= ' '.(! isset($this->code_journal)?'NULL':"'".$this->db->escape($this->code_journal)."'").','; + $sql .= ' '.(! isset($this->piece_num)?'NULL':$this->piece_num); + + + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_CREATE',$user); + //if ($result < 0) $error++; + //// End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.doc_date,"; + $sql .= " t.doc_type,"; + $sql .= " t.doc_ref,"; + $sql .= " t.fk_doc,"; + $sql .= " t.fk_docdet,"; + $sql .= " t.code_tiers,"; + $sql .= " t.numero_compte,"; + $sql .= " t.label_compte,"; + $sql .= " t.debit,"; + $sql .= " t.credit,"; + $sql .= " t.montant,"; + $sql .= " t.sens,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.import_key,"; + $sql .= " t.code_journal,"; + $sql .= " t.piece_num"; + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + if (null !== $ref) { + $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + } else { + $sql .= ' WHERE t.rowid = ' . $id; + } + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->doc_date = $this->db->jdate($obj->doc_date); + $this->doc_type = $obj->doc_type; + $this->doc_ref = $obj->doc_ref; + $this->fk_doc = $obj->fk_doc; + $this->fk_docdet = $obj->fk_docdet; + $this->code_tiers = $obj->code_tiers; + $this->numero_compte = $obj->numero_compte; + $this->label_compte = $obj->label_compte; + $this->debit = $obj->debit; + $this->credit = $obj->credit; + $this->montant = $obj->montant; + $this->sens = $obj->sens; + $this->fk_user_author = $obj->fk_user_author; + $this->import_key = $obj->import_key; + $this->code_journal = $obj->code_journal; + $this->piece_num = $obj->piece_num; + } + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.doc_date,"; + $sql .= " t.doc_type,"; + $sql .= " t.doc_ref,"; + $sql .= " t.fk_doc,"; + $sql .= " t.fk_docdet,"; + $sql .= " t.code_tiers,"; + $sql .= " t.numero_compte,"; + $sql .= " t.label_compte,"; + $sql .= " t.debit,"; + $sql .= " t.credit,"; + $sql .= " t.montant,"; + $sql .= " t.sens,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.import_key,"; + $sql .= " t.code_journal,"; + $sql .= " t.piece_num"; + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + + // Manage filter + $sqlwhere = array (); + if (count($filter) > 0) { + foreach ( $filter as $key => $value ) { + if ($key=='t.doc_date') { + $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + } elseif($key=='t.doc_date>=' || $key=='t.doc_date<=') { + $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + } elseif($key=='t.numero_compte>=' || $key=='t.numero_compte<=' || $key=='t.code_tiers>=' || $key=='t.code_tiers<=') { + $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + } elseif($key=='t.fk_doc' || $key=='t.fk_docdet' || $key=='t.piece_num') { + $sqlwhere[] = $key . '=' . $value; + } elseif($key=='t.code_tiers' || $key=='t.numero_compte') { + $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + } else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + } + + if (! empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (! empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + } + $this->lines = array (); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ( $obj = $this->db->fetch_object($resql) ) { + $line = new BookKeepingLine(); + + $line->id = $obj->rowid; + + $line->doc_date = $this->db->jdate($obj->doc_date); + $line->doc_type = $obj->doc_type; + $line->doc_ref = $obj->doc_ref; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->code_tiers = $obj->code_tiers; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->montant; + $line->sens = $obj->sens; + $line->fk_user_author = $obj->fk_user_author; + $line->import_key = $obj->import_key; + $line->code_journal = $obj->code_journal; + $line->piece_num = $obj->piece_num; + + $this->lines[] = $line; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) { + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + // Clean parameters + + if (isset($this->doc_type)) { + $this->doc_type = trim($this->doc_type); + } + if (isset($this->doc_ref)) { + $this->doc_ref = trim($this->doc_ref); + } + if (isset($this->fk_doc)) { + $this->fk_doc = trim($this->fk_doc); + } + if (isset($this->fk_docdet)) { + $this->fk_docdet = trim($this->fk_docdet); + } + if (isset($this->code_tiers)) { + $this->code_tiers = trim($this->code_tiers); + } + if (isset($this->numero_compte)) { + $this->numero_compte = trim($this->numero_compte); + } + if (isset($this->label_compte)) { + $this->label_compte = trim($this->label_compte); + } + if (isset($this->debit)) { + $this->debit = trim($this->debit); + } + if (isset($this->credit)) { + $this->credit = trim($this->credit); + } + if (isset($this->montant)) { + $this->montant = trim($this->montant); + } + if (isset($this->sens)) { + $this->sens = trim($this->sens); + } + if (isset($this->fk_user_author)) { + $this->fk_user_author = trim($this->fk_user_author); + } + if (isset($this->import_key)) { + $this->import_key = trim($this->import_key); + } + if (isset($this->code_journal)) { + $this->code_journal = trim($this->code_journal); + } + if (isset($this->piece_num)) { + $this->piece_num = trim($this->piece_num); + } + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + + $sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ','; + $sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ','; + $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; + $sql .= ' fk_doc = ' . (isset($this->fk_doc) ? $this->fk_doc : "null") . ','; + $sql .= ' fk_docdet = ' . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ','; + $sql .= ' code_tiers = ' . (isset($this->code_tiers) ? "'" . $this->db->escape($this->code_tiers) . "'" : "null") . ','; + $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; + $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; + $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; + $sql .= ' credit = ' . (isset($this->credit) ? $this->credit : "null") . ','; + $sql .= ' montant = ' . (isset($this->montant) ? $this->montant : "null") . ','; + $sql .= ' sens = ' . (isset($this->sens) ? "'" . $this->db->escape($this->sens) . "'" : "null") . ','; + $sql .= ' fk_user_author = ' . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ','; + $sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ','; + $sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ','; + $sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null"); + + $sql .= ' WHERE rowid=' . $this->id; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (! $resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + if (! $error && ! $notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_MODIFY',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + $this->db->begin(); + + if (! $error) { + if (! $notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_DELETE',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + } + } + + if (! $error) { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; + $sql .= ' WHERE rowid=' . $this->id; + + $resql = $this->db->query($sql); + if (! $resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + /** * Delete bookkepping by importkey * * @param string $importkey Import key * @return int Result */ - function delete_by_importkey($importkey) { + function deleteByImportkey($importkey) { $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; + $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE import_key = '" . $importkey . "'"; - + $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); foreach ( $this->errors as $errmsg ) { @@ -368,23 +841,23 @@ class BookKeeping extends CommonObject $this->db->rollback(); return - 1; } - + $this->db->commit(); return 1; } /** - * Delete bookkepping by importkey + * Delete bookkepping by year * * @param string $delyear year to delete * @return int Result */ - function delete_by_year($delyear) { + function deleteByYear($delyear) { $this->db->begin(); // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; + $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE YEAR(doc_date) = ".$delyear; $resql = $this->db->query($sql); @@ -402,313 +875,187 @@ class BookKeeping extends CommonObject $this->db->commit(); return 1; } - + /** - * Create object into database + * Delete bookkepping by piece number * - * @param User $user Object user that create - * @param int $notrigger 1=Does not execute triggers, 0 otherwise - * @return int <0 if KO, >0 if OK + * @param int $piecenum peicenum to delete + * @return int Result */ - function create_std($user, $notrigger = 0) - { - $error = 0; - - // Clean parameters - if (isset($this->doc_type)) - $this->doc_type = trim($this->doc_type); - if (isset($this->doc_ref)) - $this->doc_ref = trim($this->doc_ref); - if (isset($this->fk_doc)) - $this->fk_doc = trim($this->fk_doc); - if (isset($this->fk_docdet)) - $this->fk_docdet = trim($this->fk_docdet); - if (isset($this->code_tiers)) - $this->code_tiers = trim($this->code_tiers); - if (isset($this->numero_compte)) - $this->numero_compte = trim($this->numero_compte); - if (isset($this->label_compte)) - $this->label_compte = trim($this->label_compte); - if (isset($this->debit)) - $this->debit = trim($this->debit); - if (isset($this->credit)) - $this->credit = trim($this->credit); - if (isset($this->montant)) - $this->montant = trim($this->montant); - if (isset($this->sens)) - $this->sens = trim($this->sens); - if (isset($this->fk_user_author)) - $this->fk_user_author = trim($this->fk_user_author); - if (isset($this->import_key)) - $this->import_key = trim($this->import_key); - if (isset($this->code_journal)) - $this->code_journal = trim($this->code_journal); - if (isset($this->piece_num)) - $this->piece_num = trim($this->piece_num); - - // Check parameters - // Put here code to add control on parameters values - - // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping("; - $sql .= "doc_date,"; - $sql .= "doc_type,"; - $sql .= "doc_ref,"; - $sql .= "fk_doc,"; - $sql .= "fk_docdet,"; - $sql .= "code_tiers,"; - $sql .= "numero_compte,"; - $sql .= "label_compte,"; - $sql .= "debit,"; - $sql .= "credit,"; - $sql .= "montant,"; - $sql .= "sens,"; - $sql .= "fk_user_author,"; - $sql .= "import_key,"; - $sql .= "code_journal,"; - $sql .= "piece_num"; - - $sql .= ") VALUES ("; - - $sql .= " " . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : $this->db->idate($this->doc_date)) . ","; - $sql .= " " . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ","; - $sql .= " " . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ","; - $sql .= " " . (! isset($this->fk_doc) ? 'NULL' : "'" . $this->fk_doc . "'") . ","; - $sql .= " " . (! isset($this->fk_docdet) ? 'NULL' : "'" . $this->fk_docdet . "'") . ","; - $sql .= " " . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ","; - $sql .= " " . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ","; - $sql .= " " . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ","; - $sql .= " " . (! isset($this->debit) ? 'NULL' : "'" . $this->debit . "'") . ","; - $sql .= " " . (! isset($this->credit) ? 'NULL' : "'" . $this->credit . "'") . ","; - $sql .= " " . (! isset($this->montant) ? 'NULL' : "'" . $this->montant . "'") . ","; - $sql .= " " . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ","; - $sql .= " " . $user->id . ","; - $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ","; - $sql .= " " . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ","; - $sql .= " " . (! isset($this->piece_num) ? 'NULL' : "'" . $this->piece_num . "'") . ""; - - $sql .= ")"; - + function deleteMvtNum($piecenum) { + $this->db->begin(); - - dol_syslog(get_class($this) . "::create_std sql=" . $sql, LOG_DEBUG); + + // first check if line not yet in bookkeeping + $sql = "DELETE"; + $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; + $sql .= " WHERE piece_num = ".$piecenum; + $resql = $this->db->query($sql); + if (! $resql) { - $error ++; $this->errors[] = "Error " . $this->db->lasterror(); - } - - if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping"); - -// if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers -// } - } - - // Commit or rollback - if ($error) { - foreach ( $this->errors as $errmsg ) { - dol_syslog(get_class($this) . "::create_std " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return - 1 * $error; - } else { - $this->db->commit(); - return $this->id; - } - } - - /** - * Update object into database - * - * @param User $user Object user that create - * @param int $notrigger 1=Does not execute triggers, 0 otherwise - * @return int <0 if KO, >0 if OK - */ - function update($user = 0, $notrigger = 0) - { - $error = 0; - - // Clean parameters - if (isset($this->doc_type)) - $this->doc_type = trim($this->doc_type); - if (isset($this->doc_ref)) - $this->doc_ref = trim($this->doc_ref); - if (isset($this->fk_doc)) - $this->fk_doc = trim($this->fk_doc); - if (isset($this->fk_docdet)) - $this->fk_docdet = trim($this->fk_docdet); - if (isset($this->code_tiers)) - $this->code_tiers = trim($this->code_tiers); - if (isset($this->numero_compte)) - $this->numero_compte = trim($this->numero_compte); - if (isset($this->label_compte)) - $this->label_compte = trim($this->label_compte); - if (isset($this->debit)) - $this->debit = trim($this->debit); - if (isset($this->credit)) - $this->credit = trim($this->credit); - if (isset($this->montant)) - $this->montant = trim($this->montant); - if (isset($this->sens)) - $this->sens = trim($this->sens); - if (isset($this->fk_user_author)) - $this->fk_user_author = trim($this->fk_user_author); - if (isset($this->import_key)) - $this->import_key = trim($this->import_key); - if (isset($this->code_journal)) - $this->code_journal = trim($this->code_journal); - if (isset($this->piece_num)) - $this->piece_num = trim($this->piece_num); - - // Check parameters - // Put here code to add a control on parameters values - - // Update request - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET"; - - $sql .= " doc_date=" . (dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ","; - $sql .= " doc_type=" . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ","; - $sql .= " doc_ref=" . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ","; - $sql .= " fk_doc=" . (isset($this->fk_doc) ? $this->fk_doc : "null") . ","; - $sql .= " fk_docdet=" . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ","; - $sql .= " code_tiers=" . (isset($this->code_tiers) ? "'" . $this->db->escape($this->code_tiers) . "'" : "null") . ","; - $sql .= " numero_compte=" . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ","; - $sql .= " label_compte=" . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ","; - $sql .= " debit=" . (isset($this->debit) ? $this->debit : "null") . ","; - $sql .= " credit=" . (isset($this->credit) ? $this->credit : "null") . ","; - $sql .= " montant=" . (isset($this->montant) ? $this->montant : "null") . ","; - $sql .= " sens=" . (isset($this->sens) ? "'" . $this->db->escape($this->sens) . "'" : "null") . ","; - $sql .= " fk_user_author=" . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ","; - $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ","; - $sql .= " code_journal=" . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ","; - $sql .= " piece_num=" . (isset($this->piece_num) ? $this->piece_num : "null") . ""; - - $sql .= " WHERE rowid=" . $this->id; - - $this->db->begin(); - - dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = "Error " . $this->db->lasterror(); - } - -// if (! $error) { -// if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers -// } -// } - - // Commit or rollback - if ($error) { - foreach ( $this->errors as $errmsg ) { - dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); - } - $this->db->rollback(); - return - 1 * $error; - } else { - $this->db->commit(); - return 1; - } - } - - /** - * Delete object in database - * - * @param User $user Object user that create - * @param int $notrigger 1=Does not execute triggers, 0 otherwise - * @return int <0 if KO, >0 if OK - */ - function delete($user, $notrigger = 0) - { - $error = 0; - - $this->db->begin(); - -// if (! $notrigger) -// { -// // Call trigger -// $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user); -// if ($result < 0) $error++; -// // End call triggers -// } - - if (! $error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - $sql .= " WHERE rowid=" . $this->id; - - dol_syslog(get_class($this) . "::delete sql=" . $sql); - $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = "Error " . $this->db->lasterror(); - } - } - - // Commit or rollback - if ($error) { foreach ( $this->errors as $errmsg ) { dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return - 1; } - else - { + + $this->db->commit(); + return 1; + } + + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * + * @return int New id of clone + */ + public function createFromClone($fromid) { + dol_syslog(__METHOD__, LOG_DEBUG); + + global $user; + $error = 0; + $object = new Accountingbookkeeping($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $result = $object->create($user); + + // Other options + if ($result < 0) { + $error ++; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + // End + if (! $error) { $this->db->commit(); - return 1; + + return $object->id; + } else { + $this->db->rollback(); + + return - 1; } } - + /** - * Delete bookkepping by importkey + * Initialise object with example values + * Id must be 0 if object instance is a specimen * - * @param string $model Model - * @return int Result + * @return void */ - function export_bookkeping($model = 'ebp') - { + public function initAsSpecimen() { + $this->id = 0; + + $this->doc_date = ''; + $this->doc_type = ''; + $this->doc_ref = ''; + $this->fk_doc = ''; + $this->fk_docdet = ''; + $this->code_tiers = ''; + $this->numero_compte = ''; + $this->label_compte = ''; + $this->debit = ''; + $this->credit = ''; + $this->montant = ''; + $this->sens = ''; + $this->fk_user_author = ''; + $this->import_key = ''; + $this->code_journal = ''; + $this->piece_num = ''; + } + + /** + * Load an accounting document into memory from database + * + * @param int $piecenum Accounting document to get + * @return int <0 if KO, >0 if OK + */ + public function fetch_per_mvt($piecenum) { + $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; + $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; + $sql .= " WHERE piece_num = " . $piecenum; + + dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + + $this->piece_num = $obj->piece_num; + $this->code_journal = $obj->code_journal; + $this->doc_date = $this->db->jdate($obj->doc_date); + $this->doc_ref = $obj->doc_ref; + $this->doc_type = $obj->doc_type; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); + return - 1; + } + + return 1; + } + + /** + * Return next number movement + * + * @return string Last number + */ + public function getNextNumMvt() { + $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element; + + dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); + $result = $this->db->query($sql); + + if ($result) { + $obj = $this->db->fetch_object($result); + + return $obj->max; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR); + return - 1; + } + } + + /** + * Load all informations of accountancy document + * + * @param int $piecenum id of line to get + * @return int <0 if KO, >0 if OK + */ + function fetch_all_per_mvt($piecenum) { $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - - dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); - - $resql = $this->db->query($sql); - - if ($resql) { - $this->linesexport = array (); - - $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; + $sql .= " WHERE piece_num = " . $piecenum; + + dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + + while ( $obj = $this->db->fetch_object($result) ) { + $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -723,11 +1070,64 @@ class BookKeeping extends CommonObject $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + + $this->linesmvt[] = $line; + } + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); + return - 1; + } + + return 1; + } + + /** + * Export bookkeping + * + * @param string $model Model + * @return int Result + */ + function export_bookkeping($model = 'ebp') + { + $sql = "SELECT rowid, doc_date, doc_type,"; + $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; + $sql .= " numero_compte, label_compte, debit, credit,"; + $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; + $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; + + dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); + + $resql = $this->db->query($sql); + + if ($resql) { + $this->linesexport = array (); + + $num = $this->db->num_rows($resql); + while ( $obj = $this->db->fetch_object($resql) ) { + $line = new BookKeepingLine(); + + $line->id = $obj->rowid; + + $line->doc_date = $this->db->jdate($obj->doc_date); + $line->doc_type = $obj->doc_type; + $line->doc_ref = $obj->doc_ref; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->code_tiers = $obj->code_tiers; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->montant; + $line->sens = $obj->sens; + $line->code_journal = $obj->code_journal; + $line->piece_num = $obj->piece_num; + $this->linesexport[] = $line; } $this->db->free($resql); - + return $num; } else @@ -742,22 +1142,22 @@ class BookKeeping extends CommonObject /** * Class BookKeepingLine */ -class BookKeepingLine -{ - var $id; - var $doc_date; - var $doc_type; - var $doc_ref; - var $fk_doc; - var $fk_docdet; - var $code_tiers; - var $numero_compte; - var $label_compte; - var $debit; - var $credit; - var $montant; - var $sens; - var $fk_user_author; - var $code_journal; - var $piece_num; +class BookKeepingLine { + public $id; + public $doc_date = ''; + public $doc_type; + public $doc_ref; + public $fk_doc; + public $fk_docdet; + public $code_tiers; + public $numero_compte; + public $label_compte; + public $debit; + public $credit; + public $montant; + public $sens; + public $fk_user_author; + public $import_key; + public $code_journal; + public $piece_num; } diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index 6863b997d33..a1f01e5116b 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -342,4 +342,66 @@ class FormVentilation extends Form return $out; } + + /** + * Return HTML combo list of years existing into book keepping + * + * @param string $selected Preselected value + * @param string $htmlname Name of HTML select object + * @param int $useempty Affiche valeur vide dans liste + * @param string $output_format (html/opton (for option html only)/array (to return options arrays + * @return string/array + */ + function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html') { + $out = ''; + $out_array = array (); + + if ($output_format == 'html') { + $out .= '\n"; + } + + if ($output_format == 'html' || $output_format == 'options') { + return $out; + } elseif ($output_format == 'array') { + return $out_array; + } + } } From 87284ef9be339d3a095f9ab3ffe755d8e717000b Mon Sep 17 00:00:00 2001 From: bobby Date: Thu, 28 Jan 2016 13:37:09 +0100 Subject: [PATCH 02/41] accoutancy module enhancement --- htdocs/accountancy/bookkeeping/card.php | 8 +- htdocs/accountancy/bookkeeping/listbyyear.php | 289 ++++++++++++++---- .../accountancy/class/bookkeeping.class.php | 19 +- htdocs/accountancy/journal/bankjournal.php | 4 +- .../accountancy/journal/purchasesjournal.php | 6 +- htdocs/accountancy/journal/sellsjournal.php | 6 +- 6 files changed, 246 insertions(+), 86 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f4e7ff8ae0a..e06ddb75b22 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -91,7 +91,7 @@ if ($action == "confirm_update") { $book->sens = 'C'; } - $result = $book->update(); + $result = $book->update($user); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } else { @@ -136,7 +136,7 @@ else if ($action == "add") { $book->sens = 'C'; } - $result = $book->create_std($user); + $result = $book->createStd($user); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } else { @@ -180,7 +180,7 @@ else if ($action == "confirm_create") { $book->montant = 0; - $result = $book->create_std($user); + $result = $book->createStd($user); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } else { @@ -271,7 +271,7 @@ if ($action == 'create') { print ''; } else { $book = new BookKeeping($db); - $result = $book->fetch_per_mvt($piece_num); + $result = $book->fetchPerMvt($piece_num); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index c6a26755365..853ac0b4fe1 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -29,6 +29,8 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.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/html.formventilation.class.php'; // Langs $langs->load("accountancy"); @@ -37,92 +39,255 @@ $page = GETPOST("page"); $sortorder = GETPOST("sortorder"); $sortfield = GETPOST("sortfield"); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); +$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); +$search_doc_type=GETPOST('search_doc_type','alpha'); +$search_doc_date=dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); +$search_doc_ref=GETPOST('search_doc_ref','alpha'); +$search_numero_compte=GETPOST('search_numero_compte','alpha'); +$search_numero_compte_start=GETPOST('search_numero_compte_start','alpha'); +if ($search_numero_compte_start==-1) { + $search_numero_compte_start=''; +} +$search_numero_compte_end=GETPOST('search_numero_compte_end','alpha'); +if ($search_numero_compte_end==-1) { + $search_numero_compte_end=''; +} +$search_code_tiers=GETPOST('search_code_tiers','alpha'); +$search_code_tiers_start=GETPOST('search_code_tiers_start','alpha'); +if ($search_code_tiers_start==-1) { + $search_code_tiers_start=''; +} +$search_code_tiers_end=GETPOST('search_code_tiers_end','alpha'); +if ($search_code_tiers_end==-1) { + $search_code_tiers_end=''; +} +$search_label_compte=GETPOST('search_label_compte','alpha'); +$search_sens=GETPOST('search_sens','alpha'); +$search_code_journal=GETPOST('search_code_journal','alpha'); + +$object = new BookKeeping($db); +$form = new Form($db); +$formventilation = new FormVentilation($db); // Filter -$year = GETPOST("year", 'int'); -if ($year == 0) { - $year_current = strftime("%Y", time()); - $year_start = $year_current; -} else { - $year_current = $year; - $year_start = $year; +if (empty($search_date_start)) { + $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')); } if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") - $sortfield = "bk.rowid"; + $sortfield = "t.rowid"; $offset = $limit * $page; llxHeader('', $langs->trans("Bookkeeping")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_doc_type = ""; + $search_doc_date = ""; + $search_doc_ref = ""; + $search_numero_compte = ""; + $search_code_tiers = ""; + $search_label_compte = ""; + $search_sens = ""; + $search_code_journal = ""; +} + +$options = ''; +$filter = array (); +if (! empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); +} +if (! empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); +} +if (! empty($search_doc_type)) { + $filter['t.doc_type'] = $search_doc_type; + $options .= '&search_doc_type=' . $search_doc_type; +} +if (! empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); +} +if (! empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $options .= '&search_doc_ref=' . $search_doc_ref; +} +if (! empty($search_numero_compte)) { + $filter['t.numero_compte'] = $search_numero_compte; + $options .= '&search_numero_compte=' . $search_numero_compte; +} +if (! empty($search_numero_compte_start)) { + $filter['t.numero_compte>='] = $search_numero_compte_start; + $options .= '&search_numero_compte_start=' . $search_numero_compte_start; +} +if (! empty($search_numero_compte_end)) { + $filter['t.numero_compte<='] = $search_numero_compte_end; + $options .= '&search_numero_compte_end=' . $search_numero_compte_end; +} +if (! empty($search_code_tiers)) { + $filter['t.code_tiers'] = $search_code_tiers; + $options .= '&search_code_tiers=' . $search_code_tiers; +} +if (! empty($search_code_tiers_start)) { + $filter['t.code_tiers>='] = $search_code_tiers_start; + $options .= '&search_code_tiers_start=' . $search_code_tiers_start; +} +if (! empty($search_code_tiers_end)) { + $filter['t.code_tiers<='] = $search_code_tiers_end; + $options .= '&search_code_tiers_end=' . $search_code_tiers_end; +} +if (! empty($search_label_compte)) { + $filter['t.label_compte'] = $search_label_compte; + $options .= '&search_label_compte=' . $search_label_compte; +} +if (! empty($search_sens)) { + $filter['t.sens'] = $search_sens; + $options .= '&search_sens=' . $search_sens; +} +if (! empty($search_code_journal)) { + $filter['t.code_journal'] = $search_code_journal; + $options .= '&search_code_journal=' . $search_code_journal; +} /* * Mode List */ -$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens, bk.code_journal"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; -// $sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y,1,false))."'"; -// $sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y,12,false))."'"; -$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset); +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } +} -dol_syslog('accountancy/bookkeeping/listbyyear.php:: $sql=' . $sql); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; +$result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter); +if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); +} + +print_barre_liste($langs->trans("Bookkeeping") .' '. dol_print_date($search_date_start).'-'.dol_print_date($search_date_end), $page, $_SERVER['PHP_SELF'], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); - print_barre_liste($langs->trans("Bookkeeping") . " $textprevyear " . $langs->trans("Year") . " $year_start $textnextyear", $page, $_SERVER['PHP_SELF'], "", $sortfield, $sortorder, '', $num); +print '
'; +print '
'; +print $langs->trans('DateStart') . ': '; +print $form->select_date($search_date_start, 'date_start'); +print $langs->trans('DateEnd') . ': '; +print $form->select_date($search_date_end, 'date_end'); +print '
'; +print '
'; +print $langs->trans('From').' '.$langs->trans('AccountAccounting') . ': '; +print $formventilation->select_account($search_numero_compte_start,'search_numero_compte_start', 1, array (), 1, 1,''); +print $langs->trans('To').' '.$langs->trans('AccountAccounting') . ': '; +print $formventilation->select_account($search_numero_compte_end,'search_numero_compte_end', 1, array (), 1, 1,''); +print '
'; +print '
'; +print $langs->trans('From').' '.$langs->trans('ThirdPartyAccount') . ': '; +print $formventilation->select_auxaccount($search_code_tiers_start,'search_code_tiers_start', 1); +print $langs->trans('To').' '.$langs->trans('ThirdPartyAccount') . ': '; +print $formventilation->select_auxaccount($search_code_tiers_end,'searchcode_tiers_end', 1); +print '
'; print ""; print ''; - print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "bk.doc_type", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder); - print_liste_field_titre(''); +print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "t.doc_type", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, "", $sortfield, $sortorder); +print '\n"; +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print "\n"; + +$var = True; + +foreach ( $object->lines as $line ) { + $var = ! $var; + + print ""; + + print '' . "\n"; + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; - - $var = True; - - while ( $i < min($num, $conf->liste_limit) ) { - $obj = $db->fetch_object($resql); - $var = ! $var; - - print ""; - - print '' . "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $i ++; - } - print "
'; +print ''; +print "
'; +print ''; +print ''; +print ''; +print ''; +print $form->select_date($search_doc_date,'doc_date',0, 0, 1); +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print '
' . $line->piece_num . '' . $line->doc_type . '' . dol_print_date($line->doc_date) . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->montant) . '' . $line->sens . '' . $line->code_journal . '' . img_edit() . '
' . $obj->doc_type . '' . dol_print_date($db->jdate($obj->doc_date)) . '' . $obj->doc_ref . '' . length_accountg($obj->numero_compte) . '' . length_accounta($obj->code_tiers) . '' . $obj->label_compte . '' . price($obj->debit) . '' . price($obj->credit) . '' . price($obj->montant) . '' . $obj->sens . '' . $obj->code_journal . '' . img_edit() . '
"; - $db->free($resql); -} else { - dol_print_error($db); } +print ""; +print '
'; llxFooter(); $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index efcd972cd71..58c13686d1c 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; * * Put here description of your class */ -class BookKeeping extends CommonObject +class BookKeeping extends CommonObject { /** * @@ -325,7 +325,7 @@ class BookKeeping extends CommonObject * * @return int <0 if KO, Id of created object if OK */ - public function create_std(User $user, $notrigger = false) + public function createStd(User $user, $notrigger = false) { dol_syslog(__METHOD__, LOG_DEBUG); @@ -585,12 +585,8 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif($key=='t.doc_date>=' || $key=='t.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif($key=='t.numero_compte>=' || $key=='t.numero_compte<=' || $key=='t.code_tiers>=' || $key=='t.code_tiers<=') { - $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; - } elseif($key=='t.fk_doc' || $key=='t.fk_docdet' || $key=='t.piece_num') { + } elseif($key=='t.fk_doc' || $key=='t.fk_docdet' ||$key=='t.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif($key=='t.code_tiers' || $key=='t.numero_compte') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; } @@ -883,7 +879,6 @@ class BookKeeping extends CommonObject * @return int Result */ function deleteMvtNum($piecenum) { - $this->db->begin(); // first check if line not yet in bookkeeping @@ -986,12 +981,11 @@ class BookKeeping extends CommonObject * @param int $piecenum Accounting document to get * @return int <0 if KO, >0 if OK */ - public function fetch_per_mvt($piecenum) { + public function fetchPerMvt($piecenum) { $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -1003,7 +997,7 @@ class BookKeeping extends CommonObject $this->doc_type = $obj->doc_type; } else { $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); + dol_syslog(get_class($this) . "::".__METHOD__ . $this->error, LOG_ERR); return - 1; } @@ -1142,7 +1136,8 @@ class BookKeeping extends CommonObject /** * Class BookKeepingLine */ -class BookKeepingLine { +class BookKeepingLine +{ public $id; public $doc_date = ''; public $doc_type; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index b6ae5b295d8..520800f99dd 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -343,7 +343,7 @@ if ($action == 'writebookkeeping') } } - $result = $bookkeeping->create(); + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); @@ -421,7 +421,7 @@ if ($action == 'writebookkeeping') $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; } - $result = $bookkeeping->create(); + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 9faf44e4815..dd0c1f3a4c9 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -182,7 +182,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - $result = $bookkeeping->create(); + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); @@ -212,7 +212,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - $result = $bookkeeping->create(); + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); @@ -243,7 +243,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - $result = $bookkeeping->create(); + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index b0ebc8e8df7..b22ac7ff4c5 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -217,7 +217,7 @@ if ($action == 'writebookkeeping') $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - $result = $bookkeeping->create(); + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); @@ -247,7 +247,7 @@ if ($action == 'writebookkeeping') $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - $result = $bookkeeping->create(); + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); @@ -279,7 +279,7 @@ if ($action == 'writebookkeeping') $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - $result = $bookkeeping->create(); + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); From 9c7572f2db91d896cf6dbc33c3e3808f562ce22d Mon Sep 17 00:00:00 2001 From: bobby Date: Thu, 28 Jan 2016 14:03:44 +0100 Subject: [PATCH 03/41] Fix Travis --- htdocs/core/class/link.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index 91eb8e21a7c..2a58876cdd7 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -275,7 +275,7 @@ class Link extends CommonObject /** * Return nb of links * - * @param DoliDb $dblinks Database handler + * @param DoliDb $db Database handler * @param string $objecttype type of the associated object in dolibarr * @param int $objectid id of the associated object in dolibarr * @return int Nb of links, -1 if error From b95e9f0097c603a311268cb1cfc12c5cccdeceb0 Mon Sep 17 00:00:00 2001 From: bobby Date: Thu, 28 Jan 2016 14:26:52 +0100 Subject: [PATCH 04/41] NEW : Add expense report into accountancy report --- htdocs/compta/resultat/clientfourn.php | 85 ++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index c881b263dff..c51ea5f6dde 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -621,6 +621,91 @@ if (! empty($conf->salaries->enabled)) print ''; } +/* + * Expense + */ + +if (! empty($conf->expensereport->enabled)) +{ + $langs->load('trips'); + if ($modecompta == 'CREANCES-DETTES') { + $sql = "SELECT p.rowid, p.ref, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; + $sql.= " WHERE p.entity = ".getEntity('expensereport',1); + $sql.= " AND p.fk_statut>5"; + + $column='p.date_valid'; + + } else { + $sql = "SELECT p.rowid, p.ref, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; + $sql.= " WHERE p.entity = ".getEntity('expensereport',1); + $sql.= " AND p.fk_statut=6"; + + $column='pe.datep'; + } + + print ''.$langs->trans("ExpenseReport").''; + + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; + + $sql.= " GROUP BY p.rowid, p.ref, u.firstname, u.lastname, dm"; + $sql.= " ORDER BY p.ref"; + + dol_syslog("get expense report outcome"); + $result=$db->query($sql); + $subtotal_ht = 0; + $subtotal_ttc = 0; + if ($result) + { + $num = $db->num_rows($result); + $var=true; + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total_ht -= $obj->amount_ht; + $total_ttc -= $obj->amount_ttc; + $subtotal_ht += $obj->amount_ht; + $subtotal_ttc += $obj->amount_ttc; + + $var = !$var; + print " "; + + print "".$langs->trans("ExpenseReport")." rowid."\">".$obj->ref.' ('.$obj->firstname." ".$obj->lastname.")\n"; + + if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount_ht).''; + print ''.price(-$obj->amount_ttc).''; + print ''; + $i++; + } + } + else + { + $var = !$var; + print " "; + print ''.$langs->trans("None").''; + print ''; + } + } + else + { + dol_print_error($db); + } + print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''.price(-$subtotal_ht).''; + print ''.price(-$subtotal_ttc).''; + print ''; +} /* * Donation From 0582c78131fb339ce50f2f6afbb321e4f0fb7fe6 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 29 Jan 2016 14:05:37 +0100 Subject: [PATCH 05/41] Add exepnse report into accoutnacy standard report --- htdocs/compta/resultat/clientfourn.php | 6 +-- htdocs/compta/resultat/index.php | 52 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index c51ea5f6dde..4286c6a8453 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -665,13 +665,10 @@ if (! empty($conf->expensereport->enabled)) { $num = $db->num_rows($result); $var=true; - $i = 0; if ($num) { - while ($i < $num) + while ($obj = $db->fetch_object($result)) { - $obj = $db->fetch_object($result); - $total_ht -= $obj->amount_ht; $total_ttc -= $obj->amount_ttc; $subtotal_ht += $obj->amount_ht; @@ -685,7 +682,6 @@ if (! empty($conf->expensereport->enabled)) if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount_ht).''; print ''.price(-$obj->amount_ttc).''; print ''; - $i++; } } else diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 96400da23c1..9036ce32ed0 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -521,6 +521,58 @@ if (! empty($conf->salaries->enabled)) } } +if (! empty($conf->expensereport->enabled)) +{ + $langs->load('trips'); + if ($modecompta == 'CREANCES-DETTES') { + $sql = "SELECT date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; + $sql.= " WHERE p.entity = ".getEntity('expensereport',1); + $sql.= " AND p.fk_statut>5"; + + $column='p.date_valid'; + + } else { + $sql = "SELECT date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; + $sql.= " WHERE p.entity = ".getEntity('expensereport',1); + $sql.= " AND p.fk_statut=6"; + + $column='pe.datep'; + } + + $sql.= " GROUP BY dm"; + + dol_syslog("get expense report outcome"); + $result=$db->query($sql); + $subtotal_ht = 0; + $subtotal_ttc = 0; + if ($result) + { + $num = $db->num_rows($result); + if ($num) + { + while ($obj = $db->fetch_object($result)) + { + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; + $decaiss[$obj->dm] += $obj->amount_ht; + + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; + $decaiss_ttc[$obj->dm] += $obj->amount_ttc; + + } + } + } + else + { + dol_print_error($db); + } +} + /* * Donation get dunning paiement */ From 2a1ab9a8d4ee2ce0408bb47c1a8c8892e3af59d4 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Sat, 30 Jan 2016 16:43:35 +0100 Subject: [PATCH 06/41] Update card.php delete empty row in select list of vats in expenses as this value is not accepted --- htdocs/expensereport/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a14e006fd7c..5036fd617f0 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1829,7 +1829,6 @@ else $defaultvat=-1; if (! empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; print ''; print ''; From d75a20c589828cc4defe2d26ce6c2f4727b3862a Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 30 Jan 2016 17:30:06 +0100 Subject: [PATCH 07/41] bad id on restricted aera --- htdocs/fichinter/info.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index 5be4af71d27..9f951dfe2d3 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -35,7 +35,7 @@ $id = GETPOST('id','int'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter'); +$result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); From c77fda5128b2f467bead144bbf83e9f7478cd799 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 31 Jan 2016 07:31:48 +0100 Subject: [PATCH 08/41] New accountancy menu for auguria --- htdocs/core/class/menu.class.php | 4 +- htdocs/core/menus/init_menu_auguria.sql | 55 +++++++++++++--------- htdocs/core/menus/standard/auguria.lib.php | 48 +++++++++---------- 3 files changed, 57 insertions(+), 50 deletions(-) diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 0715c2fafdc..58e93ec5544 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -55,7 +55,7 @@ class Menu * @param string $titre Label of menu to add * @param integer $level Level of menu to add * @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey) - * @param string $target Target lien + * @param string $target Target link * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) * @param int $position Position (not used yet) @@ -74,7 +74,7 @@ class Menu * @param string $titre Label of menu to add * @param integer $level Level of menu to add * @param int $enabled Menu active or not - * @param string $target Target lien + * @param string $target Target link * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) * @param int $position Position (not used yet) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 74c6260259e..1e5062f7e1d 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -205,31 +205,42 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2302__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/reglement.php?leftmenu=tax_vat', 'List', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2303__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?leftmenu=tax_vat', 'ReportByCustomers', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/quadri_detail.php?leftmenu=tax_vat', 'ReportByQuarter', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); --- Ventilation (accounting) -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'ventil_customer', 6__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=ventil_customer', 'CustomersVentilation', 0, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 8, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ventil_customer"', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', '', 2400__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 1, 'accountancy', '$user->rights->accounting->ventilation->dispatch', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ventil_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2400__+MAX_llx_menu__, '/accountancy/customer/lines.php', 'Dispatched', 1, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 1, __ENTITY__); - -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'ventil_supplier', 6__+MAX_llx_menu__, '/accountancy/supplier/index.php?leftmenu=ventil_supplier', 'SuppliersVentilation', 0, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 9, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="ventil_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php', 'ToDispatch', 1, 'accountancy', '$user->rights->accounting->ventilation->dispatch', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="ventil_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php', 'Dispatched', 1, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 1, __ENTITY__); +-- Accounting Expert +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=accounting', 'MenuAccountancy', 0, 'accountancy', '(! empty($conf->accounting->enabled) || $user->rights->accounting->ventilation->read || $user->rights->accounting->ventilation->dispatch || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); + -- Dispatch + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 1, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->ventilation->dispatch', '', 0, 2, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 3, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'ventil_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?leftmenu=dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 4, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->ventilation->dispatch', '', 0, 5, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 6, __ENTITY__); + -- Journals + -- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'journal', 2400__+MAX_llx_menu__, '/accountancy/journal/index.php?leftmenu=journal', 'Journaux', 1, 'accountancy', '$user->rights->accounting->comptarapport->lire', '', 0, 7, __ENTITY__); + -- General Ledger + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2430__+MAX_llx_menu__, 'accountancy', 'bookkeeping', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/list.php?leftmenu=bookkeeping', 'Bookkeeping', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 15, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="bookkeeping"', __HANDLER__, 'left', 2431__+MAX_llx_menu__, 'accountancy', '', 2430__+MAX_llx_menu__, '/accountancy/bookkeeping/listbyyear.php', 'ByYear', 2, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="bookkeeping"', __HANDLER__, 'left', 2432__+MAX_llx_menu__, 'accountancy', '', 2430__+MAX_llx_menu__, '/accountancy/bookkeeping/balancebymonth.php', 'AccountBalanceByMonth', 2, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__); + -- Reports + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2440__+MAX_llx_menu__, 'accountancy', 'report', 2400__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 17, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2441__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'ReportInOut', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 18, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2442__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/resultat/clientfourn.php?leftmenu=ca', 'ByCompanies', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 19, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2443__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/index.php?leftmenu=ca', 'ReportTurnover', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 20, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2444__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/casoc.php?leftmenu=ca', 'ByCompanies', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 21, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2445__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 22, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2446__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 23, __ENTITY__); + -- Admin + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'home', '', 2400__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?leftmenu=setup', 'Fiscalyear', 1, 'admin', '$user->rights->accounting->fiscalyear', '', 0, 24, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'home', '', 2400__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy', 'Chartofaccounts', 1, 'admin', '$user->rights->accounting->chartofaccount', '', 0, 25, __ENTITY__); -- Rapports -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled || $conf->accounting->enabled', __HANDLER__, 'left', 2700__+MAX_llx_menu__, 'accountancy', 'ca', 6__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 0, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 11, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled || $conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2701__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'ReportInOut', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled || $conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2702__+MAX_llx_menu__, 'accountancy', '', 2701__+MAX_llx_menu__, '/compta/resultat/clientfourn.php?leftmenu=ca', 'ByCompanies', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled || $conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2703__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/stats/index.php?leftmenu=ca', 'ReportTurnover', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled || $conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2704__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/casoc.php?leftmenu=ca', 'ByCompanies', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled || $conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2705__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled || $conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2708__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled', __HANDLER__, 'left', 2700__+MAX_llx_menu__, 'accountancy', 'ca', 6__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 0, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 11, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2701__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'ReportInOut', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2702__+MAX_llx_menu__, 'accountancy', '', 2701__+MAX_llx_menu__, '/compta/resultat/clientfourn.php?leftmenu=ca', 'ByCompanies', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2703__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/stats/index.php?leftmenu=ca', 'ReportTurnover', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2704__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/casoc.php?leftmenu=ca', 'ByCompanies', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2705__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2708__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2706__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/journal/sellsjournal.php?leftmenu=ca', 'SellsJournal', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2707__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/journal/purchasesjournal.php?leftmenu=ca', 'PurchasesJournal', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); --- Book Keeping -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2720__+MAX_llx_menu__, 'accountancy', 'bookkeeping', 6__+MAX_llx_menu__, '/accountancy/bookkeeping/list.php?leftmenu=bookkeeping', 'Bookkeeping', 0, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 12, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="bookkeeping"', __HANDLER__, 'left', 2721__+MAX_llx_menu__, 'accountancy', '', 2720__+MAX_llx_menu__, '/accountancy/bookkeeping/listbyyear.php', 'ByYear', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="bookkeeping"', __HANDLER__, 'left', 2722__+MAX_llx_menu__, 'accountancy', '', 2720__+MAX_llx_menu__, '/accountancy/bookkeeping/balancebymonth.php', 'AccountBalanceByMonth', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 1, __ENTITY__); --- Fiscal year & Chart of accounts -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2750__+MAX_llx_menu__, 'home', '', 6__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?leftmenu=setup', 'Fiscalyear', 1, 'admin', '$user->rights->accounting->fiscalyear', '', 2, 20, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2751__+MAX_llx_menu__, 'home', '', 6__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy', 'Chartofaccounts', 1, 'admin', '$user->rights->accounting->chartofaccount', '', 2, 21, __ENTITY__); -- Check deposit insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '! empty($conf->banque->enabled) && (! empty($conf->facture->enabled)) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON)', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank', 'MenuChequeDeposits', 0, 'bills', '$user->rights->banque->lire', '', 2, 9, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '! empty($conf->banque->enabled) && (! empty($conf->facture->enabled)) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON)', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/card.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'compta', '$user->rights->banque->lire', '', 2, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 9623958188d..a24a2d32baa 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -294,38 +294,34 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM if (! empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') // Entry in accountancy journal for each bank account { - $newmenu->add('/accountancy/journal/index.php?leftmenu=journal',$langs->trans("Journaux"),0,$user->rights->banque->lire); + $newmenu->add('',$langs->trans("Journaux"),0,$user->rights->accounting->comptarapport->lire,'','accountancy','accounting'); - if ($leftmenu == 'journal') + $sql = "SELECT rowid, label, accountancy_journal"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; + $sql.= " WHERE entity = ".$conf->entity; + $sql.= " AND clos = 0"; + $sql.= " ORDER BY label"; + + $resql = $db->query($sql); + if ($resql) { - $sql = "SELECT rowid, label, accountancy_journal"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND clos = 0"; - $sql.= " ORDER BY label"; + $numr = $db->num_rows($resql); + $i = 0; - $resql = $db->query($sql); - if ($resql) + if ($numr > 0) + while ($i < $numr) { - $numr = $db->num_rows($resql); - $i = 0; - - if ($numr > 0) - - while ($i < $numr) - { - $objp = $db->fetch_object($resql); - $newmenu->add('/accountancy/journal/bankjournal.php?id_account='.$objp->rowid,$langs->trans("Journal").' - '.$objp->label,1,$user->rights->accounting->comptarapport->lire); - $i++; - } + $objp = $db->fetch_object($resql); + $newmenu->add('/accountancy/journal/bankjournal.php?id_account='.$objp->rowid,$langs->trans("Journal").' - '.$objp->label,1,$user->rights->accounting->comptarapport->lire,'','accountancy','accounting'); + $i++; } - else dol_print_error($db); - $db->free($resql); - - // Add other journal - $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal",$langs->trans("SellsJournal"),1,$user->rights->accounting->comptarapport->lire); - $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal",$langs->trans("PurchasesJournal"),1,$user->rights->accounting->comptarapport->lire); } + else dol_print_error($db); + $db->free($resql); + + // Add other journal + $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal",$langs->trans("SellsJournal"),1,$user->rights->accounting->comptarapport->lire); + $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal",$langs->trans("PurchasesJournal"),1,$user->rights->accounting->comptarapport->lire); } if ($conf->ftp->enabled && $mainmenu == 'ftp') // Entry for FTP From 6a12cdc876183b176481f4a471bcec3228d0ee7d Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 31 Jan 2016 08:18:47 +0100 Subject: [PATCH 09/41] New: Add User accountancy code in export --- htdocs/core/modules/modUser.class.php | 6 +++--- htdocs/langs/en_US/users.lang | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 02a085c4a8b..48de5a48a6c 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -210,9 +210,9 @@ class modUser extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs'; $this->export_permission[$r]=array(array("user","user","export")); - $this->export_fields_array[$r]=array('u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion','u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId"); - $this->export_TypeFields_array[$r]=array('u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.office_phone'=>'Text','u.office_fax'=>'Text','u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date','u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname"); - $this->export_entities_array[$r]=array('u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.office_phone'=>'user','u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member"); + $this->export_fields_array[$r]=array('u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.accountancy_code'=>"UserAccountancyCode",'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion','u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId"); + $this->export_TypeFields_array[$r]=array('u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.accountancy_code'=>'Text','u.office_phone'=>'Text','u.office_fax'=>'Text','u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date','u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname"); + $this->export_entities_array[$r]=array('u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.accountancy_code'=>'user','u.office_phone'=>'user','u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member"); if (empty($conf->adherent->enabled)) { unset($this->export_fields_array[$r]['u.fk_member']); diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 8a7dfcfe787..47cddfa433f 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -122,3 +122,4 @@ LoginUsingOpenID=Use OpenID to login WeeklyHours=Weekly hours ColorUser=Color of the user DisabledInMonoUserMode=Disabled in maintenance mode +UserAccountancyCode=User accountancy code \ No newline at end of file From 773ee5c0eadf540cee9cbb091214c3cb0aca6fbd Mon Sep 17 00:00:00 2001 From: abb Date: Sun, 31 Jan 2016 18:56:05 +0100 Subject: [PATCH 10/41] provide link section in expenses and add option for intervention --- htdocs/core/class/html.form.class.php | 63 ++++++++++++++++++++++++++- htdocs/expensereport/card.php | 21 +++++++++ htdocs/langs/en_US/compta.lang | 3 +- htdocs/langs/fr_FR/compta.lang | 1 + 4 files changed, 86 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2230aebdbb5..5f23c65df61 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5100,7 +5100,68 @@ class Form print ''; } - if (((! is_array($restrictlinksto)) || in_array('supplier_order',$restrictlinksto)) + if ((in_array('fichinter',$restrictlinksto)) && ! empty($conf->ficheinter->enabled)) + { + $linktoelem.=($linktoelem?'   ':'').'' . $langs->trans('LinkedFichinter') . ''; + + print ' + + '; + + print '
global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>'; + + $sql = "SELECT s.rowid as socid, s.nom as name, s.client, f.rowid, f.ref"; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; + $sql .= ", " . MAIN_DB_PREFIX . "fichinter as f"; + $sql .= ' WHERE f.fk_soc = s.rowid'; + + $resqlorderlist = $this->db->query($sql); + if ($resqlorderlist) + { + $num = $this->db->num_rows($resqlorderlist); + $i = 0; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + while ($i < $num) + { + $objp = $this->db->fetch_object($resqlorderlist); + + $var = ! $var; + print ''; + print ''; + print ''; + print ''; + print ''; + + $i ++; + } + print '
' . $langs->trans("Ref") . '' . $langs->trans("Company") . '
'; + print ''; + print '' . $objp->ref . '' . $objp->name . '
'; + print '
     
'; + print '
'; + $this->db->free($resqlorderlist); + } else { + dol_print_error($this->db); + } + + print '
'; + } + + if (((! is_array($restrictlinksto)) || in_array('supplier_order',$restrictlinksto)) && ! empty($conf->fournisseur->enabled)) { $linktoelem.=($linktoelem?'   ':'').'' . $langs->trans('LinkedOrder') . ''; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a14e006fd7c..ea1f62b215b 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2087,7 +2087,28 @@ if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'e print ''; +if ($action != 'create' && $action != 'edit' && ($id || $ref)) +{ + $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + // Link invoice to intervention + if (GETPOST('LinkedFichinter')) { + $object->fetch($id); + $object->fetch_thirdparty(); + $result = $object->add_object_linked('fichinter', GETPOST('LinkedFichinter')); + } + // Linked object block + $somethingshown = $form->showLinkedObjectBlock($object); + + // Show links to link elements + $linktoelements=array(); + if($conf->global->EXPENSES_LINK_TO_INTERVENTION) $linktoelements[]='fichinter'; + $linktoelem=''; + $linktoelem = $form->showLinkToObjectBlock($object,$linktoelements); + if ($linktoelem) print '
'.$linktoelem; + +} llxFooter(); $db->close(); diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 14cacf57022..964a7c30678 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -220,4 +220,5 @@ AddExtraReport=Extra reports OtherCountriesCustomersReport=Foreign customers report BasedOnTwoFirstLettersOfVATNumberBeingDifferentFromYourCompanyCountry=Based on the two first letters of the VAT number being different from your own company's country code SameCountryCustomersWithVAT=National customers report -BasedOnTwoFirstLettersOfVATNumberBeingTheSameAsYourCompanyCountry=Based on the two first letters of the VAT number being the same as your own company's country code \ No newline at end of file +BasedOnTwoFirstLettersOfVATNumberBeingTheSameAsYourCompanyCountry=Based on the two first letters of the VAT number being the same as your own company's country code +LinkedFichinter=Link to an intervention diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index accb0faa9bf..75d28992070 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -220,3 +220,4 @@ OtherCountriesCustomersReport=Rapport client Ć©tranger BasedOnTwoFirstLettersOfVATNumberBeingDifferentFromYourCompanyCountry=BasĆ© sur les deux premiĆØres lettres du numĆ©ro de TVA Ć©tant diffĆ©rent du code de pays de votre propre entreprise SameCountryCustomersWithVAT=Rapport clients nationaux BasedOnTwoFirstLettersOfVATNumberBeingTheSameAsYourCompanyCountry=BasĆ© sur les deux premiĆØres lettres du numĆ©ro de TVA Ć©tant les mĆŖmes que le code pays de votre propre entreprise +LinkedFichinter=Lier Ć  une intervention From 3bcfe849a1ba237a2e8afaeba0f89cb138013469 Mon Sep 17 00:00:00 2001 From: abb Date: Sun, 31 Jan 2016 22:33:30 +0100 Subject: [PATCH 11/41] fix:remove project info in standard document model for expense reports when project module is disabled --- .../doc/pdf_standard.modules.php | 64 +++++++++++-------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 0731b803ca3..1513892b766 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -109,16 +109,21 @@ class pdf_standard extends ModeleExpenseReport $this->posxtype=105; $this->posxprojet=125; $this->posxtva=145; - $this->posxup=162; - $this->posxqty=176; - $this->postotalttc=186; - if ($this->page_largeur < 210) // To work with US executive format - { - $this->posxdate-=20; - $this->posxtype-=20; - $this->posxprojet-=20; - $this->posxtva-=20; - $this->posxup-=20; + $this->posxup = 162; + $this->posxqty = 176; + $this->postotalttc = 186; + if (empty($conf->projet->enabled)) { + $this->posxtva-=20; + $this->posxup-=20; + $this->posxqty-=20; + $this->postotalttc-=20; + } + if ($this->page_largeur < 210) { // To work with US executive format + $this->posxdate-=20; + $this->posxtype-=20; + $this->posxprojet-=20; + $this->posxtva-=20; + $this->posxup-=20; $this->posxqty-=20; $this->postotalttc-=20; } @@ -335,10 +340,12 @@ class pdf_standard extends ModeleExpenseReport $pdf->SetXY($this->posxtype, $curY); $pdf->MultiCell($this->posxprojet-$this->posxtype-1, 3,$outputlangs->transnoentities($object->lines[$i]->type_fees_code), 0, 'C'); - // Project - $pdf->SetFont('','', $default_font_size - 1); - $pdf->SetXY($this->posxprojet, $curY); - $pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lines[$i]->projet_ref, 0, 'C'); + if (! empty($conf->projet->enabled)) { + // Project + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetXY($this->posxprojet, $curY); + $pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lines[$i]->projet_ref, 0, 'C'); + } // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) @@ -765,23 +772,24 @@ class pdf_standard extends ModeleExpenseReport // Type $pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height); - $pdf->SetXY($this->posxtype-1, $tab_top+1); - $pdf->MultiCell($this->posxprojet-$this->posxtype-1,2, $outputlangs->transnoentities("Type"),'','C'); + $pdf->SetXY($this->posxtype - 1, $tab_top + 1); + $pdf->MultiCell($this->posxprojet - $this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C'); - // Project - $pdf->line($this->posxprojet-1, $tab_top, $this->posxprojet-1, $tab_top + $tab_height); - $pdf->SetXY($this->posxprojet-1, $tab_top+1); - $pdf->MultiCell($this->posxtva-$this->posxprojet-1,2, $outputlangs->transnoentities("Project"),'','C'); + if (!empty($conf->projet->enabled)) { + // Project + $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height); + $pdf->SetXY($this->posxprojet - 1, $tab_top + 1); + $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C'); + } - // VAT - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) - { - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); - $pdf->SetXY($this->posxtva-1, $tab_top+1); - $pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C'); - } + // VAT + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { + $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); + $pdf->SetXY($this->posxtva - 1, $tab_top + 1); + $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); + } - // Unit price + // Unit price $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->SetXY($this->posxup-1, $tab_top+1); $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C'); From 165b553a79dce83d84d4af2ab2fe0fd174c12ecc Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 1 Feb 2016 14:50:25 +0100 Subject: [PATCH 12/41] Format code --- htdocs/accountancy/admin/account.php | 52 +- htdocs/accountancy/admin/card.php | 141 ++-- htdocs/accountancy/admin/export.php | 107 ++- htdocs/accountancy/admin/fiscalyear.php | 117 ++-- htdocs/accountancy/admin/fiscalyear_card.php | 505 +++++++------- htdocs/accountancy/admin/fiscalyear_info.php | 36 +- htdocs/accountancy/admin/importaccounts.php | 25 +- htdocs/accountancy/admin/index.php | 147 ++--- htdocs/accountancy/admin/journal.php | 82 ++- htdocs/accountancy/admin/productaccount.php | 27 +- .../bookkeeping/balancebymonth.php | 13 +- htdocs/accountancy/bookkeeping/card.php | 623 +++++++++--------- htdocs/accountancy/bookkeeping/list.php | 149 +++-- htdocs/accountancy/bookkeeping/listbyyear.php | 76 +-- .../class/accountancysystem.class.php | 18 +- .../class/accountingaccount.class.php | 267 ++++---- .../accountancy/class/bookkeeping.class.php | 203 +++--- .../class/html.formventilation.class.php | 173 +++-- htdocs/accountancy/customer/card.php | 50 +- htdocs/accountancy/customer/index.php | 39 +- htdocs/accountancy/customer/lines.php | 142 ++-- htdocs/accountancy/customer/list.php | 35 +- htdocs/accountancy/journal/bankjournal.php | 306 ++++----- htdocs/accountancy/journal/index.php | 9 +- .../accountancy/journal/purchasesjournal.php | 125 ++-- htdocs/accountancy/journal/sellsjournal.php | 180 +++-- htdocs/accountancy/supplier/card.php | 32 +- htdocs/accountancy/supplier/index.php | 19 +- htdocs/accountancy/supplier/lines.php | 119 ++-- htdocs/accountancy/supplier/list.php | 20 +- htdocs/accountancy/tpl/export_journal.tpl.php | 5 +- 31 files changed, 1832 insertions(+), 2010 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 8213fed9d48..8ebaa93d96c 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -17,17 +17,16 @@ */ /** - * \file htdocs/accountancy/admin/account.php - * \ingroup Accounting Expert - * \brief List accounting account + * \file htdocs/accountancy/admin/account.php + * \ingroup Accounting Expert + * \brief List accounting account */ - require '../../main.inc.php'; - + // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; // Langs $langs->load("compta"); @@ -44,12 +43,12 @@ $search_pcgtype = GETPOST("search_pcgtype"); $search_pcgsubtype = GETPOST("search_pcgsubtype"); // Security check -if (!$user->admin) - accessforbidden(); +if (! $user->admin) + accessforbidden(); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'sortorder'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); if ($page == - 1) { $page = 0; @@ -90,11 +89,11 @@ if ($action == 'disable') { if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { - $search_account=""; - $search_label=""; - $search_accountparent=""; - $search_pcgtype=""; - $search_pcgsubtype=""; + $search_account = ""; + $search_label = ""; + $search_accountparent = ""; + $search_pcgtype = ""; + $search_pcgsubtype = ""; } /* @@ -156,7 +155,7 @@ if ($result) { print_liste_field_titre($langs->trans("Pcgtype"), $_SERVER["PHP_SELF"], "aa.pcg_type", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Pcgsubtype"), $_SERVER["PHP_SELF"], "aa.pcg_subtype", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Activated"), $_SERVER["PHP_SELF"], "aa.active", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); print ''; print ''; @@ -167,24 +166,23 @@ if ($result) { print ''; print ' '; print ''; - print ''; + print ''; print ' '; - print ''; + print ''; print ''; print ''; $var = false; - $accountstatic=new AccountingAccount($db); + $accountstatic = new AccountingAccount($db); - while ( $i < min($num, $limit) ) - { + while ( $i < min($num, $limit) ) { $obj = $db->fetch_object($resql); - $accountstatic->id=$obj->rowid; - $accountstatic->label=$obj->label; - $accountstatic->account_number=$obj->account_number; - + $accountstatic->id = $obj->rowid; + $accountstatic->label = $obj->label; + $accountstatic->account_number = $obj->account_number; + print ''; print '' . $accountstatic->getNomUrl(1) . ''; print '' . $obj->label . ''; @@ -217,7 +215,7 @@ if ($result) { print '' . "\n"; print "\n"; - $var=!$var; + $var = ! $var; $i ++; } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 1440a515794..7810ad4f3ef 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -18,18 +18,18 @@ */ /** - * \file htdocs/accountancy/admin/card.php - * \ingroup Accounting Expert - * \brief Card accounting account + * \file htdocs/accountancy/admin/card.php + * \ingroup Accounting Expert + * \brief Card accounting account */ require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; -$error=0; +$error = 0; // Langs $langs->load("bills"); @@ -42,21 +42,20 @@ $rowid = GETPOST('rowid', 'int'); $cancel = GETPOST('cancel'); // Security check -if (!$user->admin) - accessforbidden(); +if (! $user->admin) + accessforbidden(); $accounting = new AccountingAccount($db); // Action -if ($action == 'add') -{ +if ($action == 'add') { if (! $cancel) { $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result = $db->query($sql); $obj = $db->fetch_object($result); - + $accounting->fk_pcg_version = $obj->pcg_version; $accounting->pcg_type = GETPOST('pcg_type'); $accounting->pcg_subtype = GETPOST('pcg_subtype'); @@ -64,9 +63,9 @@ if ($action == 'add') $accounting->account_parent = GETPOST('account_parent', 'int'); $accounting->label = GETPOST('label', 'alpha'); $accounting->active = 1; - + $res = $accounting->create($user); - + if ($res == 0) { } else { if ($res == - 3) { @@ -80,27 +79,25 @@ if ($action == 'add') } } Header("Location: account.php"); -} -else if ($action == 'edit') -{ +} else if ($action == 'edit') { if (! GETPOST('cancel', 'alpha')) { $result = $accounting->fetch($id); - + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result2 = $db->query($sql); $obj = $db->fetch_object($result2); - + $accounting->fk_pcg_version = $obj->pcg_version; $accounting->pcg_type = GETPOST('pcg_type'); $accounting->pcg_subtype = GETPOST('pcg_subtype'); $accounting->account_number = GETPOST('account_number'); $accounting->account_parent = GETPOST('account_parent', 'int'); $accounting->label = GETPOST('label', 'alpha'); - + $result = $accounting->update($user); - + if ($result > 0) { header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit(); @@ -111,19 +108,17 @@ else if ($action == 'edit') header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit(); } -} -else if ($action == 'delete') -{ +} else if ($action == 'delete') { $result = $accounting->fetch($id); - + if (! empty($accounting->id)) { $result = $accounting->delete($user); - + if ($result > 0) { Header("Location: account.php"); } } - + if ($result < 0) { setEventMessages($accounting->error, $accounting->errors, 'errors'); } @@ -137,16 +132,15 @@ llxheader('', $langs->trans('AccountAccounting')); $form = new Form($db); $htmlacc = new FormVentilation($db); -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans('NewAccount')); - + print '
' . "\n"; print ''; print ''; - + dol_fiche_head(); - + print ''; print ''; @@ -165,45 +159,42 @@ if ($action == 'create') print ''; - + print '
' . $langs->trans("AccountNumber") . ''; print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype'); print '
'; - + dol_fiche_end(); - + print '
'; print ''; print '     '; print ''; print '
'; - + print '
'; -} -else if ($id) -{ +} else if ($id) { $rowid = $id; $account = $accounting->fetch($rowid); - + if ($account > 0) { dol_htmloutput_mesg($mesg); - + $head = accounting_prepare_head($accounting); - - if ($action == 'update') - { + + if ($action == 'update') { $soc = new Societe($db); if ($object->socid) { $soc->fetch($object->socid); } - + dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); - + print '
' . "\n"; print ''; print ''; print ''; - + print ''; - + print ''; print ''; print ''; @@ -220,86 +211,82 @@ else if ($id) print ''; - + print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("Label") . ''; print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype'); print '
'; - + dol_fiche_end(); - + print '
'; print ''; print '     '; print ''; print '
'; - + print '
'; - } - else - { + } else { $linkback = '' . $langs->trans("BackToChartofaccounts") . ''; - + dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); - + print ''; - + // Account number print ''; print ''; print ''; - + print ''; print ''; - + $accp = new AccountingAccount($db); if (! empty($accounting->account_parent)) { $accp->fetch($accounting->account_parent, ''); } print ''; print ''; - + print ''; print ''; - + print ''; print ''; - + print ''; print ''; - + print '
' . $langs->trans("AccountNumber") . '' . $accounting->account_number . '' . $linkback . '
' . $langs->trans("Label") . '' . $accounting->label . '
' . $langs->trans("Accountparent") . '' . $accp->account_number . ' - ' . $accp->label . '
' . $langs->trans("Pcgtype") . '' . $accounting->pcg_type . '
' . $langs->trans("Pcgsubtype") . '' . $accounting->pcg_subtype . '
' . $langs->trans("Activated") . ''; - + if (empty($accounting->active)) { print img_picto($langs->trans("Disabled"), 'switch_off'); } else { print img_picto($langs->trans("Activated"), 'switch_on'); } - + print '
'; - + dol_fiche_end(); - + /* * Barre d'actions */ - + print '
'; - + if ($user->admin) { print '' . $langs->trans('Modify') . ''; } else { print '' . $langs->trans('Modify') . ''; } - + if ($user->admin) { print '' . $langs->trans('Delete') . ''; } else { print '' . $langs->trans('Delete') . ''; } - + print '
'; } - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 9f060179910..0dc1798ef57 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -21,16 +21,15 @@ */ /** - * \file htdocs/accountancy/admin/export.php - * \ingroup Accounting Expert - * \brief Setup page to configure accounting expert module + * \file htdocs/accountancy/admin/export.php + * \ingroup Accounting Expert + * \brief Setup page to configure accounting expert module */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; $langs->load("compta"); $langs->load("bills"); @@ -38,14 +37,14 @@ $langs->load("admin"); $langs->load("accountancy"); // Security check -if (!$user->admin) - accessforbidden(); +if (! $user->admin) + accessforbidden(); $action = GETPOST('action', 'alpha'); // Parameters ACCOUNTING_EXPORT_* $main_option = array ( - 'ACCOUNTING_EXPORT_PREFIX_SPEC' + 'ACCOUNTING_EXPORT_PREFIX_SPEC' ); $model_option = array ( @@ -55,7 +54,7 @@ $model_option = array ( 'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT', 'ACCOUNTING_EXPORT_LABEL', 'ACCOUNTING_EXPORT_AMOUNT', - 'ACCOUNTING_EXPORT_DEVISE' + 'ACCOUNTING_EXPORT_DEVISE' ); /* @@ -63,7 +62,7 @@ $model_option = array ( */ if ($action == 'update') { $error = 0; - + $format = GETPOST('format', 'alpha'); $modelcsv = GETPOST('modelcsv', 'int'); @@ -74,7 +73,7 @@ if ($action == 'update') { } else { $error ++; } - + if (! empty($modelcsv)) { if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) { $error ++; @@ -82,23 +81,23 @@ if ($action == 'update') { } else { $error ++; } - - foreach ($main_option as $constname) { + + 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) { + + 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 { @@ -114,12 +113,11 @@ llxHeader(); $form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans('ConfigAccountingExpert'),$linkback,'title_setup'); +$linkback = '' . $langs->trans("BackToModuleList") . ''; +print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); $head = admin_accounting_prepare_head(); - print '
'; print ''; print ''; @@ -140,37 +138,33 @@ $var = ! $var; print ''; print '' . $langs->trans("Selectformat") . ''; -if (! $conf->use_javascript_ajax) -{ +if (! $conf->use_javascript_ajax) { print ''; print $langs->trans("NotAvailableWhenAjaxDisabled"); print ""; -} -else -{ +} else { print ''; - $listformat=array( - 'csv'=>$langs->trans("csv"), - 'txt'=>$langs->trans("txt") + $listformat = array ( + 'csv' => $langs->trans("csv"), + 'txt' => $langs->trans("txt") ); - print $form->selectarray("format",$listformat,$conf->global->ACCOUNTING_EXPORT_FORMAT,0); - + print $form->selectarray("format", $listformat, $conf->global->ACCOUNTING_EXPORT_FORMAT, 0); + print ''; } print ""; $num = count($main_option); -if ($num) -{ - foreach ($main_option as $key) { +if ($num) { + foreach ( $main_option as $key ) { $var = ! $var; - + print ''; - + // Param $label = $langs->trans($key); print '' . $label . ''; - + // Value print ''; print ''; @@ -195,22 +189,19 @@ $var = ! $var; print ''; print '' . $langs->trans("Selectmodelcsv") . ''; -if (! $conf->use_javascript_ajax) -{ +if (! $conf->use_javascript_ajax) { print ''; print $langs->trans("NotAvailableWhenAjaxDisabled"); print ""; -} -else -{ +} else { print ''; - $listmodelcsv=array( - '1'=>$langs->trans("Modelcsv_normal"), - '2'=>$langs->trans("Modelcsv_CEGID"), - '3'=>$langs->trans("Modelcsv_COALA") + $listmodelcsv = array ( + '1' => $langs->trans("Modelcsv_normal"), + '2' => $langs->trans("Modelcsv_CEGID"), + '3' => $langs->trans("Modelcsv_COALA") ); - print $form->selectarray("modelcsv",$listmodelcsv,$conf->global->ACCOUNTING_EXPORT_MODELCSV,0); - + print $form->selectarray("modelcsv", $listmodelcsv, $conf->global->ACCOUNTING_EXPORT_MODELCSV, 0); + print ''; } print ""; @@ -223,29 +214,29 @@ print "
\n"; */ $num2 = count($model_option); -if ($num2) -{ +if ($num2) { print ''; print ''; print ''; print "\n"; - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1) print ''; - - foreach ($model_option as $key) { + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1) + print ''; + + foreach ( $model_option as $key ) { $var = ! $var; - + print ''; - + // Param $label = $langs->trans($key); print ''; - + // Value print ''; } - + print "
' . $langs->trans('OtherOptions') . '
' . $langs->trans('OptionsDeactivatedForThisExportModel') . '
' . $langs->trans('OptionsDeactivatedForThisExportModel') . '
' . $label . ''; print ''; print '
\n"; } diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 31ec91958c9..75411d6402f 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -16,34 +16,37 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear.php - * \ingroup fiscal year - * \brief Setup page to configure fiscal year + * \file htdocs/accountancy/admin/fiscalyear.php + * \ingroup fiscal year + * \brief Setup page to configure fiscal year */ - require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; -$action=GETPOST('action'); +$action = GETPOST('action'); $langs->load("admin"); $langs->load("compta"); -if (! $user->admin) accessforbidden(); +if (! $user->admin) + accessforbidden(); -$error=0; +$error = 0; // List of statut -static $tmpstatut2label=array( - '0'=>'OpenFiscalYear', - '1'=>'CloseFiscalYear' +static $tmpstatut2label = array ( + '0' => 'OpenFiscalYear', + '1' => 'CloseFiscalYear' ); -$statut2label=array(''); -foreach ($tmpstatut2label as $key => $val) $statut2label[$key]=$langs->trans($val); +$statut2label = array ( + '' +); +foreach ( $tmpstatut2label as $key => $val ) + $statut2label[$key] = $langs->trans($val); -$errors=array(); +$errors = array (); $object = new Fiscalyear($db); @@ -55,67 +58,59 @@ $object = new Fiscalyear($db); * View */ -$max=100; +$max = 100; $form = new Form($db); $title = $langs->trans('FiscalYears'); -llxHeader('',$title,LOG_ERR); +llxHeader('', $title, LOG_ERR); print load_fiche_titre($langs->trans('FiscalYears')); $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity"; -$sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f"; -$sql.= " WHERE f.entity = ".$conf->entity; +$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f"; +$sql .= " WHERE f.entity = " . $conf->entity; $result = $db->query($sql); -if ($result) -{ - $var=false; - $num = $db->num_rows($result); - - $i = 0; - +if ($result) { + $var = false; + $num = $db->num_rows($result); + + $i = 0; + // Load attribute_label print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; - - if ($num) - { - $fiscalyearstatic=new Fiscalyear($db); - - while ($i < $num && $i < $max) - { - $obj = $db->fetch_object($result); - $fiscalyearstatic->id=$obj->rowid; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $var=!$var; - $i++; - } - - } - else - { - print ''; - } - + + if ($num) { + $fiscalyearstatic = new Fiscalyear($db); + + while ( $i < $num && $i < $max ) { + $obj = $db->fetch_object($result); + $fiscalyearstatic->id = $obj->rowid; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var = ! $var; + $i ++; + } + } else { + print ''; + } + print '
'.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("Statut").'' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("DateStart") . '' . $langs->trans("DateEnd") . '' . $langs->trans("Statut") . '
'.img_object($langs->trans("ShowFiscalYear"),"technic").' '.$obj->rowid.''.$obj->label.''.dol_print_date($db->jdate($obj->date_start),'day').''.dol_print_date($db->jdate($obj->date_end),'day').''.$fiscalyearstatic->LibStatut($obj->statut,5).'
'.$langs->trans("None").'
' . img_object($langs->trans("ShowFiscalYear"), "technic") . ' ' . $obj->rowid . '' . $obj->label . '' . dol_print_date($db->jdate($obj->date_start), 'day') . '' . dol_print_date($db->jdate($obj->date_end), 'day') . '' . $fiscalyearstatic->LibStatut($obj->statut, 5) . '
' . $langs->trans("None") . '
'; -} -else -{ +} else { dol_print_error($db); } @@ -123,7 +118,7 @@ dol_fiche_end(); // Buttons print ''; llxFooter(); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 45e69c991de..e04cc7132f0 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -16,145 +16,123 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear_card.php - * \brief Page to show a fiscal year + * \file htdocs/accountancy/admin/fiscalyear_card.php + * \brief Page to show a fiscal year */ - require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; - +require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; $langs->load("admin"); $langs->load("compta"); // Security check -if (! $user->admin) accessforbidden(); +if (! $user->admin) + accessforbidden(); -$error=0; +$error = 0; -$action = GETPOST('action','alpha'); -$confirm = GETPOST('confirm','alpha'); -$id = GETPOST('id','int'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$id = GETPOST('id', 'int'); // List of statut -static $tmpstatut2label=array( - '0'=>'OpenFiscalYear', - '1'=>'CloseFiscalYear' +static $tmpstatut2label = array ( + '0' => 'OpenFiscalYear', + '1' => 'CloseFiscalYear' ); -$statut2label=array(''); -foreach ($tmpstatut2label as $key => $val) $statut2label[$key]=$langs->trans($val); +$statut2label = array ( + '' +); +foreach ( $tmpstatut2label as $key => $val ) + $statut2label[$key] = $langs->trans($val); $object = new Fiscalyear($db); -$date_start=dol_mktime(0,0,0,GETPOST('fiscalyearmonth','int'),GETPOST('fiscalyearday','int'),GETPOST('fiscalyearyear','int')); -$date_end=dol_mktime(0,0,0,GETPOST('fiscalyearendmonth','int'),GETPOST('fiscalyearendday','int'),GETPOST('fiscalyearendyear','int')); - +$date_start = dol_mktime(0, 0, 0, GETPOST('fiscalyearmonth', 'int'), GETPOST('fiscalyearday', 'int'), GETPOST('fiscalyearyear', 'int')); +$date_end = dol_mktime(0, 0, 0, GETPOST('fiscalyearendmonth', 'int'), GETPOST('fiscalyearendday', 'int'), GETPOST('fiscalyearendyear', 'int')); /* * Actions */ -if ($action == 'confirm_delete' && $confirm == "yes") -{ - $result=$object->delete($id); - if ($result >= 0) - { - header("Location: fiscalyear.php"); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} +if ($action == 'confirm_delete' && $confirm == "yes") { + $result = $object->delete($id); + if ($result >= 0) { + header("Location: fiscalyear.php"); + exit(); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } +} -else if ($action == 'add') -{ - if (! GETPOST('cancel','alpha')) - { - $error=0; - - $object->date_start = $date_start; - $object->date_end = $date_end; - $object->label = GETPOST('label','alpha'); - $object->statut = GETPOST('statut','int'); - $object->datec = dol_now(); - - if (empty($object->date_start) && empty($object->date_end)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); - $error++; - } - if (empty($object->label)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $error++; - } - - if (! $error) - { +else if ($action == 'add') { + if (! GETPOST('cancel', 'alpha')) { + $error = 0; + + $object->date_start = $date_start; + $object->date_end = $date_end; + $object->label = GETPOST('label', 'alpha'); + $object->statut = GETPOST('statut', 'int'); + $object->datec = dol_now(); + + if (empty($object->date_start) && empty($object->date_end)) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); + $error ++; + } + if (empty($object->label)) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + $error ++; + } + + if (! $error) { $db->begin(); - - $id = $object->create($user); - - if ($id > 0) - { - $db->commit(); - - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit; - } - else - { - $db->rollback(); - - setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; - } - } - else - { - $action='create'; - } - } - else - { - header("Location: ./fiscalyear.php"); - exit; - } -} + + $id = $object->create($user); + + if ($id > 0) { + $db->commit(); + + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit(); + } else { + $db->rollback(); + + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'create'; + } + } else { + $action = 'create'; + } + } else { + header("Location: ./fiscalyear.php"); + exit(); + } +} // Update record -else if ($action == 'update') -{ - if (! GETPOST('cancel','alpha')) - { - $result = $object->fetch($id); - - $object->date_start = empty($_POST["fiscalyear"])?'':$date_start; - $object->date_end = empty($_POST["fiscalyearend"])?'':$date_end; - $object->label = GETPOST('label','alpha'); - $object->statut = GETPOST('statut','int'); - - $result = $object->update($user); - - if ($result > 0) - { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - else - { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit; - } +else if ($action == 'update') { + if (! GETPOST('cancel', 'alpha')) { + $result = $object->fetch($id); + + $object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start; + $object->date_end = empty($_POST["fiscalyearend"]) ? '' : $date_end; + $object->label = GETPOST('label', 'alpha'); + $object->statut = GETPOST('statut', 'int'); + + $result = $object->update($user); + + if ($result > 0) { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit(); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } else { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit(); + } } /* @@ -167,176 +145,165 @@ $form = new Form($db); /* * Action create -*/ -if ($action == 'create') -{ - print load_fiche_titre($langs->trans("NewFiscalYear")); - - print ''; - print ''; - print ''; - + */ +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewFiscalYear")); + + print ''; + print ''; + print ''; + dol_fiche_head(); - - print ''; - + + print '
'; + // Label - print ''; - + print ''; + // Date start - print ''; - - // Date end - print ''; - + print ''; + + // Date end + print ''; + // Statut - print ''; - print ''; + print ''; + print ''; print ''; - - print '
'.$langs->trans("Label").'
' . $langs->trans("Label") . '
'.$langs->trans("DateStart").''; - print $form->select_date(($date_start?$date_start:''),'fiscalyear'); - print '
'.$langs->trans("DateEnd").''; - print $form->select_date(($date_end?$date_end:-1),'fiscalyearend'); - print '
' . $langs->trans("DateStart") . ''; + print $form->select_date(($date_start ? $date_start : ''), 'fiscalyear'); + print '
' . $langs->trans("DateEnd") . ''; + print $form->select_date(($date_end ? $date_end : - 1), 'fiscalyearend'); + print '
'.$langs->trans("Statut").'
' . $langs->trans("Statut") . ''; - print $form->selectarray('statut',$statut2label,GETPOST('statut')); - print '
'; + print $form->selectarray('statut', $statut2label, GETPOST('statut')); + print ''; + + print ''; dol_fiche_end(); - - print '
'; - print ''; + + print '
'; + print ''; print '     '; - print ''; + print ''; print '
'; - - print ''; -} -else if ($id) -{ - $result = $object->fetch($id); - if ($result > 0) - { - $head = fiscalyear_prepare_head($object); - - if ($action == 'edit') - { - dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); - - print '
' . "\n"; - print ''; - print ''; - print ''; - - print ''; - - // Ref - print ""; - print ''; - - // Label - print ''; - - // Date start - print ''; - - // Date end - print ''; - - // Statut - print ''; + + // Date start + print ''; + + // Date end + print ''; + + // Statut + print ''; + + print '
'.$langs->trans("Ref").''; - print $object->rowid; - print '
'.$langs->trans("Label").''; - print ''; - print '
'.$langs->trans("DateStart").''; - print $form->select_date($object->date_start?$object->date_start:-1,'fiscalyear'); - print '
'.$langs->trans("DateEnd").''; - print $form->select_date($object->date_end?$object->date_end:-1,'fiscalyearend'); - print '
'.$langs->trans("Statut").''; - print $form->selectarray('statut',$statut2label,$object->statut); + + print ''; +} else if ($id) { + $result = $object->fetch($id); + if ($result > 0) { + $head = fiscalyear_prepare_head($object); + + if ($action == 'edit') { + dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); + + print '
' . "\n"; + print ''; + print ''; + print ''; + + print ''; + + // Ref + print ""; + print ''; - - print '
' . $langs->trans("Ref") . ''; + print $object->rowid; print '
'; - - print '
'; - print ''; + + // Label + print '
' . $langs->trans("Label") . ''; + print ''; + print '
' . $langs->trans("DateStart") . ''; + print $form->select_date($object->date_start ? $object->date_start : - 1, 'fiscalyear'); + print '
' . $langs->trans("DateEnd") . ''; + print $form->select_date($object->date_end ? $object->date_end : - 1, 'fiscalyearend'); + print '
' . $langs->trans("Statut") . ''; + print $form->selectarray('statut', $statut2label, $object->statut); + print '
'; + + print '
'; + print ''; print '     '; - print ''; - print '
'; - - print ''; - - dol_fiche_end(); - } - else - { - /* - * Confirm delete - */ - if ($action == 'delete') - { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("DeleteFiscalYear"),$langs->trans("ConfirmDeleteFiscalYear"),"confirm_delete"); - - } - - dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); - - print ''; - - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; + + // Statut + print ''; + + print "
'.$langs->trans("Ref").''; - print $object->rowid; + print ''; + print ''; + + print ''; + + dol_fiche_end(); + } else { + /* + * Confirm delete + */ + if ($action == 'delete') { + print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); + } + + dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); + + print ''; + + $linkback = '' . $langs->trans("BackToList") . ''; + + // Ref + print ''; - + print ''; + // Label - print '"; - - // Date start - print ''; - + print '"; + + // Date start + print ''; + // Date end - print ''; - - // Statut - print ''; - - print "
' . $langs->trans("Ref") . ''; + print $object->rowid; print ''; print $linkback; - print '
'; - print $form->editfieldkey("Label",'label',$object->label,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'alpha:32'); - print ''; - print $form->editfieldval("Label",'label',$object->label,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'alpha:32'); - print "
'; - print $form->editfieldkey("Date",'date_start',$object->date_start,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker'); - print ''; - print $form->editfieldval("Date",'date_start',$object->date_start,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker'); - print '
'; + print $form->editfieldkey("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); + print ''; + print $form->editfieldval("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); + print "
'; + print $form->editfieldkey("Date", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); + print ''; + print $form->editfieldval("Date", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); + print '
'; - print $form->editfieldkey("Date",'date_end',$object->date_end,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker'); - print ''; - print $form->editfieldval("Date",'date_end',$object->date_end,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker'); - print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
"; - - dol_fiche_end(); - - /* - * Barre d'actions - */ - - print '
'; - - print ''.$langs->trans('Modify').''; - - print ''.$langs->trans('Delete').''; - - print '
'; - } - } - else - { - dol_print_error($db); - } + print '
'; + print $form->editfieldkey("Date", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); + print ''; + print $form->editfieldval("Date", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); + print '
' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
"; + + dol_fiche_end(); + + /* + * Barre d'actions + */ + + print '
'; + + print '' . $langs->trans('Modify') . ''; + + print '' . $langs->trans('Delete') . ''; + + print '
'; + } + } else { + dol_print_error($db); + } } llxFooter(); diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index 00d50d273af..f1f61a1f8d5 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -16,43 +16,41 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear_card.php - * \brief Page to show info of a fiscal year + * \file htdocs/accountancy/admin/fiscalyear_card.php + * \brief Page to show info of a fiscal year */ - require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; - +require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; $langs->load("admin"); $langs->load("compta"); // Security check -if (! $user->admin) accessforbidden(); +if (! $user->admin) + accessforbidden(); -$id = GETPOST('id','int'); +$id = GETPOST('id', 'int'); // View llxHeader(); -if ($id) -{ +if ($id) { $object = new Fiscalyear($db); $object->fetch($id); $object->info($id); - + $head = fiscalyear_prepare_head($object); - + dol_fiche_head($head, 'info', $langs->trans("FiscalYearCard"), 0, 'cron'); - - print '
'; - dol_print_object_info($object); - print '
'; - - print '
'; + + print '
'; + dol_print_object_info($object); + print '
'; + + print ''; } llxFooter(); diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 7c38617d66c..15bd063bf9c 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -19,17 +19,16 @@ */ /** - * \file htdocs/accountancy/admin/importaccounts.php - * \ingroup Accounting Expert - * \brief Page import accounting account + * \file htdocs/accountancy/admin/importaccounts.php + * \ingroup Accounting Expert + * \brief Page import accounting account */ - require '../../main.inc.php'; - + // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; // langs $langs->load("compta"); @@ -38,8 +37,8 @@ $langs->load("main"); $langs->load("accountancy"); // Security check -if (!$user->admin) - accessforbidden(); +if (! $user->admin) + accessforbidden(); llxHeader('', $langs->trans("ImportAccount")); @@ -92,9 +91,9 @@ if ($_POST["action"] == 'import') { } /* -* list accounting account from product -* -*/ + * list accounting account from product + * + */ $page = GETPOST("page"); if ($page < 0) $page = 0; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 40dff028783..03cb46adf0d 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -23,16 +23,15 @@ */ /** - * \file htdocs/accountancy/admin/index.php - * \ingroup Accounting Expert - * \brief Setup page to configure accounting expert module + * \file htdocs/accountancy/admin/index.php + * \ingroup Accounting Expert + * \brief Setup page to configure accounting expert module */ - require '../../main.inc.php'; - + // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; $langs->load("compta"); $langs->load("bills"); @@ -40,16 +39,16 @@ $langs->load("admin"); $langs->load("accountancy"); // Security check -if (!$user->admin) - accessforbidden(); +if (! $user->admin) + accessforbidden(); $action = GETPOST('action', 'alpha'); // Other parameters ACCOUNTING_* $list = array ( 'ACCOUNTING_LIMIT_LIST_VENTILATION', - 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc - 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc + 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc + 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc 'ACCOUNTING_LENGTH_GACCOUNT', 'ACCOUNTING_LENGTH_AACCOUNT', 'ACCOUNTING_ACCOUNT_CUSTOMER', @@ -67,28 +66,27 @@ $list = array ( /* * Actions */ - -$accounting_mode = defined('ACCOUNTING_MODE')?ACCOUNTING_MODE:'RECETTES-DEPENSES'; -if ($action == 'update') -{ - $error = 0; +$accounting_mode = defined('ACCOUNTING_MODE') ? ACCOUNTING_MODE : 'RECETTES-DEPENSES'; - $accounting_modes = array( - 'RECETTES-DEPENSES', - 'CREANCES-DETTES' - ); - - $accounting_mode = GETPOST('accounting_mode','alpha'); +if ($action == 'update') { + $error = 0; - if (in_array($accounting_mode,$accounting_modes)) { - - if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } + $accounting_modes = array ( + 'RECETTES-DEPENSES', + 'CREANCES-DETTES' + ); + + $accounting_mode = GETPOST('accounting_mode', 'alpha'); + + if (in_array($accounting_mode, $accounting_modes)) { + + if (! dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } else { + $error ++; + } $chartofaccounts = GETPOST('chartofaccounts', 'int'); @@ -101,22 +99,19 @@ if ($action == 'update') $error ++; } - foreach ($list 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 - { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + foreach ( $list 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 { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } if ($action == 'setlistsorttodo') { @@ -152,14 +147,13 @@ llxHeader(); $form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans('ConfigAccountingExpert'),$linkback,'title_setup'); +$linkback = '' . $langs->trans("BackToModuleList") . ''; +print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); $head = admin_accounting_prepare_head($accounting); - -print '
'; -print ''; +print ''; +print ''; print ''; dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron'); @@ -169,24 +163,24 @@ print ''; // Cas du parametre ACCOUNTING_MODE print ''; -print ''; +print ''; print "\n"; -print ''; -print ''; +print '\n"; -print ''; -print '\n"; +print ''; +print '\n"; print "
'.$langs->trans('OptionMode').''.$langs->trans('Description').'' . $langs->trans('OptionMode') . '' . $langs->trans('Description') . '
'.$langs->trans('OptionModeTrue').''.nl2br($langs->trans('OptionModeTrueDesc')); +print '
' . $langs->trans('OptionModeTrue') . '' . nl2br($langs->trans('OptionModeTrueDesc')); // Write info on way to count VAT -//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) -//{ -// // print "
\n"; -// // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite')); -//} -//else -//{ -// // print "
\n"; -// // print nl2br($langs->trans('OptionModeTrueInfoExpert')); -//} +// if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) +// { +// // print "
\n"; +// // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite')); +// } +// else +// { +// // print "
\n"; +// // print nl2br($langs->trans('OptionModeTrueInfoExpert')); +// } print "
'.$langs->trans('OptionModeVirtual').''.nl2br($langs->trans('OptionModeVirtualDesc'))."
' . $langs->trans('OptionModeVirtual') . '' . nl2br($langs->trans('OptionModeVirtualDesc')) . "
\n"; @@ -246,19 +240,18 @@ print ''; print '' . $langs->trans('OtherOptions') . ''; print "\n"; -foreach ($list as $key) -{ - $var=!$var; - - print ''; - +foreach ( $list as $key ) { + $var = ! $var; + + print ''; + // Param - $label = $langs->trans($key); - print ''; - + $label = $langs->trans($key); + print ''; + // Value print ''; - print ''; + print ''; print ''; } @@ -294,7 +287,7 @@ print "\n"; dol_fiche_end(); -print '
'; +print '
'; print '
'; diff --git a/htdocs/accountancy/admin/journal.php b/htdocs/accountancy/admin/journal.php index 18f01abb082..e1b76273193 100644 --- a/htdocs/accountancy/admin/journal.php +++ b/htdocs/accountancy/admin/journal.php @@ -22,24 +22,23 @@ */ /** - * \file htdocs/accountancy/admin/journal.php - * \ingroup Accounting Expert - * \brief Setup page to configure accounting expert module + * \file htdocs/accountancy/admin/journal.php + * \ingroup Accounting Expert + * \brief Setup page to configure accounting expert module */ - require '../../main.inc.php'; - + // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $langs->load("accountancy"); // Security check -if (!$user->admin) - accessforbidden(); +if (! $user->admin) + accessforbidden(); $action = GETPOST('action', 'alpha'); @@ -49,7 +48,7 @@ $list = array ( 'ACCOUNTING_PURCHASE_JOURNAL', 'ACCOUNTING_SOCIAL_JOURNAL', 'ACCOUNTING_MISCELLANEOUS_JOURNAL', - 'ACCOUNTING_EXPENSEREPORT_JOURNAL' + 'ACCOUNTING_EXPENSEREPORT_JOURNAL' ); /* @@ -82,8 +81,8 @@ llxHeader(); $form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans('ConfigAccountingExpert'),$linkback,'title_setup'); +$linkback = '' . $langs->trans("BackToModuleList") . ''; +print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); $head = admin_accounting_prepare_head(null); @@ -115,10 +114,8 @@ foreach ( $list as $key ) { print "\n"; - print '
'; - print ''; print ''; print ''; @@ -126,39 +123,37 @@ print "\n"; // Bank account $sql = "SELECT rowid, label, accountancy_journal"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; -$sql.= " WHERE entity = ".$conf->entity; -$sql.= " AND clos = 0"; -$sql.= " ORDER BY label"; +$sql .= " FROM " . MAIN_DB_PREFIX . "bank_account"; +$sql .= " WHERE entity = " . $conf->entity; +$sql .= " AND clos = 0"; +$sql .= " ORDER BY label"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $numr = $db->num_rows($resql); $i = 0; - + if ($numr > 0) - - while ($i < $numr) - { - $objp = $db->fetch_object($resql); - $var = ! $var; - - print ''; - - // Param - print ''; - - // Value - print ''; - - $i++; - } -} -else dol_print_error($db); + while ( $i < $numr ) { + $objp = $db->fetch_object($resql); + + $var = ! $var; + + print ''; + + // Param + print ''; + + // Value + print ''; + + $i ++; + } +} else + dol_print_error($db); $db->free($resql); print "
' . $langs->trans('JournalFinancial') . '
'; - print ''; - print '
'; + print ''; + print '
\n"; @@ -169,6 +164,5 @@ print '
' . $langs->trans("Processing") . '...
'; if (! empty($chk_prod)) { @@ -110,11 +110,11 @@ if ($action == 'update') { $cpt = 0; foreach ( $chk_prod as $productid ) { - $accounting_account_id=GETPOST('codeventil_'.$productid); + $accounting_account_id = GETPOST('codeventil_' . $productid); - $result=$accounting->fetch($accounting_account_id,null,1); - if ($result<0) { - //setEventMessages(null, $accounting->errors, 'errors'); + $result = $accounting->fetch($accounting_account_id, null, 1); + if ($result < 0) { + // setEventMessages(null, $accounting->errors, 'errors'); $msg .= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '
' . $sql . '
'; } else { @@ -141,7 +141,6 @@ if ($action == 'update') { $msg .= '
' . $langs->trans("AnyLineVentilate") . '
'; } $msg .= '
' . $langs->trans("EndProcessing") . '
'; - } } @@ -240,8 +239,8 @@ if ($result) { $i = 0; /* - * View - */ + * View + */ print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); print '
'; @@ -359,7 +358,7 @@ if ($result) { // TODO: we shoul set a user defined value to adjust user square / wide screen size // $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; print ''; - print $form->select_account($compta_prodbuy_id, 'codeventil_'.$product_static->id, 1); + print $form->select_account($compta_prodbuy_id, 'codeventil_' . $product_static->id, 1); print ''; } else { @@ -369,7 +368,7 @@ if ($result) { // TODO: we shoul set a user defined value to adjust user square / wide screen size // $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; print ''; - print $form->select_account($compta_prodsell_id, 'codeventil_'.$product_static->id, 1); + print $form->select_account($compta_prodsell_id, 'codeventil_' . $product_static->id, 1); print ''; } diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index c1902c16fee..3404ddcc8df 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -20,16 +20,15 @@ */ /** - * \file htdocs/accountancy/bookkeeping/balancebymonth.php - * \ingroup Accounting Expert - * \brief Balance by month + * \file htdocs/accountancy/bookkeeping/balancebymonth.php + * \ingroup Accounting Expert + * \brief Balance by month */ - require '../../main.inc.php'; - + // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; // Langs $langs->load("main"); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 86aca8b8af4..c7d38ae3e17 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -18,15 +18,14 @@ */ /** - * \file htdocs/accountancy/bookkeeping/card.php - * \ingroup Accounting Expert - * \brief Page to show account + * \file htdocs/accountancy/bookkeeping/card.php + * \ingroup Accounting Expert + * \brief Page to show account */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; // Langs @@ -34,8 +33,9 @@ $langs->load("accountancy"); // Security check $id = GETPOST('id', 'int'); -if ($user->societe_id > 0) - accessforbidden(); +if ($user->societe_id > 0) { + accessforbidden(); +} $action = GETPOST('action'); $piece_num = GETPOST("piece_num"); @@ -44,150 +44,150 @@ $mesg = ''; $account_number = GETPOST('account_number'); $code_tiers = GETPOST('code_tiers'); -if ($code_tiers==-1) { - $code_tiers=null; +if ($code_tiers == - 1) { + $code_tiers = null; } $label_compte = GETPOST('label_compte'); $debit = price2num(GETPOST('debit')); $credit = price2num(GETPOST('credit')); -$save=GETPOST('save'); -if (!empty($save)) { - $action='add'; +$save = GETPOST('save'); +if (! empty($save)) { + $action = 'add'; } -$update=GETPOST('update'); -if (!empty($update)) { - $action='confirm_update'; +$update = GETPOST('update'); +if (! empty($update)) { + $action = 'confirm_update'; } if ($action == "confirm_update") { - - $error = 0; - - if ((floatval($debit)!=0.0) && (floatval($credit)!=0.0)) { - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $error ++; - } - - if (empty($error)) { - $book = new BookKeeping($db); - - $result = $book->fetch($id); - if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); - } else { - $book->numero_compte = $account_number; - $book->code_tiers = $code_tiers; - $book->label_compte = $label_compte; - $book->debit = $debit; - $book->credit = $credit; - - if (floatval($debit)!=0.0) { - $book->montant = $debit; - $book->sens = 'D'; - } - if (floatval($credit)!=0.0) { - $book->montant = $credit; - $book->sens = 'C'; - } - - $result = $book->update($user); - if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); - } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); - $action = ''; - } - } - } -} - -else if ($action == "add") { - $error = 0; - + + $error = 0; + if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); $error ++; } + + if (empty($error)) { + $book = new BookKeeping($db); + + $result = $book->fetch($id); + if ($result < 0) { + setEventMessages($book->error, $book->errors, 'errors'); + } else { + $book->numero_compte = $account_number; + $book->code_tiers = $code_tiers; + $book->label_compte = $label_compte; + $book->debit = $debit; + $book->credit = $credit; + + if (floatval($debit) != 0.0) { + $book->montant = $debit; + $book->sens = 'D'; + } + if (floatval($credit) != 0.0) { + $book->montant = $credit; + $book->sens = 'C'; + } + + $result = $book->update($user); + if ($result < 0) { + setEventMessages($book->error, $book->errors, 'errors'); + } else { + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + $action = ''; + } + } + } +} - if (empty($error)) { - $book = new BookKeeping($db); - +else if ($action == "add") { + $error = 0; + + if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); + $error ++; + } + + if (empty($error)) { + $book = new BookKeeping($db); + $book->numero_compte = $account_number; - $book->code_tiers = $code_tiers; - $book->label_compte = $label_compte; - $book->debit = $debit; - $book->credit = $credit; - $book->doc_date = GETPOST('doc_date'); - $book->doc_type = GETPOST('doc_type'); - $book->piece_num = $piece_num; - $book->doc_ref = GETPOST('doc_ref'); - $book->code_journal = GETPOST('code_journal'); - $book->fk_doc = GETPOST('fk_doc'); - $book->fk_docdet = GETPOST('fk_docdet'); - + $book->code_tiers = $code_tiers; + $book->label_compte = $label_compte; + $book->debit = $debit; + $book->credit = $credit; + $book->doc_date = GETPOST('doc_date'); + $book->doc_type = GETPOST('doc_type'); + $book->piece_num = $piece_num; + $book->doc_ref = GETPOST('doc_ref'); + $book->code_journal = GETPOST('code_journal'); + $book->fk_doc = GETPOST('fk_doc'); + $book->fk_docdet = GETPOST('fk_docdet'); + if (floatval($debit) != 0.0) { - $book->montant = $debit; - $book->sens = 'D'; - } + $book->montant = $debit; + $book->sens = 'D'; + } if (floatval($credit) != 0.0) { - $book->montant = $credit; - $book->sens = 'C'; - } - - $result = $book->createStd($user); - if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); - } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); - $action = ''; - } - } -} + $book->montant = $credit; + $book->sens = 'C'; + } + + $result = $book->create_std($user); + if ($result < 0) { + setEventMessages($book->error, $book->errors, 'errors'); + } else { + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + $action = ''; + } + } +} else if ($action == "confirm_delete") { - $book = new BookKeeping($db); - - $result = $book->fetch($id); - - $piece_num = $book->piece_num; - - if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); - } else { - $result = $book->delete($user); - if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); - } - } - $action = ''; -} + $book = new BookKeeping($db); + + $result = $book->fetch($id); + + $piece_num = $book->piece_num; + + if ($result < 0) { + setEventMessages($book->error, $book->errors, 'errors'); + } else { + $result = $book->delete($user); + if ($result < 0) { + setEventMessages($book->error, $book->errors, 'errors'); + } + } + $action = ''; +} else if ($action == "confirm_create") { - $book = new BookKeeping($db); - - $book->label_compte = ''; - $book->debit = 0; - $book->credit = 0; - $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); - $book->doc_type = GETPOST('doc_type'); - $book->piece_num = GETPOST('next_num_mvt'); - $book->doc_ref = GETPOST('doc_ref'); - $book->code_journal = GETPOST('code_journal'); - $book->fk_doc = 0; - $book->fk_docdet = 0; - - $book->montant = 0; - - $result = $book->createStd($user); - if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); - } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); - $action = ''; - $piece_num = $book->piece_num; - } + $book = new BookKeeping($db); + + $book->label_compte = ''; + $book->debit = 0; + $book->credit = 0; + $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); + $book->doc_type = GETPOST('doc_type'); + $book->piece_num = GETPOST('next_num_mvt'); + $book->doc_ref = GETPOST('doc_ref'); + $book->code_journal = GETPOST('code_journal'); + $book->fk_doc = 0; + $book->fk_docdet = 0; + + $book->montant = 0; + + $result = $book->create_std($user); + if ($result < 0) { + setEventMessages($book->error, $book->errors, 'errors'); + } else { + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + $action = ''; + $piece_num = $book->piece_num; + } } llxHeader(); @@ -199,115 +199,115 @@ $formventilation = new FormVentilation($db); * Confirmation to delete the command */ if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); - print $formconfirm; + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); + print $formconfirm; } if ($action == 'create') { - print load_fiche_titre($langs->trans("CreateMvts")); - - $code_journal_array = array ( - $conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL, - $conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL, - $conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL, - $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL => $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL, - $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL - ); - - $sql = 'SELECT DISTINCT accountancy_journal FROM '.MAIN_DB_PREFIX.'bank_account WHERE clos=0'; - $resql=$db->query($sql); - if (!$resql) { - setEventMessages($db->lasterror,null,'errors'); - } else { - while ($obj_bank=$db->fetch_object($resql)) { - if (!empty($obj_bank->accountancy_journal)) { - $code_journal_array[$obj_bank->accountancy_journal]=$obj_bank->accountancy_journal; - } - } - } - - $book = new BookKeeping($db); - $next_num_mvt = $book->getNextNumMvt(); - - print ''; - print '' . "\n"; - print '' . "\n"; - - dol_fiche_head(); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
' . $langs->trans("NumMvts") . '' . $next_num_mvt . '
' . $langs->trans("Docdate") . ''; - print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); - print '
' . $langs->trans("Codejournal") . '' . $html->selectarray('code_journal', $code_journal_array) . '
' . $langs->trans("Docref") . '
' . $langs->trans("Doctype") . '
'; - - dol_fiche_end(); - - print '
'; - print '     '; - print '
'; - - print '
'; + print load_fiche_titre($langs->trans("CreateMvts")); + + $code_journal_array = array ( + $conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL, + $conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL, + $conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL, + $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL => $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL, + $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL + ); + + $sql = 'SELECT DISTINCT accountancy_journal FROM ' . MAIN_DB_PREFIX . 'bank_account WHERE clos=0'; + $resql = $db->query($sql); + if (! $resql) { + setEventMessages($db->lasterror, null, 'errors'); + } else { + while ( $obj_bank = $db->fetch_object($resql) ) { + if (! empty($obj_bank->accountancy_journal)) { + $code_journal_array[$obj_bank->accountancy_journal] = $obj_bank->accountancy_journal; + } + } + } + + $book = new BookKeeping($db); + $next_num_mvt = $book->getNextNumMvt(); + + print '
'; + print '' . "\n"; + print '' . "\n"; + + dol_fiche_head(); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
' . $langs->trans("NumMvts") . '' . $next_num_mvt . '
' . $langs->trans("Docdate") . ''; + print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); + print '
' . $langs->trans("Codejournal") . '' . $html->selectarray('code_journal', $code_journal_array) . '
' . $langs->trans("Docref") . '
' . $langs->trans("Doctype") . '
'; + + dol_fiche_end(); + + print '
'; + print '     '; + print '
'; + + print '
'; } else { - $book = new BookKeeping($db); - $result = $book->fetchPerMvt($piece_num); - if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); - } - if (! empty($book->piece_num)) { - - print load_fiche_titre($langs->trans("UpdateMvts")); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
' . $langs->trans("NumMvts") . '' . $book->piece_num . '
' . $langs->trans("Docdate") . '' . dol_print_date($book->doc_date, 'daytextshort') . '
' . $langs->trans("Codejournal") . '' . $book->code_journal . '
' . $langs->trans("Docref") . '' . $book->doc_ref . '
' . $langs->trans("Doctype") . '' . $book->doc_type . '
'; - - $result = $book->fetch_all_per_mvt($piece_num); - if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); - } else { - - print load_fiche_titre($langs->trans("ListeMvts")); + $book = new BookKeeping($db); + $result = $book->fetch_per_mvt($piece_num); + if ($result < 0) { + setEventMessages($book->error, $book->errors, 'errors'); + } + if (! empty($book->piece_num)) { + + print load_fiche_titre($langs->trans("UpdateMvts"), '' . $langs->trans('BackToList') . ''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
' . $langs->trans("NumMvts") . '' . $book->piece_num . '
' . $langs->trans("Docdate") . '' . dol_print_date($book->doc_date, 'daytextshort') . '
' . $langs->trans("Codejournal") . '' . $book->code_journal . '
' . $langs->trans("Docref") . '' . $book->doc_ref . '
' . $langs->trans("Doctype") . '' . $book->doc_type . '
'; + + $result = $book->fetch_all_per_mvt($piece_num); + if ($result < 0) { + setEventMessages($book->error, $book->errors, 'errors'); + } else { + + print load_fiche_titre($langs->trans("ListeMvts")); print '
'; print '' . "\n"; @@ -317,101 +317,104 @@ if ($action == 'create') { print '' . "\n"; print '' . "\n"; - print ""; - if (count($book->linesmvt) > 0) { - - $total_debit=0; - $total_credit=0; + print "
"; + if (count($book->linesmvt) > 0) { - print ''; - - print_liste_field_titre($langs->trans("Numerocompte")); - print_liste_field_titre($langs->trans("Code_tiers")); - print_liste_field_titre($langs->trans("Labelcompte")); - print_liste_field_titre($langs->trans("Debit")); - print_liste_field_titre($langs->trans("Credit")); - print_liste_field_titre($langs->trans("Amount")); - print_liste_field_titre($langs->trans("Sens")); - print_liste_field_titre(''); - - print "\n"; - - foreach ( $book->linesmvt as $line ) { - $var = ! $var; - print ""; - - $total_debit+=$line->debit; - $total_credit+=$line->credit; + $total_debit = 0; + $total_credit = 0; + + print ''; + + print_liste_field_titre($langs->trans("Numerocompte")); + print_liste_field_titre($langs->trans("Code_tiers")); + print_liste_field_titre($langs->trans("Labelcompte")); + print_liste_field_titre($langs->trans("Debit")); + print_liste_field_titre($langs->trans("Credit")); + print_liste_field_titre($langs->trans("Amount")); + print_liste_field_titre($langs->trans("Sens")); + print_liste_field_titre(''); + + print "\n"; + + foreach ( $book->linesmvt as $line ) { + $var = ! $var; + print ""; - if ($action == 'update' && $line->id == $id) { - + $total_debit += $line->debit; + $total_credit += $line->credit; + if ($action == 'update' && $line->id == $id) { + print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - } else { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; + } else { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; - } - print "\n"; - } - - if ($total_debit!=$total_credit) { - setEventMessages(null, array('MvtNotCorrectlyBalanced',$total_credit,$total_debit),'errors'); + print img_delete(); + print ''; + + print ''; + } + print "\n"; } - if ($action == "" || $action == 'add') { - $var = ! $var; - print ""; + if ($total_debit != $total_credit) { + setEventMessages(null, array ( + 'MvtNotCorrectlyBalanced', + $total_credit, + $total_debit + ), 'errors'); + } + + if ($action == "" || $action == 'add') { + $var = ! $var; + print ""; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; - print ''; - } - print '
'; - print $formventilation->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1,''); + print $formventilation->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); print ''; - print $formventilation->select_auxaccount($line->code_tiers, 'code_tiers',1); + print $formventilation->select_auxaccount($line->code_tiers, 'code_tiers', 1); print '' . $line->montant . '' . $line->sens . ''; + print '' . $line->montant . '' . $line->sens . ''; print '' . "\n"; print ''; - print '' . $line->numero_compte . '' . $line->code_tiers . '' . $line->label_compte . '' . $line->debit . '' . $line->credit . '' . $line->montant . '' . $line->sens . ''; + print '' . $line->numero_compte . '' . $line->code_tiers . '' . $line->label_compte . '' . $line->debit . '' . $line->credit . '' . $line->montant . '' . $line->sens . ''; print ''; - print img_edit(); - print ' '; + print img_edit(); + print ' '; print ''; - print img_delete(); - print ''; - - print '
'; print $formventilation->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); print ''; - print $formventilation->select_auxaccount($code_tiers, 'code_tiers',1); + print $formventilation->select_auxaccount($code_tiers, 'code_tiers', 1); print '
'; - print '
'; - } - } - } else { - print load_fiche_titre($langs->trans("NoRecords")); - } + print ''; + } + print ''; + print ''; + } + } + } else { + print load_fiche_titre($langs->trans("NoRecords")); + } } llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index c517df2d129..d6925ac1995 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -46,10 +46,10 @@ $search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST( $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")) { - $action='delbookkeepingyear'; + $action = 'delbookkeepingyear'; } if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { - $action='export_csv'; + $action = 'export_csv'; } $search_accountancy_code = GETPOST("search_accountancy_code"); @@ -79,8 +79,6 @@ $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; - - $offset = $limit * $page; $object = new BookKeeping($db); @@ -114,9 +112,8 @@ if (empty($search_date_start)) { } if ($sortorder == "") $sortorder = "ASC"; - if ($sortfield == "") - $sortfield = "t.rowid"; - +if ($sortfield == "") + $sortfield = "t.rowid"; $options = ''; $filter = array (); @@ -181,7 +178,6 @@ if (! empty($search_mvt_num)) { $options .= '&search_mvt_num=' . $search_mvt_num; } - /* * Action */ @@ -218,18 +214,18 @@ if ($action == 'delbookkeeping') { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - //if (!empty($options)) { - // Header("Location: list.php?".urldecode($options)); - //} else { - Header("Location: list.php"); - //} + // if (!empty($options)) { + // Header("Location: list.php?".urldecode($options)); + // } else { + Header("Location: list.php"); + // } exit(); } } elseif ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = 'bookkepping'; - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); if ($result < 0) { @@ -237,32 +233,30 @@ if ($action == 'delbookkeeping') { } foreach ( $object->lines as $line ) { - - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) - { + + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; // Model Cegid Expert Export $date = dol_print_date($line->doc_date, '%d%m%Y'); print $date . $sep; print $line->code_journal . $sep; print length_accountg($line->numero_compte) . $sep; - print ' '. $sep; + print ' ' . $sep; print $line->sens . $sep; print price($line->montant) . $sep; print dol_trunc($line->label_compte, 32) . $sep; print $line->doc_ref . $sep; /*print $line->piece_num . $sep; - print length_accounta($line->code_tiers) . $sep; - print . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep;*/ + print length_accounta($line->code_tiers) . $sep; + print . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep;*/ print "\n"; - } - elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { - //Std export + // Std export $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); print $date . $sep; print $line->doc_ref . $sep; @@ -272,14 +266,14 @@ if ($action == 'delbookkeeping') { print price($line->credit) . $sep; /*print $line->piece_num . $sep; - print $line->label_compte . $sep; - print price($line->montant) . $sep; - print $line->sens . $sep;*/ + print $line->label_compte . $sep; + print price($line->montant) . $sep; + print $line->sens . $sep;*/ print $line->code_journal . $sep; print "\n"; - }elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { - //Coala export + // Coala export $date = dol_print_date($line->doc_date, '%d/%m/%Y'); print $date . $sep; print $line->code_journal . $sep; @@ -297,7 +291,7 @@ if ($action == 'delbookkeeping') { else { - $title_page=$langs->trans("Bookkeeping") .' '. dol_print_date($search_date_start).'-'.dol_print_date($search_date_end); + $title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); llxHeader('', $title_page); @@ -324,15 +318,21 @@ else { } if ($action == 'delbookkeepingyear') { - $form_question=array(); - $delyear=GETPOST('delyear'); + $form_question = array (); + $delyear = GETPOST('delyear'); if (empty($delyear)) { - $delyear=dol_print_date(dol_now(),'%Y'); + $delyear = dol_print_date(dol_now(), '%Y'); } - $year_array=$formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear',0,'array'); + $year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $form_question['delyear']=array('name'=>'delyear','type'=>'select','label'=>$langs->trans('DelYear'),'values'=>$year_array,'default'=>$delyear); + $form_question['delyear'] = array ( + 'name' => 'delyear', + 'type' => 'select', + 'label' => $langs->trans('DelYear'), + 'values' => $year_array, + 'default' => $delyear + ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); print $formconfirm; @@ -351,33 +351,32 @@ else { print '';*/ print '
'; - print '
'."\n"; + print '
' . "\n"; print '
'; print '' . $langs->trans("NewAccountingMvt") . ''; - //print '' . $langs->trans("Export") . ''; + // print '' . $langs->trans("Export") . ''; print '
'; print '
'; - /*print '
'; - print $langs->trans('DateStart') . ': '; - print $form->select_date($search_date_start, 'date_start', 0, 0, 1); - print $langs->trans('DateEnd') . ': '; - print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - print '
'; - print '
'; - print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; - print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; - print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); - print '
'; - print '
'; - print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); - print '
';*/ + print $langs->trans('DateStart') . ': '; + print $form->select_date($search_date_start, 'date_start', 0, 0, 1); + print $langs->trans('DateEnd') . ': '; + print $form->select_date($search_date_end, 'date_end', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; + print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); + print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; + print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); + print '
'; + print '
'; + print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); + print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); + print '
';*/ print ''; print ''; @@ -389,8 +388,8 @@ else { print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); - //print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); - //print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder); + // print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); + // print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; @@ -404,37 +403,37 @@ else { print '
'; print $langs->trans('To') . ': '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - //print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1); + // print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1); print ''; print ''; print ''; - //print ''; + // print ''; print ''; - //print ''; + // print ''; print ''; print ''; print ''; - //print ''; - //print ''; + // print ''; + // print ''; print ''; print '"; @@ -465,12 +464,12 @@ else { print ''; print ''; print ''; - //print ''; - //print ''; + // print ''; + // print ''; print ''; print ''; print "\n"; } diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index ea766c16ef9..002d5670a0c 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -40,30 +40,30 @@ $sortfield = GETPOST("sortfield"); $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); -$search_doc_type=GETPOST('search_doc_type','alpha'); -$search_doc_date=dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); -$search_doc_ref=GETPOST('search_doc_ref','alpha'); -$search_numero_compte=GETPOST('search_numero_compte','alpha'); -$search_numero_compte_start=GETPOST('search_numero_compte_start','alpha'); -if ($search_numero_compte_start==-1) { - $search_numero_compte_start=''; +$search_doc_type = GETPOST('search_doc_type', 'alpha'); +$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); +$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); +$search_numero_compte = GETPOST('search_numero_compte', 'alpha'); +$search_numero_compte_start = GETPOST('search_numero_compte_start', 'alpha'); +if ($search_numero_compte_start == - 1) { + $search_numero_compte_start = ''; } -$search_numero_compte_end=GETPOST('search_numero_compte_end','alpha'); -if ($search_numero_compte_end==-1) { - $search_numero_compte_end=''; +$search_numero_compte_end = GETPOST('search_numero_compte_end', 'alpha'); +if ($search_numero_compte_end == - 1) { + $search_numero_compte_end = ''; } -$search_code_tiers=GETPOST('search_code_tiers','alpha'); -$search_code_tiers_start=GETPOST('search_code_tiers_start','alpha'); -if ($search_code_tiers_start==-1) { - $search_code_tiers_start=''; +$search_code_tiers = GETPOST('search_code_tiers', 'alpha'); +$search_code_tiers_start = GETPOST('search_code_tiers_start', 'alpha'); +if ($search_code_tiers_start == - 1) { + $search_code_tiers_start = ''; } -$search_code_tiers_end=GETPOST('search_code_tiers_end','alpha'); -if ($search_code_tiers_end==-1) { - $search_code_tiers_end=''; +$search_code_tiers_end = GETPOST('search_code_tiers_end', 'alpha'); +if ($search_code_tiers_end == - 1) { + $search_code_tiers_end = ''; } -$search_label_compte=GETPOST('search_label_compte','alpha'); -$search_sens=GETPOST('search_sens','alpha'); -$search_code_journal=GETPOST('search_code_journal','alpha'); +$search_label_compte = GETPOST('search_label_compte', 'alpha'); +$search_sens = GETPOST('search_sens', 'alpha'); +$search_code_journal = GETPOST('search_code_journal', 'alpha'); $object = new BookKeeping($db); $form = new Form($db); @@ -171,7 +171,7 @@ if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } -print_barre_liste($langs->trans("Bookkeeping") .' '. dol_print_date($search_date_start).'-'.dol_print_date($search_date_end), $page, $_SERVER['PHP_SELF'], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); +print_barre_liste($langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end), $page, $_SERVER['PHP_SELF'], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); print ''; print '
'; @@ -181,16 +181,16 @@ print $langs->trans('DateEnd') . ': '; print $form->select_date($search_date_end, 'date_end'); print '
'; print '
'; -print $langs->trans('From').' '.$langs->trans('AccountAccounting') . ': '; -print $formventilation->select_account($search_numero_compte_start,'search_numero_compte_start', 1, array (), 1, 1,''); -print $langs->trans('To').' '.$langs->trans('AccountAccounting') . ': '; -print $formventilation->select_account($search_numero_compte_end,'search_numero_compte_end', 1, array (), 1, 1,''); +print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; +print $formventilation->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, ''); +print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; +print $formventilation->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, ''); print '
'; print '
'; -print $langs->trans('From').' '.$langs->trans('ThirdPartyAccount') . ': '; -print $formventilation->select_auxaccount($search_code_tiers_start,'search_code_tiers_start', 1); -print $langs->trans('To').' '.$langs->trans('ThirdPartyAccount') . ': '; -print $formventilation->select_auxaccount($search_code_tiers_end,'searchcode_tiers_end', 1); +print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; +print $formventilation->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1); +print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; +print $formventilation->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1); print '
'; print "
'; - //print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; + // print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; print $langs->trans('From'); print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - //print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; + // print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; print '
'; print $langs->trans('To'); print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); print '
'; - //print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + // print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print $langs->trans('From'); print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - //print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + // print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print '
'; print $langs->trans('To'); print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); print '
'; - print ''; + print ''; print '      '; print ''; @@ -446,14 +445,14 @@ else { $var = True; - $total_debit=0; - $total_credit=0; + $total_debit = 0; + $total_credit = 0; foreach ( $object->lines as $line ) { $var = ! $var; - $total_debit+=$line->debit; - $total_credit+=$line->credit; + $total_debit += $line->debit; + $total_credit += $line->credit; print "
' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->montant) . '' . $line->sens . '' . price($line->montant) . '' . $line->sens . '' . $line->code_journal . ''; print '' . img_edit() . ''; - print '' . img_delete() . ''; + print '' . img_delete() . ''; print '
"; @@ -213,31 +213,31 @@ print "\n"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; + $var = ! $var; + print ''; print ''; print ''; print ''; @@ -242,10 +241,10 @@ $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); - + while ( $i < $num ) { $row = $db->fetch_row($resql); - + print ''; print ''; print ''; @@ -286,7 +285,7 @@ if (! empty($conf->margin->enabled)) { print ''; print ''; print ''; - + $sql = "SELECT '" . $langs->trans("Vide") . "' AS 'Marge',"; $sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Janvier',"; $sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Fevrier',"; @@ -305,7 +304,7 @@ if (! empty($conf->margin->enabled)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - + if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")"; } @@ -315,10 +314,10 @@ if (! empty($conf->margin->enabled)) { if ($resql) { $i = 0; $num = $db->num_rows($resql); - + while ( $i < $num ) { $row = $db->fetch_row($resql); - + print ''; print ''; print ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 3c899fcdd85..0d5dbc35668 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -21,17 +21,16 @@ */ /** - * \file htdocs/accountancy/customer/lines.php - * \ingroup Accounting Expert - * \brief Page of detail of the lines of ventilation of invoices customers + * \file htdocs/accountancy/customer/lines.php + * \ingroup Accounting Expert + * \brief Page of detail of the lines of ventilation of invoices customers */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; // Langs $langs->load("bills"); @@ -40,35 +39,36 @@ $langs->load("main"); $langs->load("accountancy"); $account_parent = GETPOST('account_parent'); -$changeaccount = GETPOST('changeaccount'); -//Search Getpost -$search_ref = GETPOST('search_ref','alpha'); -$search_invoice = GETPOST('search_invoice','alpha'); -$search_label = GETPOST('search_label','alpha'); -$search_desc = GETPOST('search_desc','alpha'); -$search_amount = GETPOST('search_amount','alpha'); -$search_account = GETPOST('search_account','alpha'); -$search_vat = GETPOST('search_vat','alpha'); +$changeaccount = GETPOST('changeaccount'); +// Search Getpost +$search_ref = GETPOST('search_ref', 'alpha'); +$search_invoice = GETPOST('search_invoice', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_account = GETPOST('search_account', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); -//Getpost Order and column and limit page -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); -if ($page < 0) $page = 0; +// Getpost Order and column and limit page +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if ($page < 0) + $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; } else { - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; } $offset = $limit * $page; - -if (! $sortfield) $sortfield="f.datef, f.facnumber, l.rowid"; +if (! $sortfield) + $sortfield = "f.datef, f.facnumber, l.rowid"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { @@ -87,13 +87,13 @@ $formventilation = new FormVentilation($db); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { - $search_ref=''; - $search_invoice=''; - $search_label=''; - $search_desc=''; - $search_amount=''; - $search_account=''; - $search_vat=''; + $search_ref = ''; + $search_invoice = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -126,7 +126,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched")); -print ''; - + /* * Show result array */ print '

'; - + $i = 0; print "
'; -print ''; +print ''; print ''; -print ''; +print ''; print ''; -print $form->select_date($search_doc_date,'doc_date',0, 0, 1); +print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1); print ''; -print ''; +print ''; print ''; -print ''; +print ''; print ''; -print ''; +print ''; print ''; -print ''; +print ''; print ''; @@ -250,11 +250,11 @@ print ''; print ''; -print ''; +print ''; print ''; -print ''; +print ''; print ''; diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 86c2e5ed3f2..8a6e1d239d8 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/accountancy/class/accountancysystem.class.php - * \ingroup Accounting Expert - * \brief File of class to manage accountancy systems + * \file htdocs/accountancy/class/accountancysystem.class.php + * \ingroup Accounting Expert + * \brief File of class to manage accountancy systems */ /** @@ -37,7 +37,7 @@ class AccountancySystem var $label; var $account_number; var $account_parent; - + /** * Constructor * @@ -46,7 +46,7 @@ class AccountancySystem function __construct($db) { $this->db = $db; } - + /** * Insert accountancy system name into database * @@ -55,16 +55,16 @@ class AccountancySystem */ function create($user) { $now = dol_now(); - + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system"; $sql .= " (date_creation, fk_user_author, numero, label)"; $sql .= " VALUES (" . $this->db->idate($now) . "," . $user->id . ",'" . $this->numero . "','" . $this->label . "')"; - + dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system"); - + if ($id > 0) { $this->rowid = $id; $result = $this->rowid; @@ -78,7 +78,7 @@ class AccountancySystem $this->error = "AccountancySystem::Create Erreur $result"; dol_syslog($this->error, LOG_ERR); } - + return $result; } } \ No newline at end of file diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 856306c3304..df45f027259 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/accountancy/class/accountingaccount.class.php - * \ingroup Accounting Expert - * \brief Fichier de la classe des comptes comptable + * \file htdocs/accountancy/class/accountingaccount.class.php + * \ingroup Accounting Expert + * \brief Fichier de la classe des comptes comptable */ /** @@ -33,10 +33,8 @@ class AccountingAccount extends CommonObject var $db; var $error; var $errors; - var $id; var $rowid; - var $datec; // Creation date var $fk_pcg_version; var $pcg_type; @@ -47,45 +45,43 @@ class AccountingAccount extends CommonObject var $fk_user_author; var $fk_user_modif; var $active; - + /** * Constructor * - * @param DoliDB $db Database handle + * @param DoliDB $db Database handle */ - function __construct($db) - { + function __construct($db) { $this->db = $db; } - + /** * Load record in memory * - * @param int $rowid Id - * @param string $account_number Account number - * @param int $limittocurentchart 1=Do not load record if it is into another accounting system - * @return int <0 if KO, >0 if OK + * @param int $rowid Id + * @param string $account_number Account number + * @param int $limittocurentchart 1=Do not load record if it is into another accounting system + * @return int <0 if KO, >0 if OK */ - function fetch($rowid = null, $account_number = null, $limittocurentchart=0) - { + function fetch($rowid = null, $account_number = null, $limittocurentchart = 0) { global $conf; - + if ($rowid || $account_number) { $sql = "SELECT rowid, datec, tms, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, fk_user_author, fk_user_modif, active"; - $sql.= " FROM " . MAIN_DB_PREFIX . "accounting_account WHERE"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account WHERE"; if ($rowid) { $sql .= " rowid = '" . $rowid . "'"; } elseif ($account_number) { $sql .= " account_number = '" . $account_number . "'"; } - if (!empty($limittocurentchart)) { - $sql .=' AND fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; + if (! empty($limittocurentchart)) { + $sql .= ' AND fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; } dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - + if ($obj) { $this->id = $obj->rowid; $this->rowid = $obj->rowid; @@ -100,32 +96,31 @@ class AccountingAccount extends CommonObject $this->fk_user_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; $this->active = $obj->active; - + return $this->id; } else { return 0; } } else { - $this->error="Error " . $this->db->lasterror(); + $this->error = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror(); } } - return -1; + return - 1; } - + /** * Insert line in accounting_account * - * @param User $user Use making action - * @param int $notrigger Disable triggers - * @return int <0 if KO, >0 if OK + * @param User $user Use making action + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) - { + function create($user, $notrigger = 0) { global $conf; $error = 0; $now = dol_now(); - + // Clean parameters if (isset($this->fk_pcg_version)) $this->fk_pcg_version = trim($this->fk_pcg_version); @@ -143,13 +138,13 @@ class AccountingAccount extends CommonObject $this->fk_user_author = trim($this->fk_user_author); if (isset($this->active)) $this->active = trim($this->active); - - // Check parameters - // Put here code to add control on parameters values - + + // Check parameters + // Put here code to add control on parameters values + // Insert request $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account("; - + $sql .= "datec"; $sql .= ", entity"; $sql .= ", fk_pcg_version"; @@ -160,9 +155,9 @@ class AccountingAccount extends CommonObject $sql .= ", label"; $sql .= ", fk_user_author"; $sql .= ", active"; - + $sql .= ") VALUES ("; - + $sql .= " '" . $this->db->idate($now) . "'"; $sql .= ", " . $conf->entity; $sql .= ", " . (! isset($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); @@ -173,34 +168,34 @@ class AccountingAccount extends CommonObject $sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); $sql .= ", " . $user->id; $sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'"); - + $sql .= ")"; - + $this->db->begin(); - + dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = "Error " . $this->db->lasterror(); } - + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_account"); - -// if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers -// } + + // if (! $notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + // // Call triggers + // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + // $interface=new Interfaces($this->db); + // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + // if ($result < 0) { $error++; $this->errors=$interface->errors; } + // // End call triggers + // } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -214,17 +209,16 @@ class AccountingAccount extends CommonObject return $this->id; } } - + /** * Update record * - * @param User $user Use making update - * @return int <0 if KO, >0 if OK + * @param User $user Use making update + * @return int <0 if KO, >0 if OK */ - function update($user) - { + function update($user) { $this->db->begin(); - + $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; $sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null"); $sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null"); @@ -234,9 +228,9 @@ class AccountingAccount extends CommonObject $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null"); $sql .= " , fk_user_modif = " . $user->id; $sql .= " , active = '" . $this->active . "'"; - + $sql .= " WHERE rowid = " . $this->id; - + dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -248,25 +242,24 @@ class AccountingAccount extends CommonObject return - 1; } } - + /** * Check usage of accounting code * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ - function checkUsage() - { + function checkUsage() { global $langs; - + $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; $sql .= "UNION"; $sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; - + dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); - + if ($resql) { $num = $this->db->num_rows($resql); if ($num > 0) { @@ -280,42 +273,41 @@ class AccountingAccount extends CommonObject return - 1; } } - + /** * Delete object in database * - * @param User $user User that deletes - * @param int $notrigger 0=triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK + * @param User $user User that deletes + * @param int $notrigger 0=triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) - { + function delete($user, $notrigger = 0) { $error = 0; - + $result = $this->checkUsage(); - + if ($result > 0) { - + $this->db->begin(); - -// if (! $error) { -// if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('ACCOUNTANCY_ACCOUNT_DELETE',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers -// } -// } - + + // if (! $error) { + // if (! $notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + // // Call triggers + // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + // $interface=new Interfaces($this->db); + // $result=$interface->run_triggers('ACCOUNTANCY_ACCOUNT_DELETE',$this,$user,$langs,$conf); + // if ($result < 0) { $error++; $this->errors=$interface->errors; } + // // End call triggers + // } + // } + if (! $error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account"; $sql .= " WHERE rowid=" . $this->id; - + dol_syslog(get_class($this) . "::delete sql=" . $sql); $resql = $this->db->query($sql); if (! $resql) { @@ -323,7 +315,7 @@ class AccountingAccount extends CommonObject $this->errors[] = "Error " . $this->db->lasterror(); } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -340,47 +332,48 @@ class AccountingAccount extends CommonObject return - 1; } } - + /** - * Return clicable name (with picto eventually) + * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @return string Chaine avec URL */ - function getNomUrl($withpicto=0) - { + function getNomUrl($withpicto = 0) { global $langs; - - $result=''; - - $link = ''; - $linkend=''; - - $picto='billr'; - - $label=$langs->trans("Show").': '.$this->account_number.' - '.$this->label; - - if ($withpicto) $result.=($link.img_object($label,$picto).$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.$this->account_number.$linkend; + + $result = ''; + + $link = ''; + $linkend = ''; + + $picto = 'billr'; + + $label = $langs->trans("Show") . ': ' . $this->account_number . ' - ' . $this->label; + + if ($withpicto) + $result .= ($link . img_object($label, $picto) . $linkend); + if ($withpicto && $withpicto != 2) + $result .= ' '; + if ($withpicto != 2) + $result .= $link . $this->account_number . $linkend; return $result; } - + /** * Information on record * * @param int $id of record * @return void */ - function info($id) - { + function info($id) { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a'; $sql .= ' WHERE a.rowid = ' . $id; - + dol_syslog(get_class($this) . '::info sql=' . $sql); $result = $this->db->query($sql); - + if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); @@ -403,27 +396,26 @@ class AccountingAccount extends CommonObject dol_print_error($this->db); } } - + /** * Account desactivate * - * @param int $id Id - * @return int <0 if KO, >0 if OK + * @param int $id Id + * @return int <0 if KO, >0 if OK */ - function account_desactivate($id) - { + function account_desactivate($id) { $result = $this->checkUsage(); - + if ($result > 0) { $this->db->begin(); - + $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; $sql .= "SET active = '0'"; - $sql .= " WHERE rowid = ".$this->db->escape($id); - + $sql .= " WHERE rowid = " . $this->db->escape($id); + dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); - + if ($result) { $this->db->commit(); return 1; @@ -436,21 +428,20 @@ class AccountingAccount extends CommonObject return - 1; } } - + /** * Account activate * - * @param int $id Id - * @return int <0 if KO, >0 if OK + * @param int $id Id + * @return int <0 if KO, >0 if OK */ - function account_activate($id) - { + function account_activate($id) { $this->db->begin(); - + $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; $sql .= "SET active = '1'"; - $sql .= " WHERE rowid = ".$this->db->escape($id); - + $sql .= " WHERE rowid = " . $this->db->escape($id); + dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 58c13686d1c..c4a277ec8a1 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -218,7 +218,7 @@ class BookKeeping extends CommonObject $this->date_create = $now; } - $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element." ("; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; $sql .= "doc_date"; $sql .= ", doc_type"; @@ -291,7 +291,6 @@ class BookKeeping extends CommonObject dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - if (! $error) { if (! $notrigger) { @@ -320,19 +319,18 @@ class BookKeeping extends CommonObject /** * Create object into database * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * * @return int <0 if KO, Id of created object if OK */ - public function createStd(User $user, $notrigger = false) - { + public function createStd(User $user, $notrigger = false) { dol_syslog(__METHOD__, LOG_DEBUG); - + $error = 0; - + // Clean parameters - + if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); } @@ -378,86 +376,82 @@ class BookKeeping extends CommonObject if (isset($this->piece_num)) { $this->piece_num = trim($this->piece_num); } - - - + // Check parameters // Put here code to add control on parameters values - + // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - - $sql.= 'doc_date,'; - $sql.= 'doc_type,'; - $sql.= 'doc_ref,'; - $sql.= 'fk_doc,'; - $sql.= 'fk_docdet,'; - $sql.= 'code_tiers,'; - $sql.= 'numero_compte,'; - $sql.= 'label_compte,'; - $sql.= 'debit,'; - $sql.= 'credit,'; - $sql.= 'montant,'; - $sql.= 'sens,'; - $sql.= 'fk_user_author,'; - $sql.= 'import_key,'; - $sql.= 'code_journal,'; - $sql.= 'piece_num'; - - + + $sql .= 'doc_date,'; + $sql .= 'doc_type,'; + $sql .= 'doc_ref,'; + $sql .= 'fk_doc,'; + $sql .= 'fk_docdet,'; + $sql .= 'code_tiers,'; + $sql .= 'numero_compte,'; + $sql .= 'label_compte,'; + $sql .= 'debit,'; + $sql .= 'credit,'; + $sql .= 'montant,'; + $sql .= 'sens,'; + $sql .= 'fk_user_author,'; + $sql .= 'import_key,'; + $sql .= 'code_journal,'; + $sql .= 'piece_num'; + $sql .= ') VALUES ('; - - $sql .= ' '.(! isset($this->doc_date) || dol_strlen($this->doc_date)==0?'NULL':"'".$this->db->idate($this->doc_date)."'").','; - $sql .= ' '.(! isset($this->doc_type)?'NULL':"'".$this->db->escape($this->doc_type)."'").','; - $sql .= ' '.(! isset($this->doc_ref)?'NULL':"'".$this->db->escape($this->doc_ref)."'").','; - $sql .= ' '.(empty($this->fk_doc)?'0':$this->fk_doc).','; - $sql .= ' '.(empty($this->fk_docdet)?'0':$this->fk_docdet).','; - $sql .= ' '.(! isset($this->code_tiers)?'NULL':"'".$this->db->escape($this->code_tiers)."'").','; - $sql .= ' '.(! isset($this->numero_compte)?'NULL':"'".$this->db->escape($this->numero_compte)."'").','; - $sql .= ' '.(! isset($this->label_compte)?'NULL':"'".$this->db->escape($this->label_compte)."'").','; - $sql .= ' '.(! isset($this->debit)?'NULL':"'".$this->debit."'").','; - $sql .= ' '.(! isset($this->credit)?'NULL':"'".$this->credit."'").','; - $sql .= ' '.(! isset($this->montant)?'NULL':"'".$this->montant."'").','; - $sql .= ' '.(! isset($this->sens)?'NULL':"'".$this->db->escape($this->sens)."'").','; - $sql .= ' '.$user->id.','; - $sql .= ' '.(! isset($this->import_key)?'NULL':"'".$this->db->escape($this->import_key)."'").','; - $sql .= ' '.(! isset($this->code_journal)?'NULL':"'".$this->db->escape($this->code_journal)."'").','; - $sql .= ' '.(! isset($this->piece_num)?'NULL':$this->piece_num); - - + + $sql .= ' ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'" . $this->db->idate($this->doc_date) . "'") . ','; + $sql .= ' ' . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ','; + $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; + $sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ','; + $sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ','; + $sql .= ' ' . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ','; + $sql .= ' ' . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ','; + $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; + $sql .= ' ' . (! isset($this->debit) ? 'NULL' : "'" . $this->debit . "'") . ','; + $sql .= ' ' . (! isset($this->credit) ? 'NULL' : "'" . $this->credit . "'") . ','; + $sql .= ' ' . (! isset($this->montant) ? 'NULL' : "'" . $this->montant . "'") . ','; + $sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ','; + $sql .= ' ' . $user->id . ','; + $sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ','; + $sql .= ' ' . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; + $sql .= ' ' . (! isset($this->piece_num) ? 'NULL' : $this->piece_num); + $sql .= ')'; - + $this->db->begin(); - + $resql = $this->db->query($sql); - if (!$resql) { + if (! $resql) { $error ++; $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - - if (!$error) { + + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - - if (!$notrigger) { + + if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_CREATE',$user); - //if ($result < 0) $error++; - //// End call triggers + + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_CREATE',$user); + // if ($result < 0) $error++; + // // End call triggers } } - + // Commit or rollback if ($error) { $this->db->rollback(); - + return - 1 * $error; } else { $this->db->commit(); - + return $this->id; } } @@ -581,11 +575,11 @@ class BookKeeping extends CommonObject $sqlwhere = array (); if (count($filter) > 0) { foreach ( $filter as $key => $value ) { - if ($key=='t.doc_date') { + if ($key == 't.doc_date') { $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; - } elseif($key=='t.doc_date>=' || $key=='t.doc_date<=') { + } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif($key=='t.fk_doc' || $key=='t.fk_docdet' ||$key=='t.piece_num') { + } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; @@ -815,19 +809,19 @@ class BookKeeping extends CommonObject /** * Delete bookkepping by importkey * - * @param string $importkey Import key - * @return int Result + * @param string $importkey Import key + * @return int Result */ function deleteByImportkey($importkey) { $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE import_key = '" . $importkey . "'"; - + $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); foreach ( $this->errors as $errmsg ) { @@ -837,7 +831,7 @@ class BookKeeping extends CommonObject $this->db->rollback(); return - 1; } - + $this->db->commit(); return 1; } @@ -845,19 +839,19 @@ class BookKeeping extends CommonObject /** * Delete bookkepping by year * - * @param string $delyear year to delete - * @return int Result + * @param string $delyear year to delete + * @return int Result */ function deleteByYear($delyear) { $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE YEAR(doc_date) = ".$delyear; - + $sql .= " WHERE YEAR(doc_date) = " . $delyear; + $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); foreach ( $this->errors as $errmsg ) { @@ -867,7 +861,7 @@ class BookKeeping extends CommonObject $this->db->rollback(); return - 1; } - + $this->db->commit(); return 1; } @@ -875,19 +869,19 @@ class BookKeeping extends CommonObject /** * Delete bookkepping by piece number * - * @param int $piecenum peicenum to delete - * @return int Result + * @param int $piecenum peicenum to delete + * @return int Result */ function deleteMvtNum($piecenum) { $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE piece_num = ".$piecenum; - + $sql .= " WHERE piece_num = " . $piecenum; + $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); foreach ( $this->errors as $errmsg ) { @@ -897,7 +891,7 @@ class BookKeeping extends CommonObject $this->db->rollback(); return - 1; } - + $this->db->commit(); return 1; } @@ -997,7 +991,7 @@ class BookKeeping extends CommonObject $this->doc_type = $obj->doc_type; } else { $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::".__METHOD__ . $this->error, LOG_ERR); + dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); return - 1; } @@ -1079,30 +1073,29 @@ class BookKeeping extends CommonObject /** * Export bookkeping * - * @param string $model Model - * @return int Result + * @param string $model Model + * @return int Result */ - function export_bookkeping($model = 'ebp') - { + function export_bookkeping($model = 'ebp') { $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - + dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); - + $resql = $this->db->query($sql); - + if ($resql) { $this->linesexport = array (); - + $num = $this->db->num_rows($resql); while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -1117,15 +1110,13 @@ class BookKeeping extends CommonObject $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->linesexport[] = $line; } $this->db->free($resql); - + return $num; - } - else - { + } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::export_bookkeping " . $this->error, LOG_ERR); return - 1; diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index f2fb6caea48..a3dad82a035 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -19,57 +19,57 @@ */ /** - * \file htdocs/accountancy/class/html.formventilation.class.php - * \ingroup Accounting Expert - * \brief File of class with all html predefined components + * \file htdocs/accountancy/class/html.formventilation.class.php + * \ingroup Accounting Expert + * \brief File of class with all html predefined components */ /** - * Class to manage generation of HTML components for bank module + * Class to manage generation of HTML components for bank module */ class FormVentilation extends Form { var $db; var $error; - + /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) { - $this->db = $db; - } - - /** - * Return select filter with date of transaction + * Constructor * - * @param string $htmlname Name of select field - * @param string $selectedkey Value - * @return string HTML edit field + * @param DoliDB $db Database handler + */ + public function __construct($db) { + $this->db = $db; + } + + /** + * Return select filter with date of transaction + * + * @param string $htmlname Name of select field + * @param string $selectedkey Value + * @return string HTML edit field */ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') { - $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; + $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; $sql .= ' ORDER BY import_key DESC'; - + $out = ''; - + return $out; } - + /** - * Return list of accounts with label by chart of accounts + * Return list of accounts with label by chart of accounts * - * @param string $selectid Preselected chart of accounts - * @param string $htmlname Name of field in html form - * @param int $showempty Add an empty field - * @param array $event Event options - * @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1) - * @param int $select_out set value returned by select 0=rowid (default), 1=account_number + * @param string $selectid Preselected chart of accounts + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param array $event Event options + * @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1) + * @param int $select_out set value returned by select 0=rowid (default), 1=account_number * @param int $aabase set accountingaccount base class to display empty=all or from 1 to 8 will display only account beginning by - * - * @return string String with HTML select + * + * @return string String with HTML select */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { global $conf; - + $out = ''; - + $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; $sql .= " ORDER BY aa.account_number"; - + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - + $out .= ajax_combobox($htmlname, $event); $out .= ''; if ($showempty) $out .= ''; @@ -191,7 +191,7 @@ class FormVentilation extends Form while ( $i < $num ) { $obj = $this->db->fetch_object($resql); $label = $obj->pcg_type; - + if (($selectid != '') && $selectid == $obj->pcg_type) { $out .= ''; } else { @@ -209,34 +209,34 @@ class FormVentilation extends Form $this->db->free($resql); return $out; } - + /** - * Return list of accounts with label by sub_class of accounts + * Return list of accounts with label by sub_class of accounts * - * @param string $selectid Preselected pcg_type - * @param string $htmlname Name of field in html form - * @param int $showempty Add an empty field - * @param array $event Event options - * - * @return string String with HTML select + * @param string $selectid Preselected pcg_type + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param array $event Event options + * + * @return string String with HTML select */ function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) { global $conf; - + $out = ''; - + $sql = "SELECT DISTINCT pcg_subtype "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " ORDER BY pcg_subtype"; - + dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - + $out .= ajax_combobox($htmlname, $event); - + $out .= ''; } @@ -369,34 +368,34 @@ class FormVentilation extends Form $out_array[''] = ''; } } - + $sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " ORDER BY doc_date"; - dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); + dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { while ( $obj = $this->db->fetch_object($resql) ) { $selected_html = ''; if ($selected > 0 && $obj->dtyear == $selected) $selected_html = ' selected'; - if ($output_format == 'html' || $output_format == 'options') { - $out .= ''; - } elseif ($output_format == 'array') { - $out_array[$obj->dtyear] = $obj->dtyear; - } + if ($output_format == 'html' || $output_format == 'options') { + $out .= ''; + } elseif ($output_format == 'array') { + $out_array[$obj->dtyear] = $obj->dtyear; + } } } else { $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::".__METHOD__ . $this->error, LOG_ERR); + dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); return - 1; } $this->db->free($resql); - + if ($output_format == 'html') { $out .= "\n"; } - + if ($output_format == 'html' || $output_format == 'options') { return $out; } elseif ($output_format == 'array') { diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 964e39efebf..c49dd7ce78a 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -18,16 +18,15 @@ */ /** - * \file htdocs/accountancy/customer/card.php - * \ingroup Accountancy - * \brief Card customer ventilation + * \file htdocs/accountancy/customer/card.php + * \ingroup Accountancy + * \brief Card customer ventilation */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; // Langs $langs->load("bills"); @@ -40,17 +39,16 @@ $id = GETPOST('id'); // Security check if ($user->societe_id > 0) accessforbidden(); - -/* + + /* * Actions */ if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { - if (! GETPOST('cancel', 'alpha')) - { + if (! GETPOST('cancel', 'alpha')) { $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql .= " SET fk_code_ventilation = " . $codeventil; $sql .= " WHERE rowid = " . $id; - + dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if (! $resql) { @@ -91,35 +89,35 @@ if (! empty($id)) { if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")"; } - + dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); - + if ($result) { $num_lines = $db->num_rows($result); $i = 0; - + if ($num_lines) { - + $objp = $db->fetch_object($result); - + print '' . "\n"; print ''; print ''; - - print load_fiche_titre($langs->trans('CustomersVentilation'),'','title_setup'); - - dol_fiche_head(); - + + print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_setup'); + + dol_fiche_head(); + print ''; - + // Ref facture print ''; $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; print ''; print ''; - + print ''; print ''; print ''; print '
' . $langs->trans("Invoice") . '' . $facture_static->getNomUrl(1) . '
' . $langs->trans("Line") . '' . nl2br($objp->description) . '
' . $langs->trans("Account") . ''; @@ -127,14 +125,14 @@ if (! empty($id)) { print '
'; - dol_fiche_end(); - + dol_fiche_end(); + print '
'; print ''; print '     '; print ''; print '
'; - + print ''; } else { print "Error"; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 0b8b842bb99..ce5011043da 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -21,16 +21,15 @@ */ /** - * \file htdocs/accountancy/customer/index.php - * \ingroup Accounting Expert - * \brief Home customer ventilation + * \file htdocs/accountancy/customer/index.php + * \ingroup Accounting Expert + * \brief Home customer ventilation */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; // Langs $langs->load("compta"); @@ -44,8 +43,8 @@ if ($user->societe_id > 0) accessforbidden(); if (! $user->rights->accounting->ventilation->read) accessforbidden(); - -// Filter + + // Filter $year = $_GET["year"]; if ($year == 0) { $year_current = strftime("%Y", time()); @@ -58,10 +57,10 @@ if ($year == 0) { // Validate History $action = GETPOST('action'); if ($action == 'validatehistory') { - + $error = 0; $db->begin(); - + if ($db->type == 'pgsql') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; $sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; @@ -78,7 +77,7 @@ if ($action == 'validatehistory') { } dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); - + $resql1 = $db->query($sql1); if (! $resql1) { $error ++; @@ -169,11 +168,11 @@ $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); - + while ( $i < $num ) { $row = $db->fetch_row($resql); - $var=!$var; - print '
' . length_accountg($row[0]) . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[2]) . '' . price($row[3]) . '
' . $row[0] . '' . price($row[1]) . '' . price($row[2]) . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[1]) . '' . price($row[2]) . '
"; print ""; @@ -613,19 +569,19 @@ else print ""; print ""; print "\n"; - + $var = true; $r = ''; - + foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + if ($val["lib"] == '(SupplierInvoicePayment)') $reflabel = $langs->trans('SupplierInvoicePayment'); if ($val["lib"] == '(CustomerInvoicePayment)') $reflabel = $langs->trans('CustomerInvoicePayment'); - - // Bank + + // Bank foreach ( $tabbq[$key] as $k => $mt ) { print ""; print ""; @@ -637,10 +593,9 @@ else print ""; print ""; } - + // Third party - if (is_array ( $tabtp[$key])) - { + if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { if ($k != 'type') { print ""; @@ -654,11 +609,8 @@ else print ""; } } - } - else - { - foreach ( $tabbq[$key] as $k => $mt ) - { + } else { + foreach ( $tabbq[$key] as $k => $mt ) { print ""; print ""; print ""; @@ -672,9 +624,9 @@ else } $var = ! $var; } - + print "
" . $langs->trans("PaymentMode") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $reflabel . "
"; - + llxFooter(); } diff --git a/htdocs/accountancy/journal/index.php b/htdocs/accountancy/journal/index.php index c7a57512073..c6905ee531e 100644 --- a/htdocs/accountancy/journal/index.php +++ b/htdocs/accountancy/journal/index.php @@ -19,13 +19,12 @@ */ /** - * \file htdocs/accountancy/journal/index.php - * \ingroup Accounting Expert - * \brief Index + * \file htdocs/accountancy/journal/index.php + * \ingroup Accounting Expert + * \brief Index */ - require '../../main.inc.php'; - + // Langs $langs->load("compta"); $langs->load("bills"); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index b9f6fe2d542..8d1c2bad1a9 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -22,21 +22,20 @@ */ /** - * \file htdocs/accountancy/journal/purchasesjournal.php - * \ingroup Accounting Expert - * \brief Page with purchases journal + * \file htdocs/accountancy/journal/purchasesjournal.php + * \ingroup Accounting Expert + * \brief Page with purchases journal */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -60,8 +59,6 @@ if ($user->societe_id > 0) $action = GETPOST('action'); - - /* * Actions */ @@ -115,13 +112,13 @@ if ($result) { // les variables $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"); $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - + $tabfac = array (); $tabht = array (); $tabtva = array (); $tabttc = array (); $tabcompany = array (); - + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); @@ -135,9 +132,9 @@ if ($result) { $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); } $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - + $tabfac[$obj->rowid]["date"] = $obj->df; - $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier.' ('.$obj->ref.')'; + $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["description"] = $obj->description; $tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; @@ -147,9 +144,9 @@ if ($result) { $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, - 'code_fournisseur' => $obj->code_compta_fournisseur + 'code_fournisseur' => $obj->code_compta_fournisseur ); - + $i ++; } } else { @@ -160,11 +157,11 @@ if ($result) { if ($action == 'writebookkeeping') { $now = dol_now(); $error = 0; - + foreach ( $tabfac as $key => $val ) { foreach ( $tabttc[$key] as $k => $mt ) { // get compte id and label - + $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -181,14 +178,14 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt > 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); } } - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { if ($mt) { @@ -211,7 +208,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -220,7 +217,7 @@ if ($action == 'writebookkeeping') { } } } - + // VAT // var_dump($tabtva); foreach ( $tabtva[$key] as $k => $mt ) { @@ -242,7 +239,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -251,13 +248,12 @@ if ($action == 'writebookkeeping') { } } } - + if (empty($error)) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } } - /* * View */ @@ -265,26 +261,25 @@ if ($action == 'writebookkeeping') { $companystatic = new Fournisseur($db); // Export -if ($action == 'export_csv') -{ +if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) // Model Cegid Expert Export - { + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) // Model Cegid Expert Export +{ $sep = ";"; foreach ( $tabfac as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + if ($mt) { print $date . $sep; print $purchase_journal . $sep; @@ -297,7 +292,7 @@ if ($action == 'export_csv') print "\n"; } } - + // VAT foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -312,7 +307,7 @@ if ($action == 'export_csv') print "\n"; } } - + foreach ( $tabttc[$key] as $k => $mt ) { print $date . $sep; print $purchase_journal . $sep; @@ -325,19 +320,19 @@ if ($action == 'export_csv') print "\n"; } } - } else // Model Classic Export - { + } else // Model Classic Export +{ foreach ( $tabfac as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k); + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); if ($mt) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; @@ -360,7 +355,7 @@ if ($action == 'export_csv') print "\n"; } } - + // Third party foreach ( $tabttc[$key] as $k => $mt ) { print '"' . $date . '"' . $sep; @@ -374,11 +369,11 @@ if ($action == 'export_csv') } } } else { - + llxHeader('', '', ''); - + $form = new Form($db); - + $nom = $langs->trans("PurchasesJournal"); $nomlink = ''; $periodlink = ''; @@ -390,12 +385,14 @@ if ($action == 'export_csv') else $description .= $langs->trans("DepositsAreIncluded"); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); - report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); - + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( + 'action' => '' + )); + print ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -424,25 +421,25 @@ if ($action == 'export_csv') print ""; print ""; print "\n"; - + $var = true; $r = ''; - + $invoicestatic = new FactureFournisseur($db); - + foreach ( $tabfac as $key => $val ) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; $invoicestatic->type = $val["type"]; $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k); - + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); + if ($mt) { print ""; print ""; @@ -467,7 +464,7 @@ if ($action == 'export_csv') } } print ""; - + // Third party foreach ( $tabttc[$key] as $k => $mt ) { print ""; @@ -482,10 +479,10 @@ if ($action == 'export_csv') print '"; } print ""; - + $var = ! $var; } - + print "
" . $langs->trans("Account") . "" . $langs->trans("Type") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "
" . $date . "' . ($mt >= 0 ? price($mt) : '') . "
"; // End of page diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 1c7ef749e33..af77d3e0c06 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -24,21 +24,20 @@ */ /** - * \file htdocs/accountancy/journal/sellsjournal.php - * \ingroup Accounting Expert - * \brief Page with sells journal + * \file htdocs/accountancy/journal/sellsjournal.php + * \ingroup Accounting Expert + * \brief Page with sells journal */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -62,8 +61,6 @@ if ($user->societe_id > 0) $action = GETPOST('action'); - - /* * View */ @@ -105,10 +102,9 @@ if (! empty($conf->multicompany->enabled)) { } $sql .= " AND f.fk_statut > 0"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; -} -else { - $sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_STANDARD.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; } $sql .= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) @@ -123,16 +119,16 @@ if ($result) { $tabtva = array (); $tabttc = array (); $tabcompany = array (); - + $num = $db->num_rows($result); $i = 0; - + while ( $i < $num ) { $obj = $db->fetch_object($result); // les variables $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; - + $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) @@ -142,12 +138,12 @@ if ($result) { } $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - + // Situation invoices handling $line = new FactureLigne($db); $line->fetch($obj->rowid); $prev_progress = $line->get_prev_progress(); - if ($obj->type==Facture::TYPE_SITUATION) { + if ($obj->type == Facture::TYPE_SITUATION) { // Avoid divide by 0 if ($obj->situation_percent == 0) { $situation_ratio = 0; @@ -157,7 +153,7 @@ if ($result) { } else { $situation_ratio = 1; } - + // Invoice lines $tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["ref"] = $obj->facnumber; @@ -176,9 +172,9 @@ if ($result) { $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, - 'code_client' => $obj->code_compta + 'code_client' => $obj->code_compta ); - + $i ++; } } else { @@ -191,15 +187,12 @@ if ($result) { */ // Bookkeeping Write -if ($action == 'writebookkeeping') -{ +if ($action == 'writebookkeeping') { $now = dol_now(); $error = 0; - - foreach ($tabfac as $key => $val) - { - foreach ($tabttc[$key] as $k => $mt) - { + + foreach ( $tabfac as $key => $val ) { + foreach ( $tabttc[$key] as $k => $mt ) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -216,16 +209,16 @@ if ($action == 'writebookkeeping') $bookkeeping->credit = ($mt < 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); } } - + // Product / Service - foreach ($tabht[$key] as $k => $mt) { + foreach ( $tabht[$key] as $k => $mt ) { if ($mt) { // get compte id and label $accountingaccount = new AccountingAccount($db); @@ -246,7 +239,7 @@ if ($action == 'writebookkeeping') $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -255,13 +248,11 @@ if ($action == 'writebookkeeping') } } } - + // VAT // var_dump($tabtva); - foreach ($tabtva[$key] as $k => $mt) - { - if ($mt) - { + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -278,7 +269,7 @@ if ($action == 'writebookkeeping') $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -287,33 +278,32 @@ if ($action == 'writebookkeeping') } } } - + if (empty($error)) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } } // Export -if ($action == 'export_csv') -{ +if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = $conf->global->ACCOUNTING_SELL_JOURNAL; - - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; - + + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + $companystatic = new Client($db); - - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) // Model Cegid Expert Export - { + + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) // Model Cegid Expert Export +{ $sep = ";"; - + foreach ( $tabfac as $key => $val ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - + foreach ( $tabttc[$key] as $k => $mt ) { print $date . $sep; print $sell_journal . $sep; @@ -325,7 +315,7 @@ if ($action == 'export_csv') print $val["ref"]; print "\n"; } - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { if ($mt) { @@ -340,7 +330,7 @@ if ($action == 'export_csv') print "\n"; } } - + // TVA foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -356,17 +346,15 @@ if ($action == 'export_csv') } } } - } - else // Model Classic Export - { - foreach ($tabfac as $key => $val) - { + } else // Model Classic Export +{ + foreach ( $tabfac as $key => $val ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + foreach ( $tabttc[$key] as $k => $mt ) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; @@ -376,13 +364,12 @@ if ($action == 'export_csv') print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; } - + // Product / Service - foreach ($tabht[$key] as $k => $mt) - { + foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); - + if ($mt) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; @@ -393,10 +380,9 @@ if ($action == 'export_csv') print "\n"; } } - + // VAT - foreach ($tabtva[$key] as $k => $mt) - { + foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; @@ -410,11 +396,11 @@ if ($action == 'export_csv') } } } else { - + $form = new Form($db); - + llxHeader('', $langs->trans("SellsJournal")); - + $nom = $langs->trans("SellsJournal"); $nomlink = ''; $periodlink = ''; @@ -426,12 +412,14 @@ if ($action == 'export_csv') else $description .= $langs->trans("DepositsAreIncluded"); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); - report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); - + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( + 'action' => '' + )); + print ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -461,24 +449,22 @@ if ($action == 'export_csv') print ""; print ""; print "\n"; - + $var = true; $r = ''; - + $invoicestatic = new Facture($db); $companystatic = new Client($db); - - foreach ($tabfac as $key => $val) - { + + foreach ( $tabfac as $key => $val ) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; $invoicestatic->type = $val["type"]; - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + // Third party - foreach ($tabttc[$key] as $k => $mt) - { + foreach ( $tabttc[$key] as $k => $mt ) { print ""; print ""; print ""; @@ -492,13 +478,12 @@ if ($action == 'export_csv') print ""; } print ""; - + // Product / Service - foreach ($tabht[$key] as $k => $mt) - { + foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); - + if ($mt) { print ""; print ""; @@ -510,10 +495,9 @@ if ($action == 'export_csv') print ""; } } - + // VAT - foreach ($tabtva[$key] as $k => $mt) - { + foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { print ""; print ""; @@ -525,12 +509,12 @@ if ($action == 'export_csv') print ""; } } - + $var = ! $var; } - + print "
" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "
" . $date . "
"; - + // End of page llxFooter(); } diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index d11d72951dc..e0eb900b1c1 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -22,16 +22,15 @@ * */ /** - * \file htdocs/accountancy/supplier/card.php - * \ingroup Accountancy - * \brief Card supplier ventilation + * \file htdocs/accountancy/supplier/card.php + * \ingroup Accountancy + * \brief Card supplier ventilation */ - require '../../main.inc.php'; - + // Class -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; // Langs $langs->load("bills"); @@ -46,8 +45,7 @@ if ($user->societe_id > 0) accessforbidden(); if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { - if (! GETPOST('cancel', 'alpha')) - { + if (! GETPOST('cancel', 'alpha')) { $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " SET fk_code_ventilation = " . $codeventil; $sql .= " WHERE rowid = " . $id; @@ -94,7 +92,7 @@ if (! empty($id)) { dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); - + if ($result) { $num_lines = $db->num_rows($result); $i = 0; @@ -106,9 +104,9 @@ if (! empty($id)) { print ''; print ''; - print load_fiche_titre($langs->trans('SuppliersVentilation'),'','title_setup'); - - dol_fiche_head(); + print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_setup'); + + dol_fiche_head(); print ''; @@ -127,15 +125,15 @@ if (! empty($id)) { print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); print ''; print '
'; - - dol_fiche_end(); - + + dol_fiche_end(); + print '
'; print ''; print '     '; print ''; print '
'; - + print ''; } else { print "Error"; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index ec18d8b1e23..082fdc25fd4 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -19,16 +19,15 @@ */ /** - * \file htdocs/accountancy/supplier/index.php - * \ingroup Accounting Expert - * \brief Home supplier ventilation + * \file htdocs/accountancy/supplier/index.php + * \ingroup Accounting Expert + * \brief Home supplier ventilation */ - require '../../main.inc.php'; - + // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; // Langs $langs->load("compta"); @@ -43,7 +42,7 @@ if ($user->societe_id > 0) if (! $user->rights->accounting->ventilation->read) accessforbidden(); -// Filter + // Filter $year = $_GET["year"]; if ($year == 0) { $year_current = strftime("%Y", time()); @@ -158,8 +157,8 @@ if ($resql) { while ( $i < $num ) { $row = $db->fetch_row($resql); - $var=!$var; - print '' . length_accountg($row[0]) . ''; + $var = ! $var; + print '' . length_accountg($row[0]) . ''; print '' . $row[1] . ''; print '' . price($row[2]) . ''; print '' . price($row[3]) . ''; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index e77c98aae3d..6736c6a30d6 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -20,18 +20,17 @@ */ /** - * \file htdocs/accountancy/supplier/lines.php - * \ingroup Accounting Expert - * \brief Page of detail of the lines of ventilation of invoices suppliers + * \file htdocs/accountancy/supplier/lines.php + * \ingroup Accounting Expert + * \brief Page of detail of the lines of ventilation of invoices suppliers */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("compta"); @@ -41,43 +40,38 @@ $langs->load("main"); $langs->load("accountancy"); $account_parent = GETPOST('account_parent'); -$changeaccount = GETPOST('changeaccount'); -//Search Getpost -$search_ref = GETPOST('search_ref','alpha'); -$search_invoice = GETPOST('search_invoice','alpha'); -$search_label = GETPOST('search_label','alpha'); -$search_desc = GETPOST('search_desc','alpha'); -$search_amount = GETPOST('search_amount','alpha'); -$search_account = GETPOST('search_account','alpha'); -$search_vat = GETPOST('search_vat','alpha'); +$changeaccount = GETPOST('changeaccount'); +// Search Getpost +$search_ref = GETPOST('search_ref', 'alpha'); +$search_invoice = GETPOST('search_invoice', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_account = GETPOST('search_account', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); -//Getpost Order and column and limit page -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); +// Getpost Order and column and limit page +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; +if ($page < 0) + $page = 0; $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) -{ +if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; -} -else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) -{ - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -} -else -{ - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; +} else { + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; } -if (! $sortfield) $sortfield="f.datef, f.ref, l.rowid"; +if (! $sortfield) + $sortfield = "f.datef, f.ref, l.rowid"; -if (! $sortorder) -{ - if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) - { +if (! $sortorder) { + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = " DESC "; } } @@ -93,13 +87,13 @@ $formventilation = new FormVentilation($db); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { - $search_ref=''; - $search_invoice=''; - $search_label=''; - $search_desc=''; - $search_amount=''; - $search_account=''; - $search_vat=''; + $search_ref = ''; + $search_invoice = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -132,7 +126,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched")); -print ''; - /* * Supplier Invoice lines */ @@ -179,15 +172,14 @@ if (strlen(trim($search_amount))) { if (strlen(trim($search_account))) { $sql .= " AND aa.account_number like '%" . $search_account . "%'"; } -if (strlen(trim($search_vat))) -{ +if (strlen(trim($search_vat))) { $sql .= " AND (l.tva_tx like '" . $search_vat . "%')"; } if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; } -$sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($limit + 1,$offset); +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/supplier/lines.php::list sql= ' . $sql1); $result = $db->query($sql); @@ -203,23 +195,23 @@ if ($result) { print '
'; print ''; - print '
'. $langs->trans("ChangeAccount") . '
'; + print '
' . $langs->trans("ChangeAccount") . '
'; print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); print '
'; print '
'; - print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"],"f.ref","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"],"l.total_ht","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"],"l.tva_tx","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"],"aa.account_number","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre(''); print_liste_field_titre(''); - print_liste_field_titre($langs->trans("Ventilate").'
/','','','','','align="center"'); + print_liste_field_titre($langs->trans("Ventilate") . '
/', '', '', '', '', 'align="center"'); print "\n"; - + print ''; print ''; print ''; @@ -228,9 +220,9 @@ if ($result) { print ''; print ''; print ''; - print '\n"; + print '\n"; $facturefournisseur_static = new FactureFournisseur($db); $product_static = new Product($db); @@ -278,7 +270,6 @@ if ($result) { print $db->error(); } - print "
% '; - print ''; - print "
'; + print ''; + print "
"; llxFooter(); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 50356c0539c..212ff316c34 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/accountancy/supplier/list.php - * \ingroup Accountancy - * \brief Ventilation page from suppliers invoices + * \file htdocs/accountancy/supplier/list.php + * \ingroup Accountancy + * \brief Ventilation page from suppliers invoices */ require '../../main.inc.php'; @@ -66,9 +66,9 @@ if ($page < 0) if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; } else { - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; } $offset = $limit * $page; @@ -94,8 +94,8 @@ $formventilation = new FormVentilation($db); $accounting = new AccountingAccount($db); // TODO: we should need to check if result is a really exist accountaccount rowid..... -$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT,1); -$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT,1); +$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); +$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers @@ -133,7 +133,7 @@ print ''; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -613,19 +570,19 @@ else print ""; print ""; print "\n"; - + $var = true; $r = ''; - + foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + if ($val["lib"] == '(SupplierInvoicePayment)') $reflabel = $langs->trans('SupplierInvoicePayment'); if ($val["lib"] == '(CustomerInvoicePayment)') $reflabel = $langs->trans('CustomerInvoicePayment'); - - // Bank + + // Bank foreach ( $tabbq[$key] as $k => $mt ) { print ""; print ""; @@ -637,10 +594,9 @@ else print ""; print ""; } - + // Third party - if (is_array ( $tabtp[$key])) - { + if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { if ($k != 'type') { print ""; @@ -654,11 +610,8 @@ else print ""; } } - } - else - { - foreach ( $tabbq[$key] as $k => $mt ) - { + } else { + foreach ( $tabbq[$key] as $k => $mt ) { print ""; print ""; print ""; @@ -672,9 +625,9 @@ else } $var = ! $var; } - + print "
" . $langs->trans("PaymentMode") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $reflabel . "
"; - + llxFooter(); } diff --git a/htdocs/accountancy/journal/index.php b/htdocs/accountancy/journal/index.php index c7a57512073..c6905ee531e 100644 --- a/htdocs/accountancy/journal/index.php +++ b/htdocs/accountancy/journal/index.php @@ -19,13 +19,12 @@ */ /** - * \file htdocs/accountancy/journal/index.php - * \ingroup Accounting Expert - * \brief Index + * \file htdocs/accountancy/journal/index.php + * \ingroup Accounting Expert + * \brief Index */ - require '../../main.inc.php'; - + // Langs $langs->load("compta"); $langs->load("bills"); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index dd0c1f3a4c9..c4ab3b1709e 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -22,21 +22,20 @@ */ /** - * \file htdocs/accountancy/journal/purchasesjournal.php - * \ingroup Accounting Expert - * \brief Page with purchases journal + * \file htdocs/accountancy/journal/purchasesjournal.php + * \ingroup Accounting Expert + * \brief Page with purchases journal */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -60,8 +59,6 @@ if ($user->societe_id > 0) $action = GETPOST('action'); - - /* * Actions */ @@ -115,13 +112,13 @@ if ($result) { // les variables $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"); $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - + $tabfac = array (); $tabht = array (); $tabtva = array (); $tabttc = array (); $tabcompany = array (); - + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); @@ -135,9 +132,9 @@ if ($result) { $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); } $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - + $tabfac[$obj->rowid]["date"] = $obj->df; - $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier.' ('.$obj->ref.')'; + $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["description"] = $obj->description; $tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; @@ -147,9 +144,9 @@ if ($result) { $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, - 'code_fournisseur' => $obj->code_compta_fournisseur + 'code_fournisseur' => $obj->code_compta_fournisseur ); - + $i ++; } } else { @@ -160,11 +157,11 @@ if ($result) { if ($action == 'writebookkeeping') { $now = dol_now(); $error = 0; - + foreach ( $tabfac as $key => $val ) { foreach ( $tabttc[$key] as $k => $mt ) { // get compte id and label - + $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -181,14 +178,14 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt > 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); } } - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { if ($mt) { @@ -211,7 +208,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -220,7 +217,7 @@ if ($action == 'writebookkeeping') { } } } - + // VAT // var_dump($tabtva); foreach ( $tabtva[$key] as $k => $mt ) { @@ -242,7 +239,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -251,13 +248,12 @@ if ($action == 'writebookkeeping') { } } } - + if (empty($error)) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } } - /* * View */ @@ -265,26 +261,25 @@ if ($action == 'writebookkeeping') { $companystatic = new Fournisseur($db); // Export -if ($action == 'export_csv') -{ +if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) // Model Cegid Expert Export - { + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) // Model Cegid Expert Export +{ $sep = ";"; foreach ( $tabfac as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + if ($mt) { print $date . $sep; print $purchase_journal . $sep; @@ -297,7 +292,7 @@ if ($action == 'export_csv') print "\n"; } } - + // VAT foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -312,7 +307,7 @@ if ($action == 'export_csv') print "\n"; } } - + foreach ( $tabttc[$key] as $k => $mt ) { print $date . $sep; print $purchase_journal . $sep; @@ -325,19 +320,19 @@ if ($action == 'export_csv') print "\n"; } } - } else // Model Classic Export - { + } else // Model Classic Export +{ foreach ( $tabfac as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k); + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); if ($mt) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; @@ -360,7 +355,7 @@ if ($action == 'export_csv') print "\n"; } } - + // Third party foreach ( $tabttc[$key] as $k => $mt ) { print '"' . $date . '"' . $sep; @@ -374,11 +369,11 @@ if ($action == 'export_csv') } } } else { - + llxHeader('', $langs->trans("PurchasesJournal")); - + $form = new Form($db); - + $nom = $langs->trans("PurchasesJournal"); $nomlink = ''; $periodlink = ''; @@ -390,12 +385,14 @@ if ($action == 'export_csv') else $description .= $langs->trans("DepositsAreIncluded"); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); - report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); - + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( + 'action' => '' + )); + print ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -424,25 +421,25 @@ if ($action == 'export_csv') print ""; print ""; print "\n"; - + $var = true; $r = ''; - + $invoicestatic = new FactureFournisseur($db); - + foreach ( $tabfac as $key => $val ) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; $invoicestatic->type = $val["type"]; $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k); - + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); + if ($mt) { print ""; print ""; @@ -467,7 +464,7 @@ if ($action == 'export_csv') } } print ""; - + // Third party foreach ( $tabttc[$key] as $k => $mt ) { print ""; @@ -482,10 +479,10 @@ if ($action == 'export_csv') print '"; } print ""; - + $var = ! $var; } - + print "
" . $langs->trans("Account") . "" . $langs->trans("Type") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "
" . $date . "' . ($mt >= 0 ? price($mt) : '') . "
"; // End of page diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 1c7ef749e33..af77d3e0c06 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -24,21 +24,20 @@ */ /** - * \file htdocs/accountancy/journal/sellsjournal.php - * \ingroup Accounting Expert - * \brief Page with sells journal + * \file htdocs/accountancy/journal/sellsjournal.php + * \ingroup Accounting Expert + * \brief Page with sells journal */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -62,8 +61,6 @@ if ($user->societe_id > 0) $action = GETPOST('action'); - - /* * View */ @@ -105,10 +102,9 @@ if (! empty($conf->multicompany->enabled)) { } $sql .= " AND f.fk_statut > 0"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; -} -else { - $sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_STANDARD.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; } $sql .= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) @@ -123,16 +119,16 @@ if ($result) { $tabtva = array (); $tabttc = array (); $tabcompany = array (); - + $num = $db->num_rows($result); $i = 0; - + while ( $i < $num ) { $obj = $db->fetch_object($result); // les variables $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; - + $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) @@ -142,12 +138,12 @@ if ($result) { } $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - + // Situation invoices handling $line = new FactureLigne($db); $line->fetch($obj->rowid); $prev_progress = $line->get_prev_progress(); - if ($obj->type==Facture::TYPE_SITUATION) { + if ($obj->type == Facture::TYPE_SITUATION) { // Avoid divide by 0 if ($obj->situation_percent == 0) { $situation_ratio = 0; @@ -157,7 +153,7 @@ if ($result) { } else { $situation_ratio = 1; } - + // Invoice lines $tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["ref"] = $obj->facnumber; @@ -176,9 +172,9 @@ if ($result) { $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, - 'code_client' => $obj->code_compta + 'code_client' => $obj->code_compta ); - + $i ++; } } else { @@ -191,15 +187,12 @@ if ($result) { */ // Bookkeeping Write -if ($action == 'writebookkeeping') -{ +if ($action == 'writebookkeeping') { $now = dol_now(); $error = 0; - - foreach ($tabfac as $key => $val) - { - foreach ($tabttc[$key] as $k => $mt) - { + + foreach ( $tabfac as $key => $val ) { + foreach ( $tabttc[$key] as $k => $mt ) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -216,16 +209,16 @@ if ($action == 'writebookkeeping') $bookkeeping->credit = ($mt < 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; setEventMessages($object->error, $object->errors, 'errors'); } } - + // Product / Service - foreach ($tabht[$key] as $k => $mt) { + foreach ( $tabht[$key] as $k => $mt ) { if ($mt) { // get compte id and label $accountingaccount = new AccountingAccount($db); @@ -246,7 +239,7 @@ if ($action == 'writebookkeeping') $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -255,13 +248,11 @@ if ($action == 'writebookkeeping') } } } - + // VAT // var_dump($tabtva); - foreach ($tabtva[$key] as $k => $mt) - { - if ($mt) - { + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -278,7 +269,7 @@ if ($action == 'writebookkeeping') $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -287,33 +278,32 @@ if ($action == 'writebookkeeping') } } } - + if (empty($error)) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } } // Export -if ($action == 'export_csv') -{ +if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = $conf->global->ACCOUNTING_SELL_JOURNAL; - - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; - + + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + $companystatic = new Client($db); - - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) // Model Cegid Expert Export - { + + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) // Model Cegid Expert Export +{ $sep = ";"; - + foreach ( $tabfac as $key => $val ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - + foreach ( $tabttc[$key] as $k => $mt ) { print $date . $sep; print $sell_journal . $sep; @@ -325,7 +315,7 @@ if ($action == 'export_csv') print $val["ref"]; print "\n"; } - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { if ($mt) { @@ -340,7 +330,7 @@ if ($action == 'export_csv') print "\n"; } } - + // TVA foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -356,17 +346,15 @@ if ($action == 'export_csv') } } } - } - else // Model Classic Export - { - foreach ($tabfac as $key => $val) - { + } else // Model Classic Export +{ + foreach ( $tabfac as $key => $val ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + foreach ( $tabttc[$key] as $k => $mt ) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; @@ -376,13 +364,12 @@ if ($action == 'export_csv') print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; } - + // Product / Service - foreach ($tabht[$key] as $k => $mt) - { + foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); - + if ($mt) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; @@ -393,10 +380,9 @@ if ($action == 'export_csv') print "\n"; } } - + // VAT - foreach ($tabtva[$key] as $k => $mt) - { + foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; @@ -410,11 +396,11 @@ if ($action == 'export_csv') } } } else { - + $form = new Form($db); - + llxHeader('', $langs->trans("SellsJournal")); - + $nom = $langs->trans("SellsJournal"); $nomlink = ''; $periodlink = ''; @@ -426,12 +412,14 @@ if ($action == 'export_csv') else $description .= $langs->trans("DepositsAreIncluded"); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); - report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); - + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( + 'action' => '' + )); + print ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -461,24 +449,22 @@ if ($action == 'export_csv') print ""; print ""; print "\n"; - + $var = true; $r = ''; - + $invoicestatic = new Facture($db); $companystatic = new Client($db); - - foreach ($tabfac as $key => $val) - { + + foreach ( $tabfac as $key => $val ) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; $invoicestatic->type = $val["type"]; - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + // Third party - foreach ($tabttc[$key] as $k => $mt) - { + foreach ( $tabttc[$key] as $k => $mt ) { print ""; print ""; print ""; @@ -492,13 +478,12 @@ if ($action == 'export_csv') print ""; } print ""; - + // Product / Service - foreach ($tabht[$key] as $k => $mt) - { + foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); - + if ($mt) { print ""; print ""; @@ -510,10 +495,9 @@ if ($action == 'export_csv') print ""; } } - + // VAT - foreach ($tabtva[$key] as $k => $mt) - { + foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { print ""; print ""; @@ -525,12 +509,12 @@ if ($action == 'export_csv') print ""; } } - + $var = ! $var; } - + print "
" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "
" . $date . "
"; - + // End of page llxFooter(); } diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index d11d72951dc..e0eb900b1c1 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -22,16 +22,15 @@ * */ /** - * \file htdocs/accountancy/supplier/card.php - * \ingroup Accountancy - * \brief Card supplier ventilation + * \file htdocs/accountancy/supplier/card.php + * \ingroup Accountancy + * \brief Card supplier ventilation */ - require '../../main.inc.php'; - + // Class -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; // Langs $langs->load("bills"); @@ -46,8 +45,7 @@ if ($user->societe_id > 0) accessforbidden(); if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { - if (! GETPOST('cancel', 'alpha')) - { + if (! GETPOST('cancel', 'alpha')) { $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " SET fk_code_ventilation = " . $codeventil; $sql .= " WHERE rowid = " . $id; @@ -94,7 +92,7 @@ if (! empty($id)) { dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); - + if ($result) { $num_lines = $db->num_rows($result); $i = 0; @@ -106,9 +104,9 @@ if (! empty($id)) { print ''; print ''; - print load_fiche_titre($langs->trans('SuppliersVentilation'),'','title_setup'); - - dol_fiche_head(); + print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_setup'); + + dol_fiche_head(); print ''; @@ -127,15 +125,15 @@ if (! empty($id)) { print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); print ''; print '
'; - - dol_fiche_end(); - + + dol_fiche_end(); + print '
'; print ''; print '     '; print ''; print '
'; - + print ''; } else { print "Error"; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index ec18d8b1e23..747943575b9 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -19,16 +19,15 @@ */ /** - * \file htdocs/accountancy/supplier/index.php - * \ingroup Accounting Expert - * \brief Home supplier ventilation + * \file htdocs/accountancy/supplier/index.php + * \ingroup Accounting Expert + * \brief Home supplier ventilation */ - require '../../main.inc.php'; - + // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; // Langs $langs->load("compta"); @@ -43,7 +42,7 @@ if ($user->societe_id > 0) if (! $user->rights->accounting->ventilation->read) accessforbidden(); -// Filter + // Filter $year = $_GET["year"]; if ($year == 0) { $year_current = strftime("%Y", time()); @@ -84,6 +83,50 @@ if ($action == 'validatehistory') { $db->commit(); setEventMessages($langs->trans('Dispatched'), null, 'mesgs'); } +} elseif ($action == 'fixaccountancycode') { + $error = 0; + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; + $sql1 .= " SET fd.fk_code_ventilation = 0"; + $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; + $sql1 .= ' (SELECT accnt.rowid '; + $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as accnt'; + $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; + + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Done'), 'mesgs'); + } +} elseif ($action == 'cleanaccountancycode') { + $error = 0; + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; + $sql1 .= " SET fd.fk_code_ventilation = 0"; + $sql1 .= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; + $sql1 .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; + $sql1 .= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')"; + + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Done'), 'mesgs'); + } } /* @@ -98,7 +141,11 @@ $textnextyear = ' ' . $langs->trans("DescVentilSupplier") . ''; -print ''; +print ''; $y = $year_current; @@ -158,8 +205,8 @@ if ($resql) { while ( $i < $num ) { $row = $db->fetch_row($resql); - $var=!$var; - print '' . length_accountg($row[0]) . ''; + $var = ! $var; + print '' . length_accountg($row[0]) . ''; print '' . $row[1] . ''; print '' . price($row[2]) . ''; print '' . price($row[3]) . ''; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index e77c98aae3d..6736c6a30d6 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -20,18 +20,17 @@ */ /** - * \file htdocs/accountancy/supplier/lines.php - * \ingroup Accounting Expert - * \brief Page of detail of the lines of ventilation of invoices suppliers + * \file htdocs/accountancy/supplier/lines.php + * \ingroup Accounting Expert + * \brief Page of detail of the lines of ventilation of invoices suppliers */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("compta"); @@ -41,43 +40,38 @@ $langs->load("main"); $langs->load("accountancy"); $account_parent = GETPOST('account_parent'); -$changeaccount = GETPOST('changeaccount'); -//Search Getpost -$search_ref = GETPOST('search_ref','alpha'); -$search_invoice = GETPOST('search_invoice','alpha'); -$search_label = GETPOST('search_label','alpha'); -$search_desc = GETPOST('search_desc','alpha'); -$search_amount = GETPOST('search_amount','alpha'); -$search_account = GETPOST('search_account','alpha'); -$search_vat = GETPOST('search_vat','alpha'); +$changeaccount = GETPOST('changeaccount'); +// Search Getpost +$search_ref = GETPOST('search_ref', 'alpha'); +$search_invoice = GETPOST('search_invoice', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_account = GETPOST('search_account', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); -//Getpost Order and column and limit page -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); +// Getpost Order and column and limit page +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; +if ($page < 0) + $page = 0; $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) -{ +if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; -} -else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) -{ - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -} -else -{ - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; +} else { + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; } -if (! $sortfield) $sortfield="f.datef, f.ref, l.rowid"; +if (! $sortfield) + $sortfield = "f.datef, f.ref, l.rowid"; -if (! $sortorder) -{ - if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) - { +if (! $sortorder) { + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = " DESC "; } } @@ -93,13 +87,13 @@ $formventilation = new FormVentilation($db); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { - $search_ref=''; - $search_invoice=''; - $search_label=''; - $search_desc=''; - $search_amount=''; - $search_account=''; - $search_vat=''; + $search_ref = ''; + $search_invoice = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -132,7 +126,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched")); -print ''; - /* * Supplier Invoice lines */ @@ -179,15 +172,14 @@ if (strlen(trim($search_amount))) { if (strlen(trim($search_account))) { $sql .= " AND aa.account_number like '%" . $search_account . "%'"; } -if (strlen(trim($search_vat))) -{ +if (strlen(trim($search_vat))) { $sql .= " AND (l.tva_tx like '" . $search_vat . "%')"; } if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; } -$sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($limit + 1,$offset); +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/supplier/lines.php::list sql= ' . $sql1); $result = $db->query($sql); @@ -203,23 +195,23 @@ if ($result) { print '
'; print ''; - print '
'. $langs->trans("ChangeAccount") . '
'; + print '
' . $langs->trans("ChangeAccount") . '
'; print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); print '
'; print '
'; - print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"],"f.ref","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"],"l.total_ht","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"],"l.tva_tx","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"],"aa.account_number","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre(''); print_liste_field_titre(''); - print_liste_field_titre($langs->trans("Ventilate").'
/','','','','','align="center"'); + print_liste_field_titre($langs->trans("Ventilate") . '
/', '', '', '', '', 'align="center"'); print "\n"; - + print ''; print ''; print ''; @@ -228,9 +220,9 @@ if ($result) { print ''; print ''; print ''; - print '\n"; + print '\n"; $facturefournisseur_static = new FactureFournisseur($db); $product_static = new Product($db); @@ -278,7 +270,6 @@ if ($result) { print $db->error(); } - print "
% '; - print ''; - print "
'; + print ''; + print "
"; llxFooter(); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index bb57fa0999f..e0f0c390a02 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/accountancy/supplier/list.php - * \ingroup Accountancy - * \brief Ventilation page from suppliers invoices + * \file htdocs/accountancy/supplier/list.php + * \ingroup Accountancy + * \brief Ventilation page from suppliers invoices */ require '../../main.inc.php'; @@ -66,9 +66,9 @@ if ($page < 0) if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; } else { - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; } $offset = $limit * $page; @@ -94,8 +94,8 @@ $formventilation = new FormVentilation($db); $accounting = new AccountingAccount($db); // TODO: we should need to check if result is a really exist accountaccount rowid..... -$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT,1); -$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT,1); +$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); +$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers @@ -133,7 +133,7 @@ print ''."\n"; } @@ -750,11 +752,14 @@ else }); $("#copyaddressfromsoc").click(function() { - $(\'textarea[name="address"]\').text("'.dol_escape_js($objsoc->address).'"); + $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).'"); $(\'input[name="zipcode"]\').val("'.dol_escape_js($objsoc->zip).'"); $(\'input[name="town"]\').val("'.dol_escape_js($objsoc->town).'"); - $(\'select[name="country_id"]\').val("'.dol_escape_js($objsoc->country_id).'"); - $(\'select[name="state_id"]\').val("'.dol_escape_js($objsoc->state_id).'"); + console.log("Set state_id to '.dol_escape_js($objsoc->state_id).'"); + $(\'select[name="state_id"]\').val("'.dol_escape_js($objsoc->state_id).'").trigger("change"); + /* set country at end because it will trigger page refresh */ + console.log("Set country id to '.dol_escape_js($objsoc->country_id).'"); + $(\'select[name="country_id"]\').val("'.dol_escape_js($objsoc->country_id).'").trigger("change"); /* trigger required to update select2 components */ }); })'."\n"; print ''."\n"; From 6f1ddd3ba40a7bb524d581b1ea044702af9b6d33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2016 02:29:19 +0100 Subject: [PATCH 39/41] Fix on ref not correctly initialized. --- htdocs/compta/paiement/card.php | 7 ++++++- htdocs/compta/paiement/class/paiement.class.php | 2 +- htdocs/compta/paiement/list.php | 15 +++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index ba65669aca4..d85916fd766 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -201,8 +201,13 @@ if ($action == 'valide') print ''; +$linkback = '' . $langs->trans("BackToList") . ''; + + // Ref -print ''; +print ''; // Date payment print ''; + print ''; print ''; @@ -271,7 +278,7 @@ if ($resql) else print ' '; print ''; - print ''; + print ''; print '
'.$langs->trans('Ref').''.$object->ref.'
'.$langs->trans('Ref').''; +print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); +print '
'.$form->editfieldkey("Date",'datep',$object->date,$object,$user->rights->facture->paiement).''; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index f9a822fdfc8..4fa9c5b9575 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -103,7 +103,7 @@ class Paiement extends CommonObject { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->ref = $obj->ref; + $this->ref = $obj->ref?$obj->ref:$obj->rowid; $this->date = $this->db->jdate($obj->dp); $this->datepaye = $this->db->jdate($obj->dp); $this->numero = $obj->num_paiement; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 3e70ac0c5bc..c9cf7337ee5 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -53,8 +53,9 @@ $companystatic=new Societe($db); $search_ref=GETPOST("search_ref","int"); $search_account=GETPOST("search_account","int"); $search_paymenttype=GETPOST("search_paymenttype"); -$search_amount=GETPOST("search_amount"); -$search_company=GETPOST("search_company"); +$search_amount=GETPOST("search_amount",'alpha'); // alpha because we must be able to search on "< x" +$search_company=GETPOST("search_company",'alpha'); +$search_payment_num=GETPOST('search_payment_num','alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; @@ -72,6 +73,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_account=""; $search_amount=""; $search_paymenttype=""; + $search_payment_num=""; $search_company=""; $day=''; $year=''; @@ -165,9 +167,10 @@ else { $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } - if ($search_ref) $sql .=natural_search('p.ref', $search_ref); + if ($search_ref) $sql .=natural_search('p.ref', $search_ref); if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'"; + if ($search_payment_num != '') $sql .=" AND p.num_paiement = '".$db->escape($search_payment_num)."'"; if ($search_amount) $sql .=" AND p.amount='".$db->escape(price2num($search_amount))."'"; if ($search_company) $sql .= natural_search('s.nom', $search_company); // Add where from hooks @@ -201,6 +204,7 @@ if ($resql) print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"dp","",$paramlist,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$paramlist,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"c.libelle","",$paramlist,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Numero"),$_SERVER["PHP_SELF"],"p.num_paiement","",$paramlist,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$paramlist,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"p.amount","",$paramlist,'align="right"',$sortfield,$sortorder); //print_liste_field_titre($langs->trans("Invoices"),"","","",$paramlist,'align="left"',$sortfield,$sortorder); @@ -229,6 +233,9 @@ if ($resql) print ''; $form->select_types_paiements($search_paymenttype,'search_paymenttype','',2,1,1); print ''; + print ''; + print ''; $form->select_comptes($search_account,'search_account',0,'',1); print ''.$langs->trans("PaymentTypeShort".$objp->paiement_code).' '.$objp->num_paiement.''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.$objp->num_paiement.''; if ($objp->bid) { From f4d04b8f2656343d94e49ac116205428393843e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2016 02:41:07 +0100 Subject: [PATCH 40/41] FIX part of #4227 --- .../facture/class/facture-rec.class.php | 81 +++++++++++++------ 1 file changed, 57 insertions(+), 24 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 35238d71a2f..b9ec6df8d78 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -186,10 +186,13 @@ class FactureRec extends Facture /** * Recupere l'objet facture et ses lignes de factures * - * @param int $rowid Id de la facture a recuperer - * @return int >0 si ok, <0 si ko + * @param int $rowid Id of object to load + * @param string $ref Reference of invoice + * @param string $ref_ext External reference of invoice + * @param int $ref_int Internal reference of other object + * @return int >0 if OK, <0 if KO, 0 if not found */ - function fetch($rowid) + function fetch($rowid, $ref='', $ref_ext='', $ref_int='') { $sql = 'SELECT f.titre,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise'; $sql.= ', f.date_lim_reglement as dlr'; @@ -203,8 +206,13 @@ class FactureRec extends Facture $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; $sql.= ' WHERE f.rowid='.$rowid; - - dol_syslog("FactureRec::Fetch rowid=".$rowid."", LOG_DEBUG); + if ($ref) $sql.= " AND f.titre='".$this->db->escape($ref)."'"; + /* This field are not used for template invoice + if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; + */ + + dol_syslog(get_class($this)."::fetch rowid=".$rowid, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -353,32 +361,49 @@ class FactureRec extends Facture /** - * Delete current invoice + * Delete template invoice * - * @return int <0 if KO, >0 if OK + * @param int $rowid Id of invoice to delete. If empty, we delete current instance of invoice + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $idwarehouse Id warehouse to use for stock change. + * @return int <0 if KO, >0 if OK */ - function delete() + function delete($rowid=0, $notrigger=0, $idwarehouse=-1) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$this->id; + if (empty($rowid)) $rowid=$this->id; + + dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); + + $error=0; + $this->db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; dol_syslog($sql); if ($this->db->query($sql)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$rowid; dol_syslog($sql); - if ($this->db->query($sql)) - { - return 1; - } - else + if (! $this->db->query($sql)) { $this->error=$this->db->lasterror(); - return -1; + $error=-1; } } else { $this->error=$this->db->lasterror(); - return -2; + $error=-2; + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return $error; } } @@ -544,21 +569,29 @@ class FactureRec extends Facture /** * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param string $option Sur quoi pointe le lien ('', 'withdraw') - * @return string Chaine avec URL + * @param int $withpicto Add picto into link + * @param string $option Where point the link + * @param int $max Maxlength of ref + * @param int $short 1=Return just URL + * @param string $moretitle Add more text to title tooltip + * @return string String with URL */ - function getNomUrl($withpicto=0,$option='') + function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='') { global $langs; $result=''; $label=$langs->trans("ShowInvoice").': '.$this->ref; - - $link = ''; + + $url = DOL_URL_ROOT.'/compta/facture/fiche-rec.php?facid='.$this->id; + + if ($short) return $url; + + $picto='bill'; + + $link = ''; $linkend=''; - $picto='bill'; if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); From 19300a2d82e0621b8b3319119ab0731e22203c0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2016 03:10:58 +0100 Subject: [PATCH 41/41] Fix warning when javascript disabled --- htdocs/admin/barcode.php | 20 +++++++++++++++++-- htdocs/core/lib/functions.lib.php | 33 +++++++++++++++++-------------- htdocs/main.inc.php | 15 ++++++++------ 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 2fbd3de6a0f..b7cc6e94bf2 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -78,6 +78,11 @@ else if ($action == 'update') $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity); } } +else if ($action == 'updateengine') +{ + // TODO Update engines. + +} // define constants for models generator that need parameters if ($action == 'setModuleOptions') @@ -190,6 +195,10 @@ $var=true; print '
'; print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'',''); +print "
"; +print ''; +print ""; + print ''; print ''; print ''; @@ -282,11 +291,18 @@ if ($resql) } print "
'.$langs->trans("Name").'
\n"; +if (empty($conf->use_javascript_ajax)) +{ + // TODO Implement code behind action updateengine + //print '
'; +} +print '
'; + print "
"; + /* - * Autres options - * + * Other options */ print load_fiche_titre($langs->trans("OtherOptions"),'',''); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0b0615b69c8..73e42b22b33 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5109,21 +5109,24 @@ function printCommonFooter($zone='private') if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n"; print "\n"; - print ''."\n"; + if (! empty($conf->use_javascript_ajax)) + { + print ''."\n"; + } // Google Analytics (need Google module) if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID)) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 66899a8b2d0..bc91937d98f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1941,12 +1941,15 @@ if (! function_exists("llxFooter")) if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent; // Wrapper to show tooltips - print "\n\n"; - print '' . "\n"; + if ($conf->use_javascript_ajax) + { + print "\n\n"; + print '' . "\n"; + } // A div for the address popup print "\n\n";