27require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
42$langs->loadLangs(array(
"banks",
"accountancy",
"compta",
"other",
"errors"));
45$action =
GETPOST(
'action',
'aZ09');
47$date_startmonth =
GETPOSTINT(
'date_startmonth');
53$in_bookkeeping =
GETPOST(
'in_bookkeeping');
54if ($in_bookkeeping ==
'') {
55 $in_bookkeeping =
'notyet';
60$result =
$object->fetch($id_journal);
63} elseif ($result < 0) {
65} elseif ($result == 0) {
69$hookmanager->initHooks(array(
'globaljournal',
$object->nature.
'journal'));
72$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
73$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
78if (empty($date_startmonth)) {
81 $date_start = $dates[
'date_start'];
82 $pastmonthyear = $dates[
'pastmonthyear'];
83 $pastmonth = $dates[
'pastmonth'];
85if (empty($date_endmonth)) {
88 $date_end = $dates[
'date_end'];
89 $pastmonthyear = $dates[
'pastmonthyear'];
90 $pastmonth = $dates[
'pastmonth'];
93if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
99if ($action ==
'writebookkeeping') {
100 $data_type =
'bookkeeping';
102if ($action ==
'exportcsv') {
105$journal_data =
$object->getData($user, $data_type, $date_start, $date_end, $in_bookkeeping);
106if (!is_array($journal_data)) {
111if (!isModEnabled(
'accounting')) {
114if ($user->socid > 0) {
117if (!$user->hasRight(
'accounting',
'bind',
'write')) {
126$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
131if ($action ==
'writebookkeeping' && $user->hasRight(
'accounting',
'bind',
'write')) {
134 $result =
$object->writeIntoBookkeeping($user, $journal_data);
137 $error = abs($result);
140 $nb_elements = count($journal_data);
141 if (empty($error) && $nb_elements > 0) {
143 } elseif ($nb_elements == $error) {
146 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
150} elseif ($action ==
'exportcsv' && $user->hasRight(
'accounting',
'bind',
'write')) {
152 $result =
$object->exportCsv($journal_data, $date_end);
157 $filename =
'journal';
158 $type_export =
'journal';
160 require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
161 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
172 $param =
'id_journal=' . $id_journal;
173 $param .=
'&date_startday=' . $date_startday;
174 $param .=
'&date_startmonth=' . $date_startmonth;
175 $param .=
'&date_startyear=' . $date_startyear;
176 $param .=
'&date_endday=' . $date_endday;
177 $param .=
'&date_endmonth=' . $date_endmonth;
178 $param .=
'&date_endyear=' . $date_endyear;
179 $param .=
'&in_bookkeeping=' . $in_bookkeeping;
180 header(
"Location: " . $_SERVER[
'PHP_SELF'] . ($param ?
'?' . $param :
''));
189$form =
new Form($db);
194} elseif (
$object->nature == 3) {
197} elseif (
$object->nature == 4) {
203} elseif (
$object->nature == 5) {
207 $title =
$object->getLibType();
208 $some_mandatory_steps_of_setup_were_not_done =
false;
209 $account_accounting_not_defined =
false;
212$title = $langs->trans(
"GenerationOfAccountingEntries") .
' - ' .
$object->getNomUrl(0, 2, 1,
'', 1);
213$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
221$description = $langs->trans(
"DescJournalOnlyBindedVisible") .
'<br>';
224 $description .= $langs->trans(
"DepositsAreNotIncluded");
226 $description .= $langs->trans(
"DepositsAreIncluded");
229 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
233$listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
234$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);
235$period .=
' - ' . $langs->trans(
"JournalizationInLedgerStatus") .
' ' . $form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
237$varlink =
'id_journal=' . $id_journal;
239journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
244 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int)
$conf->entity);
245 $resql = $db->query($sql);
247 $obj = $db->fetch_object($resql);
249 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
250 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
251 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
262 $sql =
"SELECT COUNT(rowid) as nb";
263 $sql .=
" FROM " . MAIN_DB_PREFIX .
"bank_account";
264 $sql .=
" WHERE entity = " . (int)
$conf->entity;
265 $sql .=
" AND fk_accountancy_journal IS NULL";
266 $sql .=
" AND clos=0";
267 $resql = $db->query($sql);
269 $obj = $db->fetch_object($resql);
271 print
'<br>' .
img_warning() .
' ' . $langs->trans(
"TheJournalCodeIsNotDefinedOnSomeBankAccount");
272 print
' : ' . $langs->trans(
"AccountancyAreaDescBank", 9,
'<strong>' . $langs->transnoentitiesnoconv(
"MenuAccountancy") .
'-' . $langs->transnoentitiesnoconv(
"Setup") .
"-" . $langs->transnoentitiesnoconv(
"BankAccounts") .
'</strong>');
280if ($some_mandatory_steps_of_setup_were_not_done) {
281 print
'<br><div class="warning">' .
img_warning() .
' ' . $langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
282 print
' : ' . $langs->trans(
"AccountancyAreaDescMisc", 4,
'<strong>' . $langs->transnoentitiesnoconv(
"MenuAccountancy") .
'-' . $langs->transnoentitiesnoconv(
"Setup") .
"-" . $langs->transnoentitiesnoconv(
"MenuDefaultAccounts") .
'</strong>');
285print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
286if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
287 print
'<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans(
"ExportDraftJournal") .
'" onclick="launch_export();" />';
289if ($account_accounting_not_defined) {
290 print
'<input type="button" class="butActionRefused classfortooltip" title="' .
dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")) .
'" value="' . $langs->trans(
"WriteBookKeeping") .
'" />';
292 if ($in_bookkeeping ==
'notyet') {
293 print
'<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans(
"WriteBookKeeping") .
'" onclick="writebookkeeping();" />';
295 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans(
"WriteBookKeeping") .
'</a>';
302 <script type="text/javascript">
303 function launch_export() {
304 $("div.fiche form input[name=\"action\"]").val("exportcsv");
305 $("div.fiche form input[type=\"submit\"]").click();
306 $("div.fiche form input[name=\"action\"]").val("");
308 function writebookkeeping() {
309 console.log("click on writebookkeeping");
310 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
311 $("div.fiche form input[type=\"submit\"]").click();
312 $("div.fiche form input[name=\"action\"]").val("");
316$object_label = $langs->trans(
"ObjectsRef");
318 $object_label = $langs->trans(
"InvoiceRef");
321 $object_label = $langs->trans(
"ExpenseReportRef");
330print
'<div class="div-table-responsive">';
331print
'<table class="noborder centpercent">';
332print
'<tr class="liste_titre">';
333print
'<td>' . $langs->trans(
"Date") .
'</td>';
334print
'<td>' . $langs->trans(
"Piece") .
' (' . $object_label .
')</td>';
335print
'<td>' . $langs->trans(
"AccountAccounting") .
'</td>';
336print
'<td>' . $langs->trans(
"SubledgerAccount") .
'</td>';
337print
'<td>' . $langs->trans(
"LabelOperation") .
'</td>';
339 print
'<td class="center">' . $langs->trans(
"PaymentMode") .
'</td>';
341print
'<td class="right">' . $langs->trans(
"AccountingDebit") .
'</td>';
342print
'<td class="right">' . $langs->trans(
"AccountingCredit") .
'</td>';
345if (is_array($journal_data) && !empty($journal_data)) {
346 foreach ($journal_data as $element_id => $element) {
347 foreach ($element[
'blocks'] as $lines) {
348 foreach ($lines as $line) {
349 print
'<tr class="oddeven">';
350 print
'<td>' . $line[
'date'] .
'</td>';
351 print
'<td>' . $line[
'piece'] .
'</td>';
352 print
'<td>' . $line[
'account_accounting'] .
'</td>';
353 print
'<td>' . $line[
'subledger_account'] .
'</td>';
354 print
'<td>' . $line[
'label_operation'] .
'</td>';
356 print
'<td class="center">' . $line[
'payment_mode'] .
'</td>';
358 print
'<td class="right nowraponall">' . $line[
'debit'] .
'</td>';
359 print
'<td class="right nowraponall">' . $line[
'credit'] .
'</td>';
373 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.