diff --git a/ChangeLog b/ChangeLog index cd5238c911f..c69b6e62a45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -91,7 +91,7 @@ NEW: tag odt line_product_ref_fourn for supplier doc lines NEW: The binding step in accountancy has a country filter with autocompletion NEW: Top menu is always on screen with MD theme. NEW: Withdraw request massaction can include already partially paid invoices - +NEW: Option "Simplify interface for blind persons" For developers: NEW: Add lib for multiselect with checkboxes diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index e37eb6fb96b..e6c4010ebdd 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -584,14 +584,14 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else if ($tabtype[$key] == 'payment_donation') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else if ($tabtype[$key] == 'member') { $bookkeeping->subledger_account = ''; @@ -605,21 +605,21 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else if ($tabtype[$key] == 'payment_various') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else if ($tabtype[$key] == 'banktransfert') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else { if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty. @@ -1173,28 +1173,28 @@ function getSourceDocRef($val, $typerecord) // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING $ref = $val['ref']; if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') { - $ref = $langs->trans('Supplier'); + $ref = $langs->transnoentitiesnoconv('Supplier'); } if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') { - $ref = $langs->trans('Customer'); + $ref = $langs->transnoentitiesnoconv('Customer'); } if ($ref == '(SocialContributionPayment)') { - $ref = $langs->trans('SocialContribution'); + $ref = $langs->transnoentitiesnoconv('SocialContribution'); } if ($ref == '(DonationPayment)') { - $ref = $langs->trans('Donation'); + $ref = $langs->transnoentitiesnoconv('Donation'); } if ($ref == '(SubscriptionPayment)') { - $ref = $langs->trans('Subscription'); + $ref = $langs->transnoentitiesnoconv('Subscription'); } if ($ref == '(ExpenseReportPayment)') { - $ref = $langs->trans('Employee'); + $ref = $langs->transnoentitiesnoconv('Employee'); } if ($ref == '(LoanPayment)') { - $ref = $langs->trans('Loan'); + $ref = $langs->transnoentitiesnoconv('Loan'); } if ($ref == '(payment_salary)') { - $ref = $langs->trans('Employee'); + $ref = $langs->transnoentitiesnoconv('Employee'); } $sqlmid = ''; @@ -1203,63 +1203,63 @@ function getSourceDocRef($val, $typerecord) $sqlmid = 'SELECT payfac.fk_facture as id, f.ref as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f"; $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"]; - $ref = $langs->trans("Invoice"); + $ref = $langs->transnoentitiesnoconv("Invoice"); } elseif ($typerecord == 'payment_supplier') { $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . $val["paymentsupplierid"]; - $ref = $langs->trans("SupplierInvoice"); + $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); } elseif ($typerecord == 'payment_expensereport') { $sqlmid = 'SELECT e.rowid as id, e.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e"; $sqlmid .= " WHERE pe.rowid=" . $val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; - $ref = $langs->trans("ExpenseReport"); + $ref = $langs->transnoentitiesnoconv("ExpenseReport"); } elseif ($typerecord == 'payment_salary') { $sqlmid = 'SELECT s.rowid as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; - $ref = $langs->trans("SalaryPayment"); + $ref = $langs->transnoentitiesnoconv("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"); + $ref = $langs->transnoentitiesnoconv("SocialContribution"); } elseif ($typerecord == 'payment_vat') { $sqlmid = 'SELECT v.rowid as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; $sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"]; - $ref = $langs->trans("PaymentVat"); + $ref = $langs->transnoentitiesnoconv("PaymentVat"); } elseif ($typerecord == 'payment_donation') { $sqlmid = 'SELECT payd.fk_donation as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; $sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; - $ref = $langs->trans("Donation"); + $ref = $langs->transnoentitiesnoconv("Donation"); } elseif ($typerecord == 'payment_loan') { $sqlmid = 'SELECT l.rowid as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_loan as l"; $sqlmid .= " WHERE l.rowid=" . $val["paymentloanid"]; - $ref = $langs->trans("LoanPayment"); + $ref = $langs->transnoentitiesnoconv("LoanPayment"); } elseif ($typerecord == 'payment_various') { $sqlmid = 'SELECT v.rowid as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; $sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"]; - $ref = $langs->trans("VariousPayment"); + $ref = $langs->transnoentitiesnoconv("VariousPayment"); } // Add warning if (empty($sqlmid)) @@ -1281,6 +1281,6 @@ function getSourceDocRef($val, $typerecord) else dol_print_error($db); } - $ref = dol_trunc($langs->trans("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 + $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 return $ref; } diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 2fb5013b4f9..eaef18c9543 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -384,7 +384,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $connectstringserver = ''; $connectstringsource = ''; $connectstringtarget = ''; - + if (function_exists('imap_open')) { $connectstringserver = $object->getConnectStringIMAP(); @@ -397,7 +397,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $morehtml .= 'IMAP functions not available on your PHP'; } - + if (! $connection) { $morehtml .= 'Failed to open IMAP connection '.$connectstringsource; @@ -412,7 +412,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { imap_close($connection); } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'
'.$morehtml.'
', '', 0, '', '', 0, ''); print '
'; @@ -487,6 +487,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1); print ''; print ''; + $htmltext=$langs->transnoentitiesnoconv("OperationParamDesc"); + //var_dump($htmltext); + print $form->textwithpicto('', $htmltext); print ''; print ''; print ''; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 71169ddffb0..cacebb8e55d 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -120,8 +120,6 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); /* * Actions - * - * Put here all code to do according to value of "$action" parameter */ if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } @@ -165,8 +163,6 @@ if (empty($reshook)) /* * View - * - * Put here all code to render page */ $form=new Form($db); @@ -212,20 +208,20 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object) $sql.=$hookmanager->resPrint; /* If a group by is required - $sql.= " GROUP BY " - foreach($object->fields as $key => $val) - { - $sql.='t.'.$key.', '; - } - // Add fields from extrafields - if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); - // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; - $sql=preg_replace('/, $/','', $sql); - */ +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); +*/ $sql.=$db->order($sortfield,$sortorder); @@ -305,8 +301,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( -//'presend'=>$langs->trans("SendByMail"), -//'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); @@ -324,7 +320,7 @@ print ''; $newcardbutton=''; //if ($user->rights->emailcollector->creer) - //{ +//{ $newcardbutton=''.$langs->trans('New').''; $newcardbutton.= ''; $newcardbutton.= ''; @@ -333,6 +329,10 @@ $newcardbutton.= ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) +/*$topicmail=""; +$modelmail=""; +$objecttmp=new EmailCollector($db); +$trackid='xxxx'.$object->id;*/ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) @@ -343,8 +343,8 @@ if ($sall) $moreforfilter = ''; /*$moreforfilter.='
'; - $moreforfilter.= $langs->trans('MyFilter') . ': '; - $moreforfilter.= '
';*/ +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
';*/ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -371,11 +371,11 @@ print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -397,11 +397,14 @@ print ''."\n"; print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -444,15 +447,22 @@ while ($i < min($num, $limit)) print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { - print ''; + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; print $object->showOutputField($val, $key, $obj->$key, ''); print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index bc0f22cb136..bc65c72260d 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -383,12 +383,24 @@ class BlockedLog // Set object_data $this->object_data=new stdClass(); + // Add fields to exclude $arrayoffieldstoexclude = array( - 'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf', + 'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf','civility_id','contact','contact_id', 'table_element_line','ismultientitymanaged','isextrafieldmanaged', 'linkedObjectsIds','linkedObjects','fk_delivery_address', - 'context' + 'context', + 'projet' // There is already ->fk_project ); + // Add more fields to exclude depending on object type + if ($this->element == 'cashcontrol') + { + $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array( + 'name','lastname','firstname','region','region_id','region_code','state','state_id','state_code','country','country_id','country_code', + 'total_ht','total_tva','total_ttc','total_localtax1','total_localtax2', + 'barcode_type','barcode_type_code','barcode_type_label','barcode_type_coder','mode_reglement_id','cond_reglement_id','mode_reglement','cond_reglement','shipping_method_id', + 'fk_incoterms','libelle_incoterms','location_incoterms','lines') + ); + } // Add thirdparty info if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty(); diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 298e8f1f9f1..57058483464 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -115,11 +115,10 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ''; print ''; print ''; - print ''; + print ''; print ''; // Current balance - print ''; print ''; print ''; @@ -133,7 +132,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // Remainder to pay in future - $sqls = array(); + $sqls = array(); // Customer invoices $sql = "SELECT 'invoice' as family, f.rowid as objid, f.ref as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,"; @@ -142,9 +141,9 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid - $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice - $sql.= " ORDER BY dlr ASC"; - $sqls[] = $sql; + $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Supplier invoices $sql = " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; @@ -153,51 +152,51 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; $sql.= " WHERE ff.entity = ".$conf->entity; $sql.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid - $sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice - $sql.= " ORDER BY dlr ASC"; - $sqls[] = $sql; + $sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Social contributions $sql = " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; - $sql.= ", cs.fk_account"; + $sql.= ", cs.fk_account"; $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; $sql.= " WHERE cs.entity = ".$conf->entity; $sql.= " AND cs.paye = 0"; // Not paid - $sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution + $sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution $sql.= " ORDER BY dlr ASC"; - $sqls[] = $sql; + $sqls[] = $sql; - // others sql - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if(empty($reshook) and isset($hookmanager->resArray['sql'])){ - $sqls[] = $hookmanager->resArray['sql']; - } + // others sql + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook) and isset($hookmanager->resArray['sql'])){ + $sqls[] = $hookmanager->resArray['sql']; + } $error=0; $tab_sqlobjOrder=array(); $tab_sqlobj=array(); - foreach($sqls as $sql){ - $resql = $db->query($sql); - if($resql){ - while($sqlobj = $db->fetch_object($resql)){ - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); - } - $db->free($resql); - }else{ - $error++; - } - } + foreach($sqls as $sql){ + $resql = $db->query($sql); + if($resql){ + while($sqlobj = $db->fetch_object($resql)){ + $tab_sqlobj[] = $sqlobj; + $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); + } + $db->free($resql); + }else{ + $error++; + } + } // Sort array if (! $error) { array_multisort($tab_sqlobjOrder,$tab_sqlobj); - //Apply distinct filter + // Apply distinct filter foreach ($tab_sqlobj as $key=>$value) { $tab_sqlobj[$key] = "'" . serialize($value) . "'"; } @@ -262,13 +261,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $paiement = -1*$socialcontribstatic->getSommePaiement(); // Payment already done } - $parameters = array('obj' => $obj); - $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if(empty($reshook)){ - $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; - $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; - $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; - } + $parameters = array('obj' => $obj); + $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook)){ + $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; + $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; + $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; + } $total_ttc = $obj->total_ttc; if ($paiement) $total_ttc = $obj->total_ttc - $paiement; @@ -307,7 +306,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; } - // solde + // solde print ''; print ''; print ''; diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 6d446580353..d494b5777f2 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -1,6 +1,4 @@ * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin @@ -33,7 +31,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; -$langs->loadLangs(array("cashcontrol","install","cashdesk","admin","banks")); +$langs->loadLangs(array("install","cashdesk","admin","banks")); $id=GETPOST('id','int'); $ref = GETPOST('ref', 'alpha'); @@ -84,16 +82,23 @@ $hookmanager->initHooks(array('cashcontrolcard','globalcard')); * Actions */ +$permissiontoadd = ($user->rights->cashdesk->use || $user->rights->takepos->use); +$permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use) || ($permissiontoadd && $object->status == 0); +if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php',1).'?id='.($id > 0 ? $id : '__ID__'); +$backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php',1); +$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record + if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH)) { setEventMessages($langs->trans("CashDesk")." - ".$langs->trans("NotConfigured"), null, 'errors'); } -if (GETPOST('cancel')) +if (GETPOST('cancel','alpha')) { $action = 'create'; } + if ($action=="start") { $error=0; @@ -127,7 +132,7 @@ elseif ($action=="add") $error=0; foreach($arrayofpaymentmode as $key=>$val) { - if (GETPOST($key,'alpha') == '') + if (GETPOST($key.'_amount','alpha') == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors'); $action='start'; @@ -135,7 +140,7 @@ elseif ($action=="add") } else { - $object->$key = price2num(GETPOST($key,'alpha')); + $object->$key = price2num(GETPOST($key.'_amount','alpha')); } } @@ -183,6 +188,32 @@ if ($action=="close") $action="view"; } +// Action to delete +if ($action == 'confirm_delete' && ! empty($permissiontodelete)) +{ + $object->fetch($id); + + if (! ($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } + + $result=$object->delete($user); + var_dump($result); + if ($result > 0) + { + // Delete OK + setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".$backurlforlist); + exit; + } + else + { + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + } +} /* @@ -414,7 +445,7 @@ if ($action=="create" || $action=="start") foreach($arrayofpaymentmode as $key => $val) { print ''; $i++; } @@ -493,16 +524,12 @@ if (empty($action) || $action=="view") print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); print ""; - print '"; - print '"; - print '"; - + foreach($arrayofpaymentmode as $key => $val) + { + print '"; + } print "
'.$langs->trans("ThirdParty").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("BankBalance").''.$langs->trans("BankBalance").'
'.$langs->trans("CurrentBalance").''.price($solde).'
'.$langs->trans("FutureBalance").' ('.$object->currency_code.')'.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).''; - print ''; + print ''; print '
'.$langs->trans("Cash").''; - print price($object->cash, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans("Cheque").''; - print price($object->cheque, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans("Card").''; - print price($object->card, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans($val).''; + print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); + print "
\n"; print ''; @@ -516,6 +543,8 @@ if (empty($action) || $action=="view") if ($object->status == CashControl::STATUS_DRAFT) { print '
' . $langs->trans('Close') . '
'; + + print '
' . $langs->trans('Delete') . '
'; } print ''; diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index fdf77b17961..071be33fd1f 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -276,6 +276,18 @@ class CashControl extends CommonObject return $result; } + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } /** * Return label of the status diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index c85e48f09e7..a2187e3b344 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -286,7 +286,7 @@ if ($resql) print "

"; print $langs->trans("Cash").": ".price($cash)."

"; print $langs->trans("PaymentTypeCB").": ".price($bank)."

"; - print $langs->trans("PaymentTypeCheque").": ".price($cheque)."

"; + print $langs->trans("PaymentTypeCHQ").": ".price($cheque)."

"; print "

"; //save totals to DB diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 636cb92978a..be3e7ea5791 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/compta/list/index.php + * \file htdocs/compta/sociales/list.php * \ingroup tax * \brief Page to list all social contributions */ diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 7c0d813c2cb..f0bb433c65c 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -166,7 +166,7 @@ if ($result) print_barre_liste($langs->trans("VATPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines, 'title_accountancy', 0, $newcardbutton, '', $limit); print '
'; - print ''; + print '
'."\n"; print ''; print ''; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 31a6549cc27..b8b4237cc93 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -149,6 +149,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) if ($action == "update_extras" && ! empty($permissiontoadd)) { $object->fetch(GETPOST('id','int')); + $attributekey = GETPOST('attribute','alpha'); $attributekeylong = 'options_'.$attributekey; $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong,' alpha'); @@ -169,6 +170,12 @@ if ($action == "update_extras" && ! empty($permissiontoadd)) // Action to delete if ($action == 'confirm_delete' && ! empty($permissiontodelete)) { + if (! ($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } + $result=$object->delete($user); if ($result > 0) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4974f6dbab5..dad9f2bc404 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -452,7 +452,7 @@ class Form if ($notabs == 2) $tag='div'; if ($notabs == 3) $tag='span'; // Sanitize tooltip - $htmltext=str_replace("\\","\\\\",$htmltext); + //$htmltext=str_replace("\\","\\\\",$htmltext); $htmltext=str_replace("\r","",$htmltext); $htmltext=str_replace("\n","",$htmltext); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index bd6d03dc542..41b0f1af3ef 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1341,6 +1341,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if (is_object($objcon) && $objcon->id) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; } if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; @@ -1379,13 +1380,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; } - // Work with new table actioncomm_resources and multiple contact affectation. - if (is_object($objcon) && $objcon->id) - { - $sql.= " AND r.element_type = '" . $objcon->table_element . "'" . - " AND r.fk_element = " . $objcon->id; - } - // Condition on actioncode if (! empty($actioncode)) { @@ -1410,7 +1404,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); - //TODO Add limit for thirdparty in contexte very all result + //TODO Add limit in nb of results $sql.= $db->order($sortfield, $sortorder); dol_syslog("company.lib::show_actions_done", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 317a0607e3a..c172575a011 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -158,6 +158,8 @@ if ($permission) { - +
trans("User"); ?> trans("ThirdPartyContact"); ?> diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 44f8555bea7..fc0b8673332 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -96,8 +96,8 @@ class EmailCollector extends CommonObject 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector'), 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1), 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>100, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com'), - 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myacount@gmail.com'), - 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>1, 'comment'=>"IMAP password"), + 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), + 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'comment'=>"IMAP password"), 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'), //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index b984b8fd7fb..1a8bb4ee64d 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -181,6 +181,7 @@ CREATE TABLE llx_emailcollector_emailcollector( -- END MODULEBUILDER FIELDS ) ENGINE=innodb; +ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN login varchar(128); ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_entity (entity); ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_status (status); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a86baae23f3..782bfb3a6cf 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1848,6 +1848,7 @@ WithoutDolTrackingID=Dolibarr Tracking ID not found FormatZip=Zip MainMenuCode=Menu entry code (mainmenu) ECMAutoTree=Show automatic ECM tree +OperationParamDesc=Define values to use for action, or how to extract values. For example:
VALUE:abc
REGEX:SUBJECT:([^\s]*)
REGEX:BODY:My company name is\s([^\s]*) ##### Resource #### ResourceSetup=Configuration of Resource module UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). @@ -1856,3 +1857,5 @@ DisabledResourceLinkContact=Disable feature to link a resource to contacts ConfirmUnactivation=Confirm module reset OnMobileOnly=On small screen (smartphone) only DisableProspectCustomerType=Disable the "Prospect + Customer" third party type (so third party must be Prospect or Customer but can't be both) +MAIN_OPTIMIZEFORTEXTBROWSER=Simplify interface for blind person +MAIN_OPTIMIZEFORTEXTBROWSERDesc=Enable this option if you are a blind person, or use application from a text browser like lynx or links. \ No newline at end of file diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 1ba33297611..6cc85024843 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -1,6 +1,6 @@ BlockedLog=Unalterable Logs Field=Field -BlockedLogDesc=This module tracks some events into an unalterable log (that you can't modify once recorded) into a block chain, in real time. This module provides compatibility with requirements of laws of some countries (like France with the law Finance 2016 - Norme NF535). +BlockedLogDesc=This module tracks some events into an unalterable log (that you can't modify once recorded) into a block chain, in real time. This module provides compatibility with requirements of laws of some countries (like France with the law Finance 2016 - Norme NF525). Fingerprints=Archived events and fingerprints FingerprintsDesc=This is the tool to browse or extract the unalterable logs. Unalterable logs are generated and archived locally into a dedicated table, in real time when you record a business event. You can use this tool to export this archive and save it into an external support (some countries, like France, ask that you do it every year). Note that, there is no feature to purge this log and every change tried to be done directly into this log (by a hacker for example) will be reported with a non-valid fingerprint. If you really need to purge this table because you used your application for a demo/test purpose and want to clean your data to start your production, you can ask your reseller or integrator to reset your database (all your data will be removed). CompanyInitialKey=Company initial key (hash of genesis block) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index ce43c595d28..58bf59bd37c 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -43,6 +43,9 @@ TakeposConnectorNecesary='TakePOS Connector' required OrderPrinters=Order printers SearchProduct=Search product Receipt=Receipt -AmountAtEndOfPeriod=Amount at end of period (day, month or year) Header=Header Footer=Footer +AmountAtEndOfPeriod=Amount at end of period (day, month or year) +TheoricalAmount=Theorical amount +RealAmount=Real amount +CashFenceDone=Cash fence done for the period diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 75754512c71..e37216054b4 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -118,7 +118,7 @@ if (empty($reshook)) $error=0; $permissiontoadd = $user->rights->mymodule->write; - $permissiontodelete = $user->rights->mymodule->delete; + $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id='.($id > 0 ? $id : '__ID__'); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1); $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 4150ca75ca7..23c2614eb0f 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -88,13 +88,13 @@ $pagenext = $page + 1; //if (! $sortorder) $sortorder="DESC"; // Initialize technical objects -$object=new MyObject($db); +$object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('myobject'); // Load $extrafields->attributes['myobject'] -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Default sort order (if not yet defined by previous GETPOST) if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. @@ -474,11 +474,14 @@ while ($i < min($num, $limit)) print '
'; foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (! empty($arrayfields['t.'.$key]['checked'])) { print ''; + $out.=ajax_combobox('pageid'); + } print $out; } else @@ -1893,7 +1914,7 @@ if (! GETPOST('hide_websitemenu')) } //print ''; - print ''; + print ''; // Print nav arrows diff --git a/htdocs/website/samples/wrapper.html b/htdocs/website/samples/wrapper.html index fb6a10b1264..32ed05e49c1 100644 --- a/htdocs/website/samples/wrapper.html +++ b/htdocs/website/samples/wrapper.html @@ -1,11 +1,12 @@ entity; $original_file=GETPOST("file","alpha"); @@ -54,17 +55,26 @@ if (! empty($hashp)) // Define attachment (attachment=true to force choice popup 'open'/'save as') $attachment = true; if (preg_match('/\.(html|htm)$/i',$original_file)) $attachment = false; -if (isset($_GET["attachment"])) $attachment = GETPOST("attachment",'alpha')?true:false; -if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; +if (isset($_GET["attachment"])) $attachment = GETPOST("attachment",'none')?true:false; +if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS_WEBSITE)) $attachment=false; // Define mime type $type = 'application/octet-stream'; -if (GETPOST('type','alpha')) $type=GETPOST('type','alpha'); +if (GETPOST('type','none')) $type=GETPOST('type','alpha'); else $type=dol_mimetype($original_file); // Security: Delete string ../ into $original_file $original_file=str_replace("../","/", $original_file); +// Cache or not +if (GETPOST("cache",'none') || image_format_supported($original_file) >= 0) +{ + // Important: Following code is to avoid page request by browser and PHP CPU at + // each Dolibarr page access. + header('Cache-Control: max-age=3600, public, must-revalidate'); + header('Pragma: cache'); // This is to avoid having Pragma: no-cache +} + // Find the subdirectory name as the reference $refname=basename(dirname($original_file)."/"); @@ -110,15 +120,13 @@ else // Permissions are ok and file found, so we return it //top_httphead($type); + header('Content-Type: '.$type); header('Content-Description: File Transfer'); if ($encoding) header('Content-Encoding: '.$encoding); // Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, attachment=need user action to open) if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"'); header('Content-Length: ' . dol_filesize($fullpath_original_file)); - // Ajout directives pour resoudre bug IE - header('Cache-Control: Public, must-revalidate'); - header('Pragma: public'); readfile($fullpath_original_file_osencoded); }