26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
32$langs->loadLangs(array(
"banks",
"accountancy",
"compta",
"other",
"errors"));
35$action =
GETPOST(
'action',
'aZ09');
37$date_startmonth =
GETPOST(
'date_startmonth');
38$date_startday =
GETPOST(
'date_startday');
39$date_startyear =
GETPOST(
'date_startyear');
40$date_endmonth =
GETPOST(
'date_endmonth');
41$date_endday =
GETPOST(
'date_endday');
42$date_endyear =
GETPOST(
'date_endyear');
43$in_bookkeeping =
GETPOST(
'in_bookkeeping');
44if ($in_bookkeeping ==
'') {
45 $in_bookkeeping =
'notyet';
50$result =
$object->fetch($id_journal);
53} elseif ($result < 0) {
55} elseif ($result == 0) {
59$hookmanager->initHooks(array(
'globaljournal',
$object->nature.
'journal'));
62$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
63$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
68if (empty($date_startmonth)) {
71 $date_start = $dates[
'date_start'];
72 $pastmonthyear = $dates[
'pastmonthyear'];
73 $pastmonth = $dates[
'pastmonth'];
75if (empty($date_endmonth)) {
78 $date_end = $dates[
'date_end'];
79 $pastmonthyear = $dates[
'pastmonthyear'];
80 $pastmonth = $dates[
'pastmonth'];
83if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
89if ($action ==
'writebookkeeping') {
90 $data_type =
'bookkeeping';
92if ($action ==
'exportcsv') {
95$journal_data =
$object->getData($user, $data_type, $date_start, $date_end, $in_bookkeeping);
96if (!is_array($journal_data)) {
101if (!isModEnabled(
'accounting')) {
104if ($user->socid > 0) {
107if (!$user->hasRight(
'accounting',
'bind',
'write')) {
116$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
121if ($action ==
'writebookkeeping' && $user->hasRight(
'accounting',
'bind',
'write')) {
124 $result =
$object->writeIntoBookkeeping($user, $journal_data);
127 $error = abs($result);
130 $nb_elements = count($journal_data);
131 if (empty($error) && $nb_elements > 0) {
133 } elseif ($nb_elements == $error) {
136 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
140} elseif ($action ==
'exportcsv' && $user->hasRight(
'accounting',
'bind',
'write')) {
142 $result =
$object->exportCsv($journal_data, $date_end);
147 $filename =
'journal';
148 $type_export =
'journal';
150 require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
151 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
162 $param =
'id_journal=' . $id_journal;
163 $param .=
'&date_startday=' . $date_startday;
164 $param .=
'&date_startmonth=' . $date_startmonth;
165 $param .=
'&date_startyear=' . $date_startyear;
166 $param .=
'&date_endday=' . $date_endday;
167 $param .=
'&date_endmonth=' . $date_endmonth;
168 $param .=
'&date_endyear=' . $date_endyear;
169 $param .=
'&in_bookkeeping=' . $in_bookkeeping;
170 header(
"Location: " . $_SERVER[
'PHP_SELF'] . ($param ?
'?' . $param :
''));
179$form =
new Form($db);
184} elseif (
$object->nature == 3) {
187} elseif (
$object->nature == 4) {
193} elseif (
$object->nature == 5) {
197 $title =
$object->getLibType();
198 $some_mandatory_steps_of_setup_were_not_done =
false;
199 $account_accounting_not_defined =
false;
202$title = $langs->trans(
"GenerationOfAccountingEntries") .
' - ' .
$object->getNomUrl(0, 2, 1,
'', 1);
203$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
211$description = $langs->trans(
"DescJournalOnlyBindedVisible") .
'<br>';
214 $description .= $langs->trans(
"DepositsAreNotIncluded");
216 $description .= $langs->trans(
"DepositsAreIncluded");
219 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
223$listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
224$period = $form->selectDate($date_start ? $date_start : -1,
'date_start', 0, 0, 0,
'', 1, 0) .
' - ' . $form->selectDate($date_end ? $date_end : -1,
'date_end', 0, 0, 0,
'', 1, 0);
225$period .=
' - ' . $langs->trans(
"JournalizationInLedgerStatus") .
' ' . $form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
227$varlink =
'id_journal=' . $id_journal;
229journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
234 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
235 $resql = $db->query($sql);
237 $obj = $db->fetch_object($resql);
239 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
240 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
241 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
252 $sql =
"SELECT COUNT(rowid) as nb";
253 $sql .=
" FROM " . MAIN_DB_PREFIX .
"bank_account";
254 $sql .=
" WHERE entity = " . (int) $conf->entity;
255 $sql .=
" AND fk_accountancy_journal IS NULL";
256 $sql .=
" AND clos=0";
257 $resql = $db->query($sql);
259 $obj = $db->fetch_object($resql);
261 print
'<br>' .
img_warning() .
' ' . $langs->trans(
"TheJournalCodeIsNotDefinedOnSomeBankAccount");
262 print
' : ' . $langs->trans(
"AccountancyAreaDescBank", 9,
'<strong>' . $langs->transnoentitiesnoconv(
"MenuAccountancy") .
'-' . $langs->transnoentitiesnoconv(
"Setup") .
"-" . $langs->transnoentitiesnoconv(
"BankAccounts") .
'</strong>');
270if ($some_mandatory_steps_of_setup_were_not_done) {
271 print
'<br><div class="warning">' .
img_warning() .
' ' . $langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
272 print
' : ' . $langs->trans(
"AccountancyAreaDescMisc", 4,
'<strong>' . $langs->transnoentitiesnoconv(
"MenuAccountancy") .
'-' . $langs->transnoentitiesnoconv(
"Setup") .
"-" . $langs->transnoentitiesnoconv(
"MenuDefaultAccounts") .
'</strong>');
275print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
276if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
277 print
'<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans(
"ExportDraftJournal") .
'" onclick="launch_export();" />';
279if ($account_accounting_not_defined) {
280 print
'<input type="button" class="butActionRefused classfortooltip" title="' .
dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")) .
'" value="' . $langs->trans(
"WriteBookKeeping") .
'" />';
282 if ($in_bookkeeping ==
'notyet') {
283 print
'<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans(
"WriteBookKeeping") .
'" onclick="writebookkeeping();" />';
285 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans(
"WriteBookKeeping") .
'</a>';
292 <script type="text/javascript">
293 function launch_export() {
294 $("div.fiche form input[name=\"action\"]").val("exportcsv");
295 $("div.fiche form input[type=\"submit\"]").click();
296 $("div.fiche form input[name=\"action\"]").val("");
298 function writebookkeeping() {
299 console.log("click on writebookkeeping");
300 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
301 $("div.fiche form input[type=\"submit\"]").click();
302 $("div.fiche form input[name=\"action\"]").val("");
306$object_label = $langs->trans(
"ObjectsRef");
308 $object_label = $langs->trans(
"InvoiceRef");
311 $object_label = $langs->trans(
"ExpenseReportRef");
320print
'<div class="div-table-responsive">';
321print
'<table class="noborder centpercent">';
322print
'<tr class="liste_titre">';
323print
'<td>' . $langs->trans(
"Date") .
'</td>';
324print
'<td>' . $langs->trans(
"Piece") .
' (' . $object_label .
')</td>';
325print
'<td>' . $langs->trans(
"AccountAccounting") .
'</td>';
326print
'<td>' . $langs->trans(
"SubledgerAccount") .
'</td>';
327print
'<td>' . $langs->trans(
"LabelOperation") .
'</td>';
329 print
'<td class="center">' . $langs->trans(
"PaymentMode") .
'</td>';
331print
'<td class="right">' . $langs->trans(
"AccountingDebit") .
'</td>';
332print
'<td class="right">' . $langs->trans(
"AccountingCredit") .
'</td>';
335if (is_array($journal_data) && !empty($journal_data)) {
336 foreach ($journal_data as $element_id => $element) {
337 foreach ($element[
'blocks'] as $lines) {
338 foreach ($lines as $line) {
339 print
'<tr class="oddeven">';
340 print
'<td>' . $line[
'date'] .
'</td>';
341 print
'<td>' . $line[
'piece'] .
'</td>';
342 print
'<td>' . $line[
'account_accounting'] .
'</td>';
343 print
'<td>' . $line[
'subledger_account'] .
'</td>';
344 print
'<td>' . $line[
'label_operation'] .
'</td>';
346 print
'<td class="center">' . $line[
'payment_mode'] .
'</td>';
348 print
'<td class="right nowraponall">' . $line[
'debit'] .
'</td>';
349 print
'<td class="right nowraponall">' . $line[
'credit'] .
'</td>';
363 print
'<tr class="oddeven"><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='', $moreoptions=array())
Show header of a page used to transfer/dispatch data in accounting.
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage accounting journals.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.