diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 5abbcb2512e..008fdec874b 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -35,6 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; //show files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; @@ -93,6 +95,27 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage context to save list fields $contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); +$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; +$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; +$sql.= " b.fk_bordereau,"; +$sql.= " bc.ref,"; +$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; +$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; +$sql.= ", ".MAIN_DB_PREFIX."bank as b"; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; +$sql.= " WHERE b.num_releve='".$db->escape($numref)."'"; +if (!isset($numref)) $sql.= " OR b.num_releve is null"; +$sql.= " AND b.fk_account = ".$object->id; +$sql.= " AND b.fk_account = ba.rowid"; +$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day + +$sqlrequestforbankline = $sql; + + + +/* + * Actions + */ // ZIP creation if ($action=="dl" && $numref > 0) @@ -100,36 +123,161 @@ if ($action=="dl" && $numref > 0) // TODO Replace this with a standard builddoc action that use a document generation module to build the ZIP $log = ''; - getAttachedFiles($db, $numref); // Build array $_SESSION["releve"][$numref] with all files to includes + $outdir = $conf->bank->dir_temp.'/'.$numref.'-'.$object->label; + $outdirinvoices = $outdir.'/'.$langs->trans("BillsCustomers"); + $outdirsupplierinvoices = $outdir.'/'.$langs->trans("BillsSuppliers"); + + dol_mkdir($outdir); + dol_mkdir($outdirinvoices); + dol_mkdir($outdirsupplierinvoices); - $filearray = $_SESSION["releve"][$numref]; - $zipname = $numref . '.zip'; + //$zipname = $object->label.'-'.$numref . '.zip'; + //$zip = new ZipArchive(); + //$zip->open($zipname, ZipArchive::OVERWRITE); + + $sql = $sqlrequestforbankline; + + $facturestatic=new Facture($db); - $zip = new ZipArchive(); - $zip->open($zipname, ZipArchive::OVERWRITE); - foreach ($filearray as $key => $files) { - if (is_array($files)) { - foreach ($files as $file) { - $zip->addFile($file["fullname"], $file["name"]); // - $log .= $key . ',' . $file["name"] . "\n"; + $resd = $db->query($sql); + if ($resd) { + $numd = $db->num_rows($resd); + $i = 0; + if ($numd > 0) + { + $objd = $db->fetch_object($resd); + + $log.='Transaction '.$objd->rowid; + $links = $object->get_url($objd->rowid); + + foreach($links as $key=>$val) + { + $link = ''; $upload_dir = ''; + + switch ($val['type']) { + case "payment": + $payment = new Paiement($db); + $payment->fetch($val['url_id']); + $arraybill = $payment->getBillsArray(); + if (count($arraybill) > 0) + { + foreach ($arraybill as $billid) + { + $facturestatic->fetch($billid); + $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice'); + + $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other + // TODO Use get_exdir + $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); + $listoffiles = dol_dir_list($conf->facture->dir_output.$subdir,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true); + // build list of files with full path + $files = array(); + foreach($listoffiles as $filefound) + { + if (strstr($filefound["name"],$facturestatic->ref)) + { + $files[] = $uploaddir.'/'.$facturestatic->ref.'/'.$filefound["name"]; + break; + } + } + /*var_dump($files);*/ + //var_dump($listoffiles); + foreach($listoffiles as $key => $srcfileobj) + { + $srcfile = $srcfileobj['fullname']; + $destfile = $outdirinvoices.'/'.$srcfileobj['name']; + //var_dump($srcfile.' - '.$destfile); + dol_copy($srcfile, $destfile); + } + } + } + break; + case "payment_supplier": + $payment = new PaiementFourn($db); + $payment->fetch($val['url_id']); + $arraybill = $payment->getBillsArray(); + if (count($arraybill) > 0) + { + foreach ($arraybill as $billid) + { + $facturestatic->fetch($billid); + $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice_supplier'); + + $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other + // TODO Use get_exdir + $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); + $listoffiles = dol_dir_list($conf->fournisseur->facture->dir_output.$subdir,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true); + // build list of files with full path + $files = array(); + foreach($listoffiles as $filefound) + { + if (strstr($filefound["name"],$facturestatic->ref)) + { + $files[] = $uploaddir.'/'.$facturestatic->ref.'/'.$filefound["name"]; + break; + } + } + /*var_dump($files);*/ + //var_dump($listoffiles); + foreach($listoffiles as $key => $srcfileobj) + { + $srcfile = $srcfileobj['fullname']; + $destfile = $outdirinvoices.'/'.$srcfileobj['name']; + //var_dump($srcfile.' - '.$destfile); + dol_copy($srcfile, $destfile); + } + } + } + break; + case "payment_expensereport": + /*$subdir = dol_sanitizeFileName($objd->refe); + $upload_dir = $conf->expensereport->dir_output . '/' . $subdir;*/ + break; + case "payment_salary": + /*$subdir = dol_sanitizeFileName($objd->ids); + $upload_dir = $conf->salaries->dir_output . '/' . $subdir;*/ + break; + case "payment_donation": + /*$subdir = get_exdir(null, 2, 0, 1, $objd, 'donation') . '/' . dol_sanitizeFileName($objd->idd); + $upload_dir = $conf->don->dir_output . '/' . $subdir;*/ + break; + default: + break; + } } - } else { - $log .= $key . ',' . $langs->trans("Nofile") . "\n"; + $log.="\n"; + + /*if (! empty($upload_dir)) + { + $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); + + if (is_array($files)) { + foreach ($files as $file) { + $zip->addFile($file["fullname"], $file["name"]); // + $log .= $key . ',' . $file["name"] . "\n"; + } + } else { + $log .= $key . ',' . $langs->trans("Nofile") . "\n"; + } + + }*/ } } - $zip->addFromString('log '.$numref.'.csv', $log); - $zip->close(); + + $db->free($resd); + + + //$zip->addFromString('log '.$numref.'.csv', $log); + //$zip->close(); // /Then download the zipped file. - header('Content-Type: application/zip'); + /*header('Content-Type: application/zip'); header('Content-disposition: attachment; filename=' . $zipname); header('Content-Length: ' . filesize($zipname)); readfile($zipname); - unset($_SESSION["releve"][$numref]); - - exit; + exit;*/ } @@ -371,20 +519,8 @@ else } // Recherche les ecritures pour le releve - $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; - $sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; - $sql.= " b.fk_bordereau,"; - $sql.= " bc.ref,"; - $sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ", ".MAIN_DB_PREFIX."bank as b"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; - $sql.= " WHERE b.num_releve='".$db->escape($numref)."'"; - if (!isset($numref)) $sql.= " OR b.num_releve is null"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day - + $sql = $sqlrequestforbankline; + $result = $db->query($sql); if ($result) { @@ -393,9 +529,9 @@ else $i = 0; // Ligne Solde debut releve - print ""; - print "".$langs->trans("InitialBankBalance")." :"; - print ''.price($total).' '; + print ''; + print ''.$langs->trans("InitialBankBalance")." :"; + print ''.price($total).' '; print "\n"; while ($i < $numrows) @@ -613,7 +749,7 @@ else // Line Balance print "\n ".$langs->trans("EndBankBalance")." :"; - print "".price($total)." "; + print ''.price($total)." "; print "\n"; print ""; print ""; @@ -632,103 +768,3 @@ else llxFooter(); $db->close(); - - - - -/** - * Function to generate the HTML code used to show the file name & download link attached to the Item covered by the bank line - * - * @param DoliDB $db database object - * @param int $bankId bank line id - * @param int $num bank statement - * @param string $label label used to optimise the sql querry - */ -function getAttachedFiles($db, $numref, $label='') -{ - $out = ''; - global $conf; - $sql = 'SELECT u.url_id, u.type,ff.rowid as id , ff.`ref` AS reff, f.facnumber AS `ref`,'; - $sql .= ' e.`ref` AS refe, sp.rowid AS ids, d.rowid AS idd'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'bank_url AS u, ' . MAIN_DB_PREFIX . 'bank AS b'; - if (! empty($label) || $label == '(CustomerInvoicePayment)') { - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiement AS p ON p.fk_bank = u.fk_bank'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiement_facture AS pf ON pf.fk_paiement = p.rowid'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'facture AS f ON f.rowid = pf.fk_facture'; - } - if (! empty($label) || $label == '(SupplierInvoicePayment)') { - // invoice suplier (SupplierInvoicePayment) - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiementfourn AS fp ON fp.fk_bank = u.fk_bank'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiementfourn_facturefourn AS fpf ON fpf.fk_paiementfourn = fp.rowid'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'facture_fourn AS ff ON ff.rowid = fpf.fk_facturefourn'; - } - if (! empty($label) || $label == '(ExpenseReportPayment)') { - // EXPENSEs (ExpenseReportPayment) - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'payment_expensereport AS ep ON ep.fk_bank = u.fk_bank'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'expensereport AS e ON e.rowid = ep.fk_expensereport'; - } - if (! empty($label) || $label == '(DonationPayment)') { - // donation - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'payment_donation AS dp ON dp.fk_bank = u.fk_bank'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'don AS d ON d.rowid = dp.fk_donation'; - } - if (! empty($label) || $label == '(SalaryPayment)') { - // loan - // $sql.=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_loan AS lp ON lp.fk_bank = u.fk_bank'; - // salary - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'payment_salary AS sp ON sp.fk_bank = u.fk_bank'; - } - // END SQL - $sql .= " WHERE u.fk_bank = b.rowid AND u.type in ('payment','payment_supplier','payment_expensereport','payment_salary','payment_donation' )"; - $resd = $db->query($sql); - $files = array(); - $link = ''; - if ($resd) { - $numd = $db->num_rows($resd); - $upload_dir = ''; - $i = 0; - if ($numd > 0) - { - $objd = $db->fetch_object($resd); - - switch ($objd->type) { - case "payment": - $subdir = dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->facture->dir_output . '/' . $subdir; - $link = DOL_URL_ROOT."/document.php?modulepart=facture&file=" . str_replace('/', '%2F', $subdir) . '%2F'; - break; - case "payment_supplier": - $subdir = get_exdir($objd->id, 2, 0, 0, $objd, 'invoice_supplier') . $objd->reff; - $upload_dir = $conf->fournisseur->facture->dir_output . '/' . $subdir; - $link = DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=" . str_replace('/', '%2F', $subdir) . '%2F'; - break; - case "payment_expensereport": - $subdir = dol_sanitizeFileName($objd->refe); - $upload_dir = $conf->expensereport->dir_output . '/' . $subdir; - $link = DOL_URL_ROOT."/document.php?modulepart=expensereport&file=" . str_replace('/', '%2F', $subdir) . '%2F'; - break; - case "payment_salary": - $subdir = dol_sanitizeFileName($objd->ids); - $upload_dir = $conf->salaries->dir_output . '/' . $subdir; - $link = DOL_URL_ROOT."/document.php?modulepart=salaries&file=" . str_replace('/', '%2F', $subdir) . '%2F'; - break; - case "payment_donation": - $subdir = get_exdir(null, 2, 0, 1, $objd, 'donation') . '/' . dol_sanitizeFileName($objd->idd); - $upload_dir = $conf->don->dir_output . '/' . $subdir; - $link = DOL_URL_ROOT."/document.php?modulepart=don&file=" . str_replace('/', '%2F', $subdir) . '%2F'; - break; - default: - break; - } - - if (! empty($upload_dir)) - { - $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); - $_SESSION["releve"][$numref][] = $files; - } - } - } - - $db->free($resd); - return $out; -} diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index b229f756b25..53035dca96f 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -965,26 +965,29 @@ class Paiement extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option Sur quoi pointe le lien + * @param string $mode 'withlistofinvoices'=Include list of invoices into tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto=0,$option='') + function getNomUrl($withpicto=0,$option='',$mode='withlistofinvoices') { global $langs; $result=''; $label = $langs->trans("ShowPayment").': '.$this->ref; - $arraybill = $this->getBillsArray(); - if (count($arraybill) >0) - { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $facturestatic=new Facture($this->db); - foreach ($arraybill as $billid) - { - $facturestatic->fetch($billid); - $label .='
'.$facturestatic->getNomUrl(1).' '.$facturestatic->getLibStatut(2,1); - } - } - + if ($mode == 'withlistofinvoices') + { + $arraybill = $this->getBillsArray(); + if (count($arraybill) > 0) + { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $facturestatic=new Facture($this->db); + foreach ($arraybill as $billid) + { + $facturestatic->fetch($billid); + $label .='
'.$facturestatic->getNomUrl(1).' '.$facturestatic->getLibStatut(2,1); + } + } + } $link = ''; $linkend=''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 793e17c8f72..38ab27f844c 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -932,7 +932,7 @@ div.vmenu, td.vmenu { /* For smartphone (testmenuhider is on) */ -global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +browser->layout == 'phone' && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> #id-container { width: 100%; } @@ -4540,7 +4540,7 @@ div.tabsElem a.tab { } } /* rule to reduce top menu - 3rd reduction */ -@media only screen and (max-width: px) /* reduction 3 */ +@media only screen and (max-width: px) /* reduction 3 */ { .side-nav { z-index: 200; @@ -4570,16 +4570,23 @@ div.tabsElem a.tab { width: 100%; } div.login_block { + browser->layout == 'phone' && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> display: none; + padding-top: 20px; + padding-left: 20px; + padding-right: 20px; + + padding-top: 10px; + padding-left: 5px; + padding-right: 5px; + top: inherit !important; left: 0 !important; text-align: center; vertical-align: middle; background: #FFF; height: 42px; - padding-top: 20px; - padding-left: 20px; - padding-right: 20px; + z-index: 202; min-width: 190px; max-width: 190px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f3232b31d6b..a681fcc0ee4 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -929,7 +929,7 @@ td.showDragHandle { display: block; font-family: "RobotoDraft","Roboto",sans-serif; left: 0; -global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +browser->layout, array('phone','tablet')) && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> position: fixed; top: 50px; @@ -958,7 +958,7 @@ td.showDragHandle { -moz-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); -webkit-overflow-scrolling: touch; -global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +browser->layout, array('phone','tablet')) && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> overflow-x: hidden; overflow-y: auto; @@ -970,7 +970,7 @@ td.showDragHandle { } /* For smartphone (testmenuhider is on) */ -global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +browser->layout, array('phone','tablet')) && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> #id-container { width: 100%; } @@ -982,7 +982,7 @@ div.login_block { top: inherit !important; } .side-nav { -global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +browser->layout, array('phone','tablet')) && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> overflow-x: initial !important; overflow-y: scroll; @@ -1004,7 +1004,7 @@ div.login_block { z-index: 201; background: #FFF; border-right: 1px solid rgba(0,0,0,0.3); -global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +browser->layout, array('phone','tablet')) && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> top: 50px ! important; top: 60px ! important; @@ -1647,7 +1647,7 @@ div.login_block { padding-bottom: 3px; : 0; top: 0px; -global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +browser->layout, array('phone','tablet')) && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> position: absolute; position: fixed; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8529a0c0cfc..594c7e090d6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2072,9 +2072,9 @@ class User extends CommonObject $paddafterimage=''; if (abs($withpictoimg) == 1) $paddafterimage='style="margin-right: 3px;"'; // Only picto - if ($withpictoimg > 0) $picto='
'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).'
'; + if ($withpictoimg > 0) $picto='
'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).'
'; // Picto must be a photo - else $picto='
'.Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1).'
'; + else $picto='
'.Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1).'
'; $result.=$picto; } if ($withpictoimg > -2 && $withpictoimg != 2)