diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 0a4db2f84e4..42328fbc1ed 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -87,7 +87,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if ($sortorder == "") $sortorder = "ASC"; -if ($sortfield == "") $sortfield = "t.rowid"; +if ($sortfield == "") $sortfield = "t.piece_num,t.rowid"; $object = new BookKeeping($db); @@ -98,25 +98,30 @@ $form = new Form($db); if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page','int') == '' && ! GETPOST('noreset','int')) { - $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; - $res = $db->query($query); - if ($res->num_rows > 0) { - $fiscalYear = $db->fetch_object($res); - $search_date_start = strtotime($fiscalYear->date_start); - $search_date_end = strtotime($fiscalYear->date_end); - } else { - $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); - $year_start = dol_print_date(dol_now(), '%Y'); - $year_end = $year_start + 1; - $month_end = $month_start - 1; - if ($month_end < 1) - { - $month_end = 12; - $year_end--; + if (empty($search_date_start) && empty($search_date_end)) + { + $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; + $query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; + $res = $db->query($query); + + if ($res->num_rows > 0) { + $fiscalYear = $db->fetch_object($res); + $search_date_start = strtotime($fiscalYear->date_start); + $search_date_end = strtotime($fiscalYear->date_end); + } else { + $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + $year_end = $year_start + 1; + $month_end = $month_start - 1; + if ($month_end < 1) + { + $month_end = 12; + $year_end--; + } + $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); + $search_date_end = dol_get_last_day($year_end, $month_end); } - $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); - $search_date_end = dol_get_last_day($year_end, $month_end); } } @@ -124,7 +129,7 @@ if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! $arrayfields=array( 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), - 't.doc_ref'=>array('label'=>$langs->trans("Docref"), 'checked'=>1), + 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), 't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1), 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), @@ -430,7 +435,7 @@ else $button.= $langs->trans("ExportList"); $button.= ''; -$groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; +$groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; $addbutton = '' . $langs->trans("NewAccountingMvt") . ''; print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby.$addbutton, '', $limit); @@ -576,17 +581,17 @@ print ''; print "\n"; print ''; -if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre("Docref", $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre("SubledgerAccount", $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); -if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); -if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre("DateCreation", $_SERVER['PHP_SELF'], "t.date_creation", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre("DateModification", $_SERVER['PHP_SELF'], "t.tms", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); +if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); +if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -677,14 +682,14 @@ if ($num > 0) // Creation operation date if (! empty($arrayfields['t.date_creation']['checked'])) { - print '' . dol_print_date($line->date_creation, 'day') . ''; + print '' . dol_print_date($line->date_creation, 'dayhour') . ''; if (! $i) $totalarray['nbfield']++; } // Modification operation date if (! empty($arrayfields['t.tms']['checked'])) { - print '' . dol_print_date($line->date_modification, 'day') . ''; + print '' . dol_print_date($line->date_modification, 'dayhour') . ''; if (! $i) $totalarray['nbfield']++; } @@ -704,6 +709,7 @@ if ($num > 0) if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield'])) { $i=0; + print ''; while ($i < $totalarray['nbfield']) { $i++; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 08aa1aac19d..c450fb5bb63 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -68,7 +68,7 @@ $pagenext = $page + 1; if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") $sortfield = "t.rowid"; -if (empty($search_date_start)) { +if (empty($search_date_start) && empty($search_date_end)) { $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; $sql.= $db->plimit(1); @@ -81,6 +81,7 @@ if (empty($search_date_start)) { } else { $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year $year_end = $year_start + 1; $month_end = $month_start - 1; if ($month_end < 1) @@ -225,14 +226,13 @@ if ($action == 'delbookkeepingyear') { } - +$param=$options; print '
'; -$viewflat = ' ' . $langs->trans("ViewFlatList") . ''; +$viewflat = ' ' . $langs->trans("ViewFlatList") . ''; $addbutton = '' . $langs->trans("NewAccountingMvt") . ''; -$param=$options; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 4aba5bb0591..b59258f6cd7 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -781,7 +781,8 @@ class BookKeeping extends CommonObject $sql .= " t.code_journal,"; $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; - $sql .= " t.date_creation"; + $sql .= " t.date_creation,"; + $sql .= " t.tms as date_modification"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; // Manage filter $sqlwhere = array (); @@ -849,7 +850,8 @@ class BookKeeping extends CommonObject $line->code_journal = $obj->code_journal; $line->journal_label = $obj->journal_label; $line->piece_num = $obj->piece_num; - $line->date_creation = $obj->date_creation; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_modification = $this->db->jdate($obj->date_modification); $this->lines[] = $line; } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index b9b079067b8..fcb24f7757a 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -303,6 +303,7 @@ if ($result) { } $chargestatic->ref = $chargestatic->lib; $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); + $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; $sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; @@ -401,7 +402,9 @@ if (! $error && $action == 'writebookkeeping') { $now = dol_now(); $error = 0; - foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank + foreach ( $tabpay as $key => $val ) // $key is rowid into llx_bank + { + $date = dol_print_date($db->jdate($val["date"]), 'day'); $ref = getSourceDocRef($val, $tabtype[$key]); @@ -423,7 +426,14 @@ if (! $error && $action == 'writebookkeeping') { // Line into bank account foreach ( $tabbq[$key] as $k => $mt ) { - if ($mt) { + if ($mt) + { + $reflabel = $langs->trans("Bank"); + $reflabel.= ' '.$val['bank_account_ref']; + if (! empty($val['soclib'])) { + $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); + } + $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $ref; @@ -442,31 +452,8 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->date_create = $now; // No subledger_account value for the bank line but add a specific label_operation - if ($tabtype[$key] == 'payment') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; - } else if ($tabtype[$key] == 'payment_supplier') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; - } else if ($tabtype[$key] == 'payment_expensereport') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; - } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; - } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $ref; - } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $ref; - } else if ($tabtype[$key] == 'payment_various') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $ref; - } else if ($tabtype[$key] == 'unknown') { - // ??? - $bookkeeping->subledger_account = ''; - } + $bookkeeping->subledger_account = ''; + $bookkeeping->label_operation = $reflabel; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -491,108 +478,151 @@ if (! $error && $action == 'writebookkeeping') { } // Third party - if (! $errorforline && is_array($tabtp[$key])) + if (! $errorforline) { - // Line into thirdparty account - foreach ( $tabtp[$key] as $k => $mt ) { - if ($mt) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $ref; - $bookkeeping->doc_type = 'bank'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_bank"]; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0 ? - $mt : 0); - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; - $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; - $bookkeeping->fk_user_author = $user->id; - $bookkeeping->date_create = $now; + if (is_array($tabtp[$key])) + { + // Line into thirdparty account + foreach ( $tabtp[$key] as $k => $mt ) { + if ($mt) + { + $reflabel = dol_string_nohtmltag($val['soclib']); - if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; - $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; - $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_expensereport') { - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; - $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; - $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->label_compte = ''; - } else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $objmid->labelc; - } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_various') { - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'banktransfert') { - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = ''; - } else { - if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty. - { - // Temporary account - $bookkeeping->label_operation = ''; + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $ref; + $bookkeeping->doc_type = 'bank'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0 ? - $mt : 0); + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + $bookkeeping->date_create = $now; + + if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_expensereport') { + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_label = $tabuser[$key]['name']; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_salary') { + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_label = $tabuser[$key]['name']; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_compte = ''; + } else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $objmid->labelc; + } else if ($tabtype[$key] == 'payment_vat') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_donation') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_various') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'banktransfert') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; + } else { + if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty. + { + // Temporary account + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; + $bookkeeping->label_compte = ''; + } + } + + $bookkeeping->label_operation = $reflabel; + + $totaldebit += $bookkeeping->debit; + $totalcredit += $bookkeeping->credit; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } } } + } + } + else { // If thirdparty unkown, output the waiting account + foreach ( $tabbq[$key] as $k => $mt ) { + if ($mt) + { + $reflabel = 'WaitingAccount'; - $totaldebit += $bookkeeping->debit; - $totalcredit += $bookkeeping->credit; + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $ref; + $bookkeeping->doc_type = 'bank'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0 ? - $mt : 0); + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + $bookkeeping->date_create = $now; + $bookkeeping->label_compte = ''; - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + $bookkeeping->label_operation = $reflabel; + + $totaldebit += $bookkeeping->debit; + $totalcredit += $bookkeeping->credit; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } } } } @@ -662,101 +692,102 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - $companystatic = new Client($db); - $userstatic = new User($db); + // CSV header line + print '"' . $langs->trans("BankId").'"' . $sep; + print '"' . $langs->trans("Date") . '"' . $sep; + print '"' . $langs->trans("PaymentMode") . '"' . $sep; + print '"' . $langs->trans("AccountAccounting") . '"' . $sep; + print '"' . $langs->trans("LedgerAccount") . '"' . $sep; + print '"' . $langs->trans("SubledgerAccount") . '"' . $sep; + print '"' . $langs->trans("Label"). '"' . $sep; + print '"' . $langs->trans("Amount") . '"' . $sep; + print '"' . $langs->trans("Amount") . '"' . $sep; + print '"' . $langs->trans("Journal") . '"' . $sep; + print '"' . $langs->trans("Note") . '"' . $sep; + print "\n"; - foreach ( $tabpay as $key => $val ) { + + foreach ( $tabpay as $key => $val ) + { $date = dol_print_date($db->jdate($val["date"]), 'day'); $ref = getSourceDocRef($val, $tabtype[$key]); - // - if (! empty($tabcompany[$key]['id'])) - { - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - } - else - { - $companystatic->id = 0; - $companystatic->name = ''; - } - if (! empty($tabuser[$key]['id'])) - { - $userstatic->id = $tabuser[$key]['id']; - $userstatic->lastname = $tabuser[$key]['lastname']; - $userstatic->firstname = $tabuser[$key]['firstname']; - } - else - { - $userstatic->id = 0; - $userstatic->lastname = ''; - $userstatic->firstname = ''; - } - // Bank foreach ( $tabbq[$key] as $k => $mt ) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["type_payment"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print " " . $sep; - if ($companystatic->name == '') { - print '"' . $val['bank_account_ref'] . " - " . utf8_decode($reflabel) . '"' . $sep; - } else { - print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; + if ($mt) + { + $reflabel = $langs->trans("Bank"); + $reflabel.= ' '.$val['bank_account_ref']; + if (! empty($val['soclib'])) { + $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); + } + + print '"' . $key . '"' . $sep; + print '"' . $date . '"' . $sep; + print '"' . $val["type_payment"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print " " . $sep; + print '"' . $reflabel . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . $journal . '"' . $sep; + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; + print "\n"; } - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . $journal . '"' . $sep; - print "\n"; } // Third party if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { - if ($mt) { + if ($mt) + { + $reflabel = dol_string_nohtmltag($val['soclib']); + print '"' . $key . '"' . $sep; print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; if ($tabtype[$key] == 'payment_supplier') { - print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; + print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; } else if($tabtype[$key] == 'payment') { - print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; + print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; + } else if($tabtype[$key] == 'payment_expensereport') { + print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep; + } else if($tabtype[$key] == 'payment_salary') { + print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep; } else { - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; } print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - if ($companystatic->name == '') { - print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($reflabel) . '"' . $sep; - } else { - print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep; - } + print '"' . $reflabel . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . $journal . '"' . $sep; + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; print "\n"; } } - } else { + } else { // If thirdparty unkown, output the waiting account foreach ( $tabbq[$key] as $k => $mt ) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["type_payment"] . '"' . $sep; - print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; - print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; - print " " . $sep; - if ($companystatic->name == '') { - print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($reflabel) . '"' . $sep; - } else { - print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; + if ($mt) + { + $reflabel = 'WaitingAccount'; + + print '"' . $key . '"' . $sep; + print '"' . $date . '"' . $sep; + print '"' . $val["type_payment"] . '"' . $sep; + print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; + print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; + print "" . $sep; + print '"' . $reflabel . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . $journal . '"' . $sep; + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; + print "\n"; } - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . $journal . '"' . $sep; - print "\n"; } } } @@ -862,7 +893,8 @@ if (empty($action) || $action == 'view') { $r = ''; - foreach ( $tabpay as $key => $val ) { // $key is rowid in llx_bank + foreach ( $tabpay as $key => $val ) // $key is rowid in llx_bank + { $date = dol_print_date($db->jdate($val["date"]), 'day'); $ref = getSourceDocRef($val, $tabtype[$key]); @@ -870,48 +902,55 @@ if (empty($action) || $action == 'view') { // Bank foreach ( $tabbq[$key] as $k => $mt ) { - //var_dump($tabpay[$key]); - print ''; - print ''; - print ""; - print "" . $date . ""; - print "" . $ref . ""; - // Ledger account - print ""; - $accounttoshow = length_accountg($k); - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + if ($mt) { - print ''.$langs->trans("BankAccountNotDefined").''; + $reflabel = $langs->trans("Bank"); + $reflabel.= ' '.$val['bank_account_ref']; + if (! empty($val['soclib'])) { + $reflabel .= " - " . $val['soclib']; + } + + //var_dump($tabpay[$key]); + print ''; + print ''; + print ""; + print "" . $date . ""; + print "" . $ref . ""; + // Ledger account + print ""; + $accounttoshow = length_accountg($k); + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + { + print ''.$langs->trans("BankAccountNotDefined").''; + } + else print $accounttoshow; + print ""; + // Subledger account + print ""; + /*$accounttoshow = length_accountg($k); + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + { + print ''.$langs->trans("BankAccountNotDefined").''; + } + else print $accounttoshow;*/ + print ""; + print ""; + print $reflabel; + print ""; + print "" . $val["type_payment"] . ""; + print "" . ($mt >= 0 ? price($mt) : '') . ""; + print "" . ($mt < 0 ? price(- $mt) : '') . ""; + print ""; } - else print $accounttoshow; - print ""; - // Subledger account - print ""; - /*$accounttoshow = length_accountg($k); - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') - { - print ''.$langs->trans("BankAccountNotDefined").''; - } - else print $accounttoshow;*/ - print ""; - print ""; - //var_dump($tabpay[$key]); - print $langs->trans("Bank"); - print ' '.$val['bank_account_ref']; - if (! empty($val['soclib'])) { - print " - " . $val['soclib']; - } - print ""; - print "" . $val["type_payment"] . ""; - print "" . ($mt >= 0 ? price($mt) : '') . ""; - print "" . ($mt < 0 ? price(- $mt) : '') . ""; - print ""; } // Third party if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { - if ($k != 'type') { + if ($mt) + { + $reflabel = $val['soclib']; + print ''; print ''; print ""; @@ -974,42 +1013,47 @@ if (empty($action) || $action == 'view') { } } print ""; - print "" . $reflabel . ' ' . $val['soclib'] . ""; + print "" . $reflabel . ""; print "" . $val["type_payment"] . ""; print "" . ($mt < 0 ? price(- $mt) : '') . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; print ""; } } - } else { + } else { // Waiting account foreach ( $tabbq[$key] as $k => $mt ) { - print ''; - print ''; - print ""; - print "" . $date . ""; - print "" . $ref . ""; - // Ledger account - print ""; - /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + if ($mt) { - print ''.$langs->trans("WaitAccountNotDefined").''; + $reflabel = 'WaitingAccount'; + + print ''; + print ''; + print ""; + print "" . $date . ""; + print "" . $ref . ""; + // Ledger account + print ""; + /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + { + print ''.$langs->trans("WaitAccountNotDefined").''; + } + else */ print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); + print ""; + // Subledger account + print ""; + /*if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') + { + print ''.$langs->trans("WaitAccountNotDefined").''; + } + else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); + */ + print ""; + print "" . $reflabel . ""; + print "" . $val["type_payment"] . ""; + print "" . ($mt < 0 ? price(- $mt) : '') . ""; + print "" . ($mt >= 0 ? price($mt) : '') . ""; + print ""; } - else */ print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); - print ""; - // Subledger account - print ""; - /*if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') - { - print ''.$langs->trans("WaitAccountNotDefined").''; - } - else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); - */ - print ""; - print "" . $reflabel . ""; - print "" . $val["type_payment"] . ""; - print "" . ($mt < 0 ? price(- $mt) : '') . ""; - print "" . ($mt >= 0 ? price($mt) : '') . ""; - print ""; } } } @@ -1089,6 +1133,13 @@ function getSourceDocRef($val, $typerecord) $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; $ref = $langs->trans("SalaryPayment"); } + elseif ($typerecord == 'sc') + { + $sqlmid = 'SELECT sc.rowid as ref'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementcharge as sc"; + $sqlmid .= " WHERE sc.rowid=" . $val["paymentscid"]; + $ref = $langs->trans("SocialContribution"); + } elseif ($typerecord == 'payment_vat') { $sqlmid = 'SELECT v.rowid as ref'; diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php index 85603de2ae5..f5a3624939d 100644 --- a/htdocs/admin/salaries.php +++ b/htdocs/admin/salaries.php @@ -39,8 +39,7 @@ $action = GETPOST('action', 'alpha'); // Other parameters SALARIES_* $list = array ( - 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', - 'SALARIES_ACCOUNTING_ACCOUNT_CHARGE' + 'SALARIES_XXX', ); /* @@ -97,7 +96,7 @@ print "\n"; foreach ($list as $key) { - + print ''; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index c3a7d3a7c56..92a38059a1e 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -423,9 +423,11 @@ class pdf_einstein extends ModelePDFCommandes { $pdf->commitTransaction(); } + $posYAfterDescription=$pdf->GetY(); $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); + $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. @@ -614,13 +616,13 @@ class pdf_einstein extends ModelePDFCommandes } else { - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); + $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); return 0; } } diff --git a/htdocs/core/modules/expensereport/modules_expensereport.php b/htdocs/core/modules/expensereport/modules_expensereport.php index e0adf1fb47e..e97766b38f6 100644 --- a/htdocs/core/modules/expensereport/modules_expensereport.php +++ b/htdocs/core/modules/expensereport/modules_expensereport.php @@ -122,11 +122,10 @@ abstract class ModeleNumRefExpenseReport /** * Renvoie prochaine valeur attribuee * - * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc,$object) + function getNextValue($object) { global $langs; return $langs->trans("NotAvailable"); @@ -148,4 +147,4 @@ abstract class ModeleNumRefExpenseReport if ($this->version) return $this->version; return $langs->trans("NotAvailable"); } -} \ No newline at end of file +} diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index e037b35728e..aecb9eeb49f 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -67,7 +67,8 @@ class modSalaries extends DolibarrModules $this->dirs = array("/salaries/temp"); // Config pages - $this->config_page_url = array('salaries.php'); + //$this->config_page_url = array('salaries.php'); + $this->config_page_url = array(); // Dependencies $this->depends = array(); diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index b2ad0f26c0e..761bf3fcafd 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -19,7 +19,7 @@ /** * \file htdocs/core/modules/project/doc/pdf_baleine.modules.php * \ingroup project - * \brief Fichier de la classe permettant de generer les projets au modele Baleine + * \brief File of class to generate project document Baleine * \author Regis Houssin */ @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** - * Classe permettant de generer les projets au modele Baleine + * Class to manage generation of project document Baleine */ class pdf_baleine extends ModelePDFProjects @@ -78,10 +78,19 @@ class pdf_baleine extends ModelePDFProjects // Defini position des colonnes $this->posxref=$this->marge_gauche+1; $this->posxlabel=$this->marge_gauche+25; - $this->posxworkload=$this->marge_gauche+100; - $this->posxprogress=$this->marge_gauche+130; - $this->posxdatestart=$this->marge_gauche+150; + $this->posxworkload=$this->marge_gauche+120; + $this->posxprogress=$this->marge_gauche+140; + $this->posxdatestart=$this->marge_gauche+152; $this->posxdateend=$this->marge_gauche+170; + if ($this->page_largeur < 210) // To work with US executive format + { + $this->posxref-=20; + $this->posxlabel-=20; + $this->posxworkload-=20; + $this->posxprogress-=20; + $this->posxdatestart-=20; + $this->posxdateend-=20; + } } @@ -136,12 +145,14 @@ class pdf_baleine extends ModelePDFProjects global $action; $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part + // Create pdf instance + $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf->SetAutoPageBreak(1,0); + + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - $pdf->SetAutoPageBreak(1,0); if (class_exists('TCPDF')) { @@ -149,6 +160,12 @@ class pdf_baleine extends ModelePDFProjects $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } // Complete object by loading several other informations $task = new Task($this->db); @@ -177,6 +194,7 @@ class pdf_baleine extends ModelePDFProjects // New page $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); @@ -184,21 +202,28 @@ class pdf_baleine extends ModelePDFProjects $pdf->SetTextColor(0,0,0); $tab_top = 50; - $tab_height = 200; - $tab_top_newpage = 40; - $tab_height_newpage = 210; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_height = 170; + $tab_height_newpage = 190; - // Affiche notes - if (! empty($object->note_public)) + // Show public note + $notetoshow=empty($object->note_public)?'':$object->note_public; + if ($notetoshow) { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + + $tab_top -= 2; + $pdf->SetFont('','', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-($tab_top-2); + $height_note=$nexY-$tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); - $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; @@ -208,44 +233,126 @@ class pdf_baleine extends ModelePDFProjects $height_note=0; } - $iniY = $tab_top + 7; - $curY = $tab_top + 7; - $nexY = $tab_top + 7; + $heightoftitleline = 10; + $iniY = $tab_top + $heightoftitleline + 1; + $curY = $tab_top + $heightoftitleline + 1; + $nexY = $tab_top + $heightoftitleline + 1; - // Boucle sur les lignes + // Loop on each lines for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); - // Description of ligne + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore=$pdf->getPage(); + + // Description of line $ref=$object->lines[$i]->ref; $libelleline=$object->lines[$i]->label; - $progress=$object->lines[$i]->progress.'%'; + $progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':''); $datestart=dol_print_date($object->lines[$i]->date_start,'day'); $dateend=dol_print_date($object->lines[$i]->date_end,'day'); $planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin'); - $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page + $showpricebeforepagebreak=1; - $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); + $pdf->startTransaction(); + // Label $pdf->SetXY($this->posxlabel, $curY); $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + // Label + $pdf->SetXY($this->posxlabel, $curY); + $posybefore=$pdf->GetY(); + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + $forcedesconsamepage=1; + if ($forcedesconsamepage) + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); + + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $curY = $tab_top_newpage + $heightoftitleline + 1; + + // Label + $pdf->SetXY($this->posxlabel, $curY); + $posybefore=$pdf->GetY(); + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + } + } + //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription=$pdf->GetY(); + + $nexY = $pdf->GetY(); + $pageposafter=$pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); + $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; + } + + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + + // Ref of task + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); + // Workload $pdf->SetXY($this->posxworkload, $curY); - $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload, 0, 'R'); + $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R'); + // Progress $pdf->SetXY($this->posxprogress, $curY); $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R'); - + // Date $pdf->SetXY($this->posxdatestart, $curY); $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C'); $pdf->SetXY($this->posxdateend, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C'); - $pageposafter=$pdf->getPage(); - - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut - $nexY = $pdf->GetY(); - // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) { @@ -274,6 +381,7 @@ class pdf_baleine extends ModelePDFProjects $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { @@ -290,44 +398,33 @@ class pdf_baleine extends ModelePDFProjects $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } } // Show square if ($pagenb == 1) - { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } else - { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - /* - * Pied de page - */ - $this->_pagefoot($pdf,$object,$outputlangs); - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + // Pied de page + $this->_pagefoot($pdf, $object, $outputlangs); + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); - $pdf->Output($file,'F'); + $pdf->Output($file, 'F'); // Add pdfgeneration hook - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); @@ -339,9 +436,11 @@ class pdf_baleine extends ModelePDFProjects return 0; } } - - $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); - return 0; + else + { + $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR"); + return 0; + } } @@ -361,14 +460,17 @@ class pdf_baleine extends ModelePDFProjects { global $conf,$mysoc; + $heightoftitleline = 10; + $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetDrawColor(128,128,128); - // Rect prend une longueur en 3eme param + // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); + // line prend une position y en 3eme param - $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); + $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline); $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size); @@ -390,7 +492,6 @@ class pdf_baleine extends ModelePDFProjects $pdf->SetXY($this->posxdateend, $tab_top+1); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); - } /** @@ -447,10 +548,18 @@ class pdf_baleine extends ModelePDFProjects $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R'); + $posy+=6; $pdf->SetXY($posx,$posy); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); + if (is_object($object->thirdparty)) + { + $posy+=6; + $pdf->SetXY($posx,$posy); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R'); + } + $pdf->SetTextColor(0,0,60); // Add list of linked objects diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 2a3372ed847..f1db7ea1cf3 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -1,7 +1,7 @@ # Dolibarr language file - Source file is en_US - salaries SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated user accouting account on user is not defined. -SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for personnel expenses +SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for wage payments Salary=Salary Salaries=Salaries NewSalaryPayment=New salary payment