Merge remote-tracking branch 'Upstream/develop' into develop-loan

This commit is contained in:
aspangaro 2015-03-11 05:28:59 +01:00
commit 3897e65425
141 changed files with 3852 additions and 1483 deletions

View File

@ -18,10 +18,15 @@ services:
language: php
php:
# - "5.2" is not supported because pyrus to install PHP_Codesniffer is not available
- "5.3"
- "5.4"
- "5.5"
- "5.6"
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
matrix:
allow_failures:
- php: 7.0
env:
- DB=mysql

View File

@ -226,6 +226,7 @@ Dolibarr better:
- Fix: [ bug #1827 ] Tax reports gives incorrect amounts when using external modules that create lines with special codes
- Fix: [ bug #1822 ] SQL error in clientfourn.php report with PostgreSQL
- Fix: [ bug #1832 ] SQL error when adding a product with no price defined to an object
- Fix: [ bug #1833 ] user permissions in contact/note.php not working
- Fix: [ bug #1826 ] Supplier payment types are not translated into fourn/facture/paiement.php
- Fix: [ bug #1830 ] Salaries payment only allows checking accounts
- Fix: [ bug #1825 ] External agenda: hide/show checkbox doesn't work

View File

@ -1,6 +1,6 @@
dolibarr (3.7.0-3) UNRELEASED; urgency=low
dolibarr (3.8.0-3) UNRELEASED; urgency=low
[ Laurent Destailleur (eldy) ]
* New upstream release.
-- Laurent Destailleur (eldy) <eldy@users.sourceforge.net> Tue, 21 Oct 2014 12:00:00 +0100
-- Laurent Destailleur (eldy) <eldy@users.sourceforge.net> Tue, 3 Mar 2015 12:00:00 +0100

View File

@ -451,15 +451,18 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/documents`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/document`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/documents`;
# Removed known external modules to avoir any error when packaging on test env
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ancotec*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/bootstrap*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/factory*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/management*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/multicompany*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/nltechno*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/pos*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/timesheet*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/eldy/*.new`;
$ret=`rm -fr $BUILDROOT/$PROJECT/test`;

View File

@ -174,6 +174,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/cron
%_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/expedition
%_datadir/dolibarr/htdocs/expensereport
%_datadir/dolibarr/htdocs/exports
%_datadir/dolibarr/htdocs/externalsite
%_datadir/dolibarr/htdocs/fichinter

View File

@ -254,6 +254,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/cron
%_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/expedition
%_datadir/dolibarr/htdocs/expensereport
%_datadir/dolibarr/htdocs/exports
%_datadir/dolibarr/htdocs/externalsite
%_datadir/dolibarr/htdocs/fichinter

View File

@ -171,6 +171,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/cron
%_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/expedition
%_datadir/dolibarr/htdocs/expensereport
%_datadir/dolibarr/htdocs/exports
%_datadir/dolibarr/htdocs/externalsite
%_datadir/dolibarr/htdocs/fichinter

View File

@ -182,6 +182,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/cron
%_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/expedition
%_datadir/dolibarr/htdocs/expensereport
%_datadir/dolibarr/htdocs/exports
%_datadir/dolibarr/htdocs/externalsite
%_datadir/dolibarr/htdocs/fichinter

View File

@ -1721,8 +1721,8 @@ class Adherent extends CommonObject
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Objet user
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
* @param User $user Objet user
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/
function load_board($user)
{

View File

@ -8,7 +8,7 @@
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
* Copyright (C) 2012-2013 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2011-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -316,7 +316,7 @@ $tabcond[13]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabl
$tabcond[14]= (! empty($conf->product->enabled) && ! empty($conf->ecotax->enabled));
$tabcond[15]= true;
$tabcond[16]= (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS));
$tabcond[17]= ! empty($conf->deplacement->enabled);
$tabcond[17]= (! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled));
$tabcond[18]= ! empty($conf->expedition->enabled);
$tabcond[19]= ! empty($conf->societe->enabled);
$tabcond[20]= ! empty($conf->fournisseur->enabled);

View File

@ -221,7 +221,7 @@ else if ($action == 'set_FICHINTER_DRAFT_WATERMARK')
elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS')
{
$val = GETPOST('FICHINTER_PRINT_PRODUCTS','alpha');
$res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS",($val == 'on'),'bool',0,'',$conf->entity);
$res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS",($val == 'on' ? 1 : 0),'bool',0,'',$conf->entity);
if (! $res > 0) $error++;

View File

@ -67,7 +67,7 @@ llxHeader('',$langs->trans("DefaultRights"));
print_fiche_titre($langs->trans("SecuritySetup"),'','setup');
print $langs->trans("DefaultRightsDesc");
print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
print " ".$langs->trans("OnlyActiveElementsAreShown")."<br><br>\n";
$db->begin();
@ -115,16 +115,15 @@ foreach ($modulesdir as $dir)
$db->commit();
// Show warning about external users
print info_admin(showModulesExludedForExternal($modules)).'<br>'."\n";
print "<br>\n";
$head=security_prepare_head();
dol_fiche_head($head, 'default', $langs->trans("Security"));
// Show warning about external users
print info_admin(showModulesExludedForExternal($modules)).'<br>'."\n";
print '<table class="noborder" width="100%">';
// Affiche lignes des permissions

View File

@ -208,7 +208,7 @@ $formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestF
// List of document
$filearray=dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1);
$formfile->list_of_documents($filearray, '', 'admin_temp', '');
$formfile->list_of_documents($filearray, null, 'admin_temp', '');
llxFooter();
$db->close();

View File

@ -66,6 +66,11 @@ else if ($conf->db->type == 'mssql')
//$sqls[0] = "";
//$base=3;
}
else if ($conf->db->type == 'sqlite' || $conf->db->type == 'sqlite3')
{
//$sql = "SELECT name, type FROM sqlite_master";
$base = 4;
}
if (! $base)
@ -169,6 +174,40 @@ else
}
print '</table>';
}
if ($base == 4)
{
// Sqlite by PDO or by Sqlite3
print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("TableName").'</td>';
print '<td>'.$langs->trans("NbOfRecord").'</td>';
print "</tr>\n";
$sql = "SELECT name, type FROM sqlite_master where type='table' and name not like 'sqlite%' ORDER BY name";
$resql = $db->query($sql);
if ($resql)
{
$var=True;
while ($row = $db->fetch_row($resql)) {
$rescount = $db->query("SELECT COUNT(*) FROM " . $row[0]);
if ($rescount) {
$row_count = $db->fetch_row($rescount);
$count = $row_count[0];
} else {
$count = '?';
}
print "<tr ".$bc[$var].">";
print '<td>'.$row[0].'</td>';
print '<td>'.$count.'</td>';
print '</tr>';
}
}
}
}
llxFooter();

View File

@ -108,7 +108,7 @@ $db->close();
/**
* Function to get list of updated or modified files
*
* @param object $dir SimpleXMLElement of files to test
* @param SimpleXMLElement $dir SimpleXMLElement of files to test
* @param string $path Path of file
* @return array Array of filenames
*/

View File

@ -1330,17 +1330,23 @@ class Categorie extends CommonObject
* Build thumb
*
* @param string $file Chemin du fichier d'origine
* @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
* @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
* @return void
*/
function add_thumb($file, $maxWidth = 160, $maxHeight = 120)
function add_thumb($file)
{
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ...
if (file_exists($file))
{
vignette($file,$maxWidth,$maxHeight);
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($file, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -347,7 +348,6 @@ if (! empty($conf->use_javascript_ajax))
$s='';
$s.='<script type="text/javascript">' . "\n";
$s.='jQuery(document).ready(function () {' . "\n";
$s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n";
$s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n";
$s.='jQuery(".family_birthday").toggle();' . "\n";
if ($action=="show_week" || $action=="show_month" || empty($action))
@ -361,18 +361,20 @@ if (! empty($conf->use_javascript_ajax))
$s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked="true" disabled="disabled"> ' . $langs->trans("LocalAgenda").' &nbsp; </div>';
if (is_array($showextcals) && count($showextcals) > 0)
{
$s.='<script type="text/javascript">' . "\n";
$s.='jQuery(document).ready(function () {
jQuery("table input[name^=\"check_ext\"]").click(function() {
var name = $(this).attr("name");
jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
});
});' . "\n";
$s.='</script>' . "\n";
foreach ($showextcals as $val)
{
$htmlname = md5($val['name']);
$s.='<script type="text/javascript">' . "\n";
$s.='jQuery(document).ready(function () {' . "\n";
$s.=' jQuery("#check_ext' . $htmlname . '").click(function() {';
$s.=' /* alert("'.$htmlname.'"); */';
$s.=' jQuery(".family_ext' . $htmlname . '").toggle();';
$s.=' });' . "\n";
$s.='});' . "\n";
$s.='</script>' . "\n";
$s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked="true"> ' . $val ['name'] . ' &nbsp; </div>';
$s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked="true"> ' . $val['name'] . ' &nbsp; </div>';
}
}
$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' &nbsp; </div>';

View File

@ -400,7 +400,7 @@ if ($id > 0)
// display amount and link to unpaid bill
$outstandigBills = $object->get_OutstandingBill();
if ($outstandigBills != 0)
print " / <a href='".DOL_URL_ROOT."/compta/facture/list.php?socid=".$object->id."&search_status=1'>".price($outstandigBills).'</a>';
print " (".$langs->trans("CurrentOutstandingBill")." <a href='".DOL_URL_ROOT."/compta/facture/list.php?socid=".$object->id."&search_status=1'>".price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency).'</a>)';
print '</td>';
print '</tr>';
}

View File

@ -103,6 +103,21 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
print "</table></form><br>\n";
}
// Search supplier order
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
{
$var=false;
print '<form method="post" action="'.DOL_URL_ROOT.'/fourn/commande/list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchASupplierOrder").'</td></tr>';
print '<tr '.$bc[$var].'><td>';
print '<label for="search_ref">'.$langs->trans("Ref").'</label>:</td><td><input type="text" class="flat" name="search_ref" id="search_ref" size=18></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td class="nowrap"><label for="search_all">'.$langs->trans("Other").'</label>:</td><td><input type="text" class="flat" name="search_all" id="search_all" size="18"></td>';
print '</tr>';
print "</table></form><br>\n";
}
// Search contract
if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
{

View File

@ -2003,8 +2003,7 @@ if ($action == 'create')
// Amount HT
print '<tr><td height="10" width="25%">' . $langs->trans('AmountHT') . '</td>';
print '<td align="right" class="nowrap"><b>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
print '<td></td>';
print '<td align="right" class="nowrap" colspan="2"><b>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
// Margin Infos
if (! empty($conf->margin->enabled)) {
@ -2016,27 +2015,27 @@ if ($action == 'create')
// Amount VAT
print '<tr><td height="10">' . $langs->trans('AmountVAT') . '</td>';
print '<td align="right" class="nowrap">' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td></td></tr>';
print '<td align="right" class="nowrap" colspan="2">' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
// Amount Local Taxes
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1
{
print '<tr><td height="10">' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
print '<td align="right" class="nowrap">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td align="right" class="nowrap" colspan="2">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td></td></tr>';
}
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2
{
print '<tr><td height="10">' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
print '<td align="right" class="nowrap">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td></td></tr>';
print '<td align="right" class="nowrap" colspan="2">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
}
// Amount TTC
print '<tr><td height="10">' . $langs->trans('AmountTTC') . '</td>';
print '<td align="right" class="nowrap">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td></td></tr>';
print '<td align="right" class="nowrap" colspan="2">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
// Statut
print '<tr><td height="10">' . $langs->trans('Status') . '</td><td align="left" colspan="2">' . $object->getLibStatut(4) . '</td></tr>';

View File

@ -182,9 +182,9 @@ if ($search_author)
{
$sql.= " AND u.login LIKE '%".$db->escape(trim($search_author))."%'";
}
if ($search_montant_ht)
if ($search_montant_ht != '')
{
$sql.= " AND p.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'";
$sql.= natural_search("p.total_ht", $search_montant_ht, 1);
}
if ($sall) {
$sql .= natural_search(array('s.nom', 'p.note_private', 'p.note_public', 'pd.description'), $sall);
@ -316,12 +316,12 @@ if ($result)
print '</td>';
print '<td class="liste_titre" colspan="1">&nbsp;</td>';
// Amount
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$search_montant_ht.'">';
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="6" name="search_montant_ht" value="'.$search_montant_ht.'">';
print '</td>';
// Author
print '<td class="liste_titre" align="center">';
print '<input class="flat" size="10" type="text" name="search_author" value="'.$search_author.'">';
print '<input class="flat" size="6" type="text" name="search_author" value="'.$search_author.'">';
print '</td>';
print '<td class="liste_titre" align="right">';
$formpropal->selectProposalStatus($viewstatut,1);

View File

@ -220,13 +220,13 @@ if (empty($reshook))
if ($datecommande == '') {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), 'errors');
$action = 'create';
$error ++;
$error++;
}
if ($socid < 1) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors');
$action = 'create';
$error ++;
$error++;
}
if (! $error) {
@ -350,7 +350,7 @@ if (empty($reshook))
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options);
if ($result < 0) {
$error ++;
$error++;
break;
}
@ -365,14 +365,14 @@ if (empty($reshook))
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
if ($reshook < 0)
$error ++;
$error++;
} else {
setEventMessage($srcobject->error, 'errors');
$error ++;
$error++;
}
} else {
setEventMessage($object->error, 'errors');
$error ++;
$error++;
}
} else {
// Required extrafield left blank, error message already defined by setOptionalsFromPost()
@ -408,7 +408,7 @@ if (empty($reshook))
$result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external');
if ($result < 0) {
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
$error ++;
$error++;
}
}
@ -579,24 +579,24 @@ if (empty($reshook))
if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
$error ++;
$error++;
}
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
$error ++;
$error++;
}
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
{
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
$error ++;
$error++;
}
if ($qty == '') {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
$error ++;
$error++;
}
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
$error ++;
$error++;
}
if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) {
@ -852,7 +852,7 @@ if (empty($reshook))
if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors');
$error ++;
$error++;
}
} else {
$type = GETPOST('type');
@ -861,7 +861,7 @@ if (empty($reshook))
// Check parameters
if (GETPOST('type') < 0) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors');
$error ++;
$error++;
}
}
@ -1125,10 +1125,10 @@ if (empty($reshook))
if (empty($reshook)) {
$result = $object->insertExtraFields();
if ($result < 0) {
$error ++;
$error++;
}
} else if ($reshook < 0)
$error ++;
$error++;
}
if ($error)
@ -2243,7 +2243,11 @@ if ($action == 'create' && $user->rights->commande->creer)
}
// Cancel order
if ($object->statut == 1 && $user->rights->commande->annuler) {
if ($object->statut == 1 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->cloturer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler)))
)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>';
}

View File

@ -51,6 +51,7 @@ $sall=GETPOST('sall');
$socid=GETPOST('socid','int');
$search_user=GETPOST('search_user','int');
$search_sale=GETPOST('search_sale','int');
$search_total_ht=GETPOST('search_total_ht','alpha');
// Security check
$id = (GETPOST('orderid')?GETPOST('orderid'):GETPOST('id','int'));
@ -79,6 +80,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$search_ref='';
$search_ref_customer='';
$search_company='';
$search_total_ht='';
$orderyear='';
$ordermonth='';
$deliverymonth='';
@ -96,6 +98,7 @@ $parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/*
* View
*/
@ -198,7 +201,10 @@ if ($search_user > 0)
{
$sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
}
if ($search_total_ht != '')
{
$sql.= natural_search('c.total_ht', $search_total_ht, 1);
}
$sql.= ' ORDER BY '.$sortfield.' '.$sortorder;
$nbtotalofrecords = 0;
@ -252,7 +258,8 @@ if ($resql)
if ($search_ref_customer) $param.='&search_ref_customer='.$search_ref_customer;
if ($search_user > 0) $param.='&search_user='.$search_user;
if ($search_sale > 0) $param.='&search_sale='.$search_sale;
if ($search_total_ht != '') $param.='&search_total_ht='.$search_total_ht;
$num = $db->num_rows($resql);
print_barre_liste($title, $page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
$i = 0;
@ -316,7 +323,9 @@ if ($resql)
print '<input class="flat" type="text" size="1" maxlength="2" name="deliverymonth" value="'.$deliverymonth.'">';
$formother->select_year($deliveryyear?$deliveryyear:-1,'deliveryyear',1, 20, 5);
print '</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="6" name="search_total_ht" value="'.$search_total_ht.'">';
print '</td>';
print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print "</td></tr>\n";
@ -328,7 +337,8 @@ if ($resql)
$generic_commande = new Commande($db);
$generic_product = new Product($db);
while ($i < min($num,$limit)) {
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
$var=!$var;
print '<tr '.$bc[$var].'>';

View File

@ -917,7 +917,7 @@ class Account extends CommonObject
*
* @param User $user Objet user
* @param int $filteraccountid To get info for a particular account id
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/
function load_board($user,$filteraccountid=0)
{
@ -940,7 +940,7 @@ class Account extends CommonObject
$langs->load("banks");
$now=dol_now();
require_once DOL_DOCUMENT_ROOT.'/core/class/WorkboardResponse.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
$response = new WorkboardResponse();
$response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;

View File

@ -174,7 +174,11 @@ foreach ($accounts as $key=>$type)
$total[$acc->currency_code] += $solde;
}
}
if (! $found) print '<tr '.$bc[$var].'><td colspan="6">'.$langs->trans("None").'</td></tr>';
if (! $found)
{
$var = !$var;
print '<tr '.$bc[false].'><td colspan="6">'.$langs->trans("None").'</td></tr>';
}
// Total
foreach ($total as $key=>$solde)
{

View File

@ -93,9 +93,10 @@ if ($conf->salaries->enabled)
print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
$sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sql.= " WHERE s.entity = ".$conf->entity;
$sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm, s.salary, u.salary as current_salary";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE s.entity IN (".getEntity('user',1).")";
$sql.= " AND u.rowid = s.fk_user";
if ($year > 0)
{
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
@ -132,11 +133,11 @@ if ($conf->salaries->enabled)
print "<td>".$obj->label."</td>\n";
print '<td align="right">'.price($obj->amount)."</td>";
print '<td align="right">'.($obj->salary?price($obj->salary):'')."</td>";
// Ref payment
$sal_static->id=$obj->rowid;
$sal_static->ref=$obj->rowid;
$sal_static->id=$obj->rowid;
$sal_static->ref=$obj->rowid;
print '<td align="left">'.$sal_static->getNomUrl(1)."</td>\n";
print '<td align="center">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
@ -146,7 +147,7 @@ if ($conf->salaries->enabled)
$i++;
}
print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
print '<td align="right">'.price($total)."</td>";
print '<td align="right">'."</td>";
print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>';
print '<td align="right">'.price($total)."</td>";

View File

@ -1962,11 +1962,11 @@ if ($action == 'create')
// Outstanding Bill
$outstandigBills = $soc->get_OutstandingBill();
print ' (' . $langs->trans('CurrentOutstandingBill') . ': ';
print price($outstandigBills, '', $langs, 0, 0, - 1, $conf->currency);
print price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency);
if ($soc->outstanding_limit != '')
{
if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
print ' / ' . price($soc->outstanding_limit);
print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
}
print ')';
print '</td>';

View File

@ -187,13 +187,13 @@ if ($search_societe)
{
$sql .= natural_search('s.nom', $search_societe);
}
if ($search_montant_ht)
if ($search_montant_ht != '')
{
$sql.= ' AND f.total = \''.$db->escape(price2num(trim($search_montant_ht))).'\'';
$sql.= natural_search('f.total', $search_montant_ht, 1);
}
if ($search_montant_ttc)
if ($search_montant_ttc != '')
{
$sql.= ' AND f.total_ttc = \''.$db->escape(price2num(trim($search_montant_ttc))).'\'';
$sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
}
if ($search_status != '')
{
@ -263,8 +263,8 @@ if ($resql)
if ($search_societe) $param.='&search_societe=' .$search_societe;
if ($search_sale > 0) $param.='&search_sale=' .$search_sale;
if ($search_user > 0) $param.='&search_user=' .$search_user;
if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht;
if ($search_montant_ttc) $param.='&search_montant_ttc='.$search_montant_ttc;
if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht;
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc;
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
$i = 0;
@ -323,9 +323,9 @@ if ($resql)
print '</td>';
print '<td class="liste_titre" align="left">&nbsp;</td>';
print '<td class="liste_titre" align="left"><input class="flat" type="text" name="search_societe" value="'.$search_societe.'"></td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="10" name="search_montant_ht" value="'.$search_montant_ht.'"></td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="6" name="search_montant_ht" value="'.$search_montant_ht.'"></td>';
print '<td class="liste_titre" align="right">&nbsp;</td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$search_montant_ttc.'"></td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="6" name="search_montant_ttc" value="'.$search_montant_ttc.'"></td>';
print '<td class="liste_titre" align="right">&nbsp;</td>';
print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View File

@ -196,7 +196,7 @@ if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
{
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.date_debut as date, x.tms as dm, x.total_ttc";
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE u.rowid = x.fk_user_author";
@ -218,7 +218,7 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("BoxTitleLastModifiedExpenses",min($max,$num)).'</td>';
print '<td align="right">'.$langs->trans("FeesAmount").'</td>';
print '<td align="right">'.$langs->trans("TotalTTC").'</td>';
print '<td align="right">'.$langs->trans("DateModificationShort").'</td>';
print '<td width="16">&nbsp;</td>';
print '</tr>';
@ -239,9 +239,9 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire
print '<tr '.$bc[$var].'>';
print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
print '<td>'.$userstatic->getNomUrl(1).'</td>';
print '<td align="right">'.$obj->total_ttc.'</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>';
print '<td align="right">'.dol_print_date($db->jdate($obj->dm),'day').'</td>';
//print '<td>'.$expensereportstatic->LibStatut($obj->fk_statut,3).'</td>';
print '<td>'.$expensereportstatic->LibStatut($obj->status,3).'</td>';
print '</tr>';
$var=!$var;
$i++;

View File

@ -1294,7 +1294,7 @@ class BonPrelevement extends CommonObject
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures, $obj->idfac, $obj->iban, $obj->bic, $obj->datec, $obj->drum);
$fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures, $obj->idfac, $obj->iban, $obj->bic, $this->db->jdate($obj->datec), $obj->drum);
$this->total = $this->total + $obj->somme;
$i++;
}
@ -1496,6 +1496,20 @@ class BonPrelevement extends CommonObject
}
/**
* Build RUM number for a customer bank account
*
* @param string $row_code_client Customer code (soc.code_client)
* @param int $row_datec Creation date of bank account (rib.datec)
* @param string $row_drum Id of customer bank account (rib.rowid)
* @return string RUM number
*/
static function buildRumNumber($row_code_client, $row_datec, $row_drum)
{
$pre = ($row_datec > 1359673200) ? 'Rum' : '++R';
return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec);
}
/**
* Write recipient of request (customer)
*
@ -1514,7 +1528,7 @@ class BonPrelevement extends CommonObject
* @param string $row_iban rib.iban_prefix AS iban,
* @param string $row_bic rib.bic AS bic,
* @param string $row_datec rib.datec,
* @param string $row_drum rib.rowid AS drum
* @param string $row_drum rib.rowid used to generate rum
* @return string Return string with SEPA part DrctDbtTxInf
*/
function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_facnumber, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum)
@ -1524,10 +1538,11 @@ class BonPrelevement extends CommonObject
// Define value for RUM
// Example: RUMCustomerCode-CustomerBankAccountId-01424448606 (note: Date is date of creation of CustomerBankAccountId)
$Date_Rum = strtotime($row_datec);
$Rum = $this->buildRumNumber($row_code_client, $row_datec, $row_drum);
// Define date of RUM signature
$DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d');
$pre = ($date_Rum > 1359673200) ? 'Rum' : '++R';
$Rum = $pre.$row_code_client.$row_drum.'-0'.date('U', $Date_Rum);
$XML_DEBITOR ='';
$XML_DEBITOR .=' <DrctDbtTxInf>'.$CrLf;
$XML_DEBITOR .=' <PmtId>'.$CrLf;

View File

@ -67,8 +67,8 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]);
$dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
$sal->accountid=GETPOST("accountid");
$sal->fk_user=GETPOST("fk_user");
$sal->accountid=GETPOST("accountid","int");
$sal->fk_user=GETPOST("fk_user","int");
$sal->datev=$datev;
$sal->datep=$datep;
$sal->amount=price2num(GETPOST("amount"));
@ -80,6 +80,11 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$sal->num_payment=GETPOST("num_payment");
$sal->fk_user_creat=$user->id;
// Set user current salary as ref salaray for the payment
$fuser=new User($db);
$fuser->fetch(GETPOST("fk_user","int"));
$sal->salary=$fuser->salary;
if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep))
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors');
@ -368,7 +373,7 @@ if ($id)
print "<div class=\"tabsAction\">\n";
if ($salpayment->rappro == 0)
{
if (! empty($user->rights->tax->charges->supprimer))
if (! empty($user->rights->salaries->delete))
{
print '<a class="butActionDelete" href="card.php?id='.$salpayment->id.'&action=delete">'.$langs->trans("Delete").'</a>';
}

View File

@ -324,6 +324,7 @@ class PaymentSalary extends CommonObject
$sql.= ", datep";
$sql.= ", datev";
$sql.= ", amount";
$sql.= ", salary";
$sql.= ", fk_typepayment";
$sql.= ", num_payment";
if ($this->note) $sql.= ", note";
@ -338,7 +339,8 @@ class PaymentSalary extends CommonObject
$sql.= "'".$this->fk_user."'";
$sql.= ", '".$this->db->idate($this->datep)."'";
$sql.= ", '".$this->db->idate($this->datev)."'";
$sql.= ", '".$this->amount."'";
$sql.= ", ".$this->amount;
$sql.= ", ".($this->salary > 0 ? $this->salary : "null");
$sql.= ", '".$this->type_payment."'";
$sql.= ", '".$this->num_payment."'";
if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'";

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
/* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -82,7 +83,8 @@ $form = new Form($db);
$salstatic = new PaymentSalary($db);
$userstatic = new User($db);
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,";
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_societe as fk_soc,";
$sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,";
$sql.= " pst.code as payment_code";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,";
@ -93,7 +95,7 @@ $sql.= " AND s.entity = ".$conf->entity;
// Search criteria
if ($search_ref) $sql.=" AND s.rowid=".$search_ref;
if ($search_label) $sql.=" AND s.label LIKE '%".$db->escape($search_label)."%'";
if ($search_amount) $sql.=" AND s.amount='".$db->escape(price2num(trim($search_amount)))."'";
if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1);
if ($filtre) {
$filtre=str_replace(":","=",$filtre);
$sql .= " AND ".$filtre;
@ -124,9 +126,10 @@ if ($result)
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.salary","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datev","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre("");
print "</tr>\n";
@ -136,6 +139,9 @@ if ($result)
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="3" name="search_ref" value="'.$search_ref.'">';
print '</td>';
// People
print '<td class="liste_titre">&nbsp;</td>';
// Current salary
print '<td class="liste_titre">&nbsp;</td>';
// Label
print '<td class="liste_titre"><input type="text" class="flat" size="14" name="search_label" value="'.$search_label.'"></td>';
@ -159,10 +165,19 @@ if ($result)
$userstatic->id=$obj->uid;
$userstatic->lastname=$obj->lastname;
$userstatic->firstname=$obj->firstname;
$userstatic->admin=$obj->admin;
$userstatic->login=$obj->login;
$userstatic->email=$obj->email;
$userstatic->societe_id=$obj->fk_soc;
$salstatic->id=$obj->rowid;
$salstatic->ref=$obj->rowid;
print "<td>".$salstatic->getNomUrl(1)."</td>\n";
// Ref
print "<td>".$salstatic->getNomUrl(1)."</td>\n";
// User name
print "<td>".$userstatic->getNomUrl(1)."</td>\n";
// Current salary
print "<td>".($obj->salary?price($obj->salary):'')."</td>\n";
// Label payment
print "<td>".dol_trunc($obj->label,40)."</td>\n";
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
// Type
@ -176,7 +191,7 @@ if ($result)
$i++;
}
print '<tr class="liste_total"><td colspan="5" class="liste_total">'.$langs->trans("Total").'</td>';
print '<tr class="liste_total"><td colspan="6" class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.price($total,0,$outputlangs,1,-1,-1,$conf->currency)."</td>";
print "<td>&nbsp;</td></tr>";

5
htdocs/conf/phpinfo.php Normal file
View File

@ -0,0 +1,5 @@
<a href="index.php">Go back to index</a>
| <a href="<?php echo $_SERVER["REQUEST_URI"];?>">Refresh</a>
<br><br>
<?php phpinfo(); ?>

View File

@ -73,7 +73,7 @@ $object = new Contrat($db);
$extrafields = new ExtraFields($db);
// Load object
if ($id > 0 || ! empty($ref)) {
if ($id > 0 || ! empty($ref) && $action!='add') {
$ret = $object->fetch($id, $ref);
if ($ret > 0)
$ret = $object->fetch_thirdparty();
@ -207,6 +207,13 @@ if ($action == 'add' && $user->rights->contrat->creer)
$error++;
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) {
$error ++;
$action = 'create';
}
if (! $error)
{
$object->socid = $socid;
@ -356,11 +363,6 @@ if ($action == 'add' && $user->rights->contrat->creer)
}
else
{
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++;
$result = $object->create($user);
if ($result > 0)
{
@ -726,20 +728,19 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
if ($ret < 0) $error++;
if ($ret < 0)
$error ++;
if (! $error)
{
$result = $object->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
else if ($reshook < 0) $error++;
if (! $error) {
if ($error)
{
$result = $object->insertExtraFields();
if ($result < 0) {
$error ++;
}
} else if ($reshook < 0)
$error ++;
if ($error) {
$action = 'edit_extras';
setEventMessage($object->error,'errors');
}

View File

View File

@ -91,7 +91,7 @@ llxHeader();
if ($object->id)
{
$head=contract_prepare_head($object, $user);
$head=contract_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans("Contract"), 0, 'contract');

View File

@ -206,7 +206,7 @@ abstract class CommonDocGenerator
/**
* Define array with couple subtitution key => subtitution value
*
* @param Object $object contact
* @param Contact $object contact
* @param Translate $outputlangs object for output
* @param array_key $array_key Name of the key for return array
* @return array of substitution key->code
@ -442,7 +442,7 @@ abstract class CommonDocGenerator
/**
* Define array with couple substitution key => substitution value
*
* @param Object $object Main object to use as data source
* @param Expedition $object Main object to use as data source
* @param Translate $outputlangs Lang object to use for output
* @param array_key $array_key Name of the key for return array
* @return array Array of substitution

View File

@ -888,7 +888,7 @@ abstract class CommonObject
if (! $this->table_element)
{
dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined", LOG_ERR);
dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined");
return -1;
}
@ -2140,8 +2140,9 @@ abstract class CommonObject
$fieldstatus="fk_statut";
if ($elementTable == 'user') $fieldstatus="statut";
if ($elementTable == 'expensereport') $fieldstatus="fk_c_expensereport_statuts";
if ($elementTable == 'expensereport') $fieldstatus="fk_statut";
if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status";
$sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable;
$sql.= " SET ".$fieldstatus." = ".$status;
// If status = 1 = validated, update also fk_user_valid
@ -2389,8 +2390,8 @@ abstract class CommonObject
return 1;
}
}
/**
* Return incoterms informations
*
@ -2409,13 +2410,13 @@ abstract class CommonObject
$res = $this->db->fetch_object($result);
$out .= $res->code;
}
}
}
$out .= ' - '.$this->location_incoterms;
return $out;
}
/**
* Return incoterms informations for pdf display
*
@ -2430,12 +2431,12 @@ abstract class CommonObject
$res = $this->db->fetch_object($resql);
return 'Incoterm : '.$res->code.' - '.$this->location_incoterms;
}
else
else
{
return false;
return false;
}
}
/**
* Define incoterms values of current object
*
@ -2457,14 +2458,14 @@ abstract class CommonObject
{
$this->fk_incoterms = $id_incoterm;
$this->location_incoterms = $location;
$sql = 'SELECT libelle FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$res = $this->db->query($sql);
if ($res)
{
$obj = $this->db->fetch_object($res);
$this->libelle_incoterms = $obj->libelle;
}
}
return 1;
}
else

View File

@ -452,7 +452,7 @@ class Conf
$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024);
// Define list of limited modules
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later.
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,askpricesupplier,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later.
// Enable select2
if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)) $conf->global->MAIN_USE_JQUERY_MULTISELECT='select2';

View File

@ -109,7 +109,7 @@ class DolCookie
*
* @param string $cookie Cookie name
* @param string $value Cookie value
* @param string $expire Expiration
* @param integer $expire Expiration
* @param string $path Path of cookie
* @param string $domain Domain name
* @param int $secure 0 or 1

View File

@ -65,7 +65,7 @@ class DolGraph
var $bgcolorgrid=array(255,255,255); // array(R,G,B)
var $datacolor; // array(array(R,G,B),...)
private $_stringtoshow; // To store string to output graph into HTML page
protected $stringtoshow; // To store string to output graph into HTML page
/**
@ -774,7 +774,7 @@ class DolGraph
// Generate file
$graph->draw($file);
$this->_stringtoshow='<!-- Build using '.$this->_library.' --><img src="'.$fileurl.'" title="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'" alt="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'">';
$this->stringtoshow='<!-- Build using '.$this->_library.' --><img src="'.$fileurl.'" title="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'" alt="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'">';
}
@ -847,18 +847,18 @@ class DolGraph
}
$tag=dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file),'_',array('-','.'))));
$this->_stringtoshow ='<!-- Build using '.$this->_library.' -->'."\n";
if (! empty($this->title)) $this->_stringtoshow.='<div align="center" class="dolgraphtitle'.(empty($this->cssprefix)?'':' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
$this->_stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix)?'':' dolgraph'.$this->cssprefix).'"></div>'."\n";
$this->_stringtoshow.='<script id="'.$tag.'">'."\n";
$this->_stringtoshow.='$(function () {'."\n";
$this->stringtoshow ='<!-- Build using '.$this->_library.' -->'."\n";
if (! empty($this->title)) $this->stringtoshow.='<div align="center" class="dolgraphtitle'.(empty($this->cssprefix)?'':' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
$this->stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix)?'':' dolgraph'.$this->cssprefix).'"></div>'."\n";
$this->stringtoshow.='<script id="'.$tag.'">'."\n";
$this->stringtoshow.='$(function () {'."\n";
$i=$firstlot;
while ($i < $nblot)
{
$this->_stringtoshow.=$serie[$i];
$this->stringtoshow.=$serie[$i];
$i++;
}
$this->_stringtoshow.="\n";
$this->stringtoshow.="\n";
// Special case for Graph of type 'pie'
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie')
@ -871,7 +871,7 @@ class DolGraph
$showpointvalue=$this->showpointvalue;
$showpercent=$this->showpercent;
$this->_stringtoshow.= '
$this->stringtoshow.= '
function plotWithOptions_'.$tag.'() {
$.plot($("#placeholder_'.$tag.'"), d0,
{
@ -886,15 +886,15 @@ class DolGraph
var percent=Math.round(series.percent);
var number=series.data[0][1];
return \'';
$this->_stringtoshow.='<div style="font-size:8pt;text-align:center;padding:2px;color:white;">';
if ($urltemp) $this->_stringtoshow.='<a style="color: #FFFFFF;" border="0" href="'.$urltemp.'">';
$this->_stringtoshow.='\'+';
$this->_stringtoshow.=($showlegend?'':'label+\'<br/>\'+'); // Hide label if already shown in legend
$this->_stringtoshow.=($showpointvalue?'number+':'');
$this->_stringtoshow.=($showpercent?'\'<br/>\'+percent+\'%\'+':'');
$this->_stringtoshow.='\'';
if ($urltemp) $this->_stringtoshow.='</a>';
$this->_stringtoshow.='</div>\';
$this->stringtoshow.='<div style="font-size:8pt;text-align:center;padding:2px;color:white;">';
if ($urltemp) $this->stringtoshow.='<a style="color: #FFFFFF;" border="0" href="'.$urltemp.'">';
$this->stringtoshow.='\'+';
$this->stringtoshow.=($showlegend?'':'label+\'<br/>\'+'); // Hide label if already shown in legend
$this->stringtoshow.=($showpointvalue?'number+':'');
$this->stringtoshow.=($showpercent?'\'<br/>\'+percent+\'%\'+':'');
$this->stringtoshow.='\'';
if ($urltemp) $this->stringtoshow.='</a>';
$this->stringtoshow.='</div>\';
},
background: {
opacity: 0.5,
@ -911,9 +911,9 @@ class DolGraph
},';
if (count($datacolor))
{
$this->_stringtoshow.='colors: '.(! empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)).',';
$this->stringtoshow.='colors: '.(! empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)).',';
}
$this->_stringtoshow.='legend: {show: '.($showlegend?'true':'false').', position: \'ne\' }
$this->stringtoshow.='legend: {show: '.($showlegend?'true':'false').', position: \'ne\' }
});
}'."\n";
}
@ -921,7 +921,7 @@ class DolGraph
else
{
// Add code to support tooltips
$this->_stringtoshow.='
$this->stringtoshow.='
function showTooltip_'.$tag.'(x, y, contents) {
$(\'<div id="tooltip_'.$tag.'">\' + contents + \'</div>\').css({
position: \'absolute\',
@ -935,26 +935,26 @@ class DolGraph
opacity: 0.80
}).appendTo("body").fadeIn(20);
}
var previousPoint = null;
$("#placeholder_'.$tag.'").bind("plothover", function (event, pos, item) {
$("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2));
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
$("#tooltip").remove();
/* console.log(item); */
var x = item.datapoint[0].toFixed(2);
var y = item.datapoint[1].toFixed(2);
var z = item.series.xaxis.ticks[item.dataIndex].label;
';
if ($this->showpointvalue > 0) $this->_stringtoshow.='
if ($this->showpointvalue > 0) $this->stringtoshow.='
showTooltip_'.$tag.'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
';
$this->_stringtoshow.='
$this->stringtoshow.='
}
}
else {
@ -964,50 +964,50 @@ class DolGraph
});
';
$this->_stringtoshow.='var stack = null, steps = false;'."\n";
$this->stringtoshow.='var stack = null, steps = false;'."\n";
$this->_stringtoshow.='function plotWithOptions_'.$tag.'() {'."\n";
$this->_stringtoshow.='$.plot($("#placeholder_'.$tag.'"), [ '."\n";
$this->stringtoshow.='function plotWithOptions_'.$tag.'() {'."\n";
$this->stringtoshow.='$.plot($("#placeholder_'.$tag.'"), [ '."\n";
$i=$firstlot;
while ($i < $nblot)
{
if ($i > $firstlot) $this->_stringtoshow.=', '."\n";
if ($i > $firstlot) $this->stringtoshow.=', '."\n";
$color=sprintf("%02x%02x%02x",$this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]);
$this->_stringtoshow.='{ ';
if (! isset($this->type[$i]) || $this->type[$i] == 'bars') $this->_stringtoshow.='bars: { show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, ';
if (isset($this->type[$i]) && $this->type[$i] == 'lines') $this->_stringtoshow.='lines: { show: true, fill: false }, ';
$this->_stringtoshow.='color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }';
$this->stringtoshow.='{ ';
if (! isset($this->type[$i]) || $this->type[$i] == 'bars') $this->stringtoshow.='bars: { show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, ';
if (isset($this->type[$i]) && $this->type[$i] == 'lines') $this->stringtoshow.='lines: { show: true, fill: false }, ';
$this->stringtoshow.='color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }';
$i++;
}
$this->_stringtoshow.="\n".' ], { series: { stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6 } }'."\n";
$this->stringtoshow.="\n".' ], { series: { stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6 } }'."\n";
// Xaxis
$this->_stringtoshow.=', xaxis: { ticks: ['."\n";
$this->stringtoshow.=', xaxis: { ticks: ['."\n";
$x=0;
foreach($this->data as $key => $valarray)
{
if ($x > 0) $this->_stringtoshow.=', '."\n";
$this->_stringtoshow.= ' ['.$x.', "'.$valarray[0].'"]';
if ($x > 0) $this->stringtoshow.=', '."\n";
$this->stringtoshow.= ' ['.$x.', "'.$valarray[0].'"]';
$x++;
}
$this->_stringtoshow.='] }'."\n";
$this->stringtoshow.='] }'."\n";
// Yaxis
$this->_stringtoshow.=', yaxis: { min: '.$this->MinValue.', max: '.($this->MaxValue).' }'."\n";
$this->stringtoshow.=', yaxis: { min: '.$this->MinValue.', max: '.($this->MaxValue).' }'."\n";
// Background color
$color1=sprintf("%02x%02x%02x",$this->bgcolorgrid[0],$this->bgcolorgrid[0],$this->bgcolorgrid[2]);
$color2=sprintf("%02x%02x%02x",$this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]);
$this->_stringtoshow.=', grid: { hoverable: true, backgroundColor: { colors: ["#'.$color1.'", "#'.$color2.'"] } }'."\n";
//$this->_stringtoshow.=', shadowSize: 20'."\n"; TODO Uncommet this
$this->_stringtoshow.='});'."\n";
$this->_stringtoshow.='}'."\n";
$this->stringtoshow.=', grid: { hoverable: true, backgroundColor: { colors: ["#'.$color1.'", "#'.$color2.'"] } }'."\n";
//$this->stringtoshow.=', shadowSize: 20'."\n"; TODO Uncommet this
$this->stringtoshow.='});'."\n";
$this->stringtoshow.='}'."\n";
}
$this->_stringtoshow.='plotWithOptions_'.$tag.'();'."\n";
$this->_stringtoshow.='});'."\n";
$this->_stringtoshow.='</script>'."\n";
$this->stringtoshow.='plotWithOptions_'.$tag.'();'."\n";
$this->stringtoshow.='});'."\n";
$this->stringtoshow.='</script>'."\n";
}
@ -1019,10 +1019,10 @@ class DolGraph
*/
function show()
{
return $this->_stringtoshow;
return $this->stringtoshow;
}
/**
* getDefaultGraphSizeForStats
*
@ -1033,18 +1033,18 @@ class DolGraph
static function getDefaultGraphSizeForStats($direction,$defaultsize='')
{
global $conf;
if ($direction == 'width')
{
if (empty($conf->dol_optimize_smallscreen)) return ($defaultsize ? $defaultsize : '500');
else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width']-40));
}
if ($direction == 'height')
if ($direction == 'height')
{
return (empty($conf->dol_optimize_smallscreen)?($defaultsize?$defaultsize:'200'):'160');
}
return 0;
}
}

View File

@ -48,10 +48,14 @@ class ExtraFields
var $attribute_required;
// Array to store parameters of attribute (used in select type)
var $attribute_param;
// Int to store position of attribute
// Array to store position of attribute
var $attribute_pos;
// Int to store if attribute is editable regardless of the document status
// Array to store if attribute is editable regardless of the document status
var $attribute_alwayseditable;
// Array to store permission to check
var $attribute_perms;
// Array to store permission to check
var $attribute_list;
var $error;
var $errno;
@ -90,6 +94,8 @@ class ExtraFields
$this->attribute_elementtype = array();
$this->attribute_unique = array();
$this->attribute_required = array();
$this->attribute_perms = array();
$this->attribute_list = array();
}
/**
@ -106,9 +112,11 @@ class ExtraFields
* @param string $default_value Defaulted value
* @param array $param Params for field
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param int $list Into list view by default
* @return int <=0 if KO, >0 if OK
*/
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0)
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0, $perms='', $list=0)
{
if (empty($attrname)) return -1;
if (empty($label)) return -1;
@ -118,13 +126,13 @@ class ExtraFields
// Create field into database except for separator type which is not stored in database
if ($type != 'separate')
{
$result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param);
$result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value, $param, $perms, $list);
}
$err1=$this->errno;
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate')
{
// Add declaration of field into table
$result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable);
$result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable, $perms, $list);
$err2=$this->errno;
if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS'))
{
@ -152,10 +160,11 @@ class ExtraFields
* @param int $required Is field required or not
* @param string $default_value Default value for field
* @param array $param Params for field (ex for select list : array('options'=>array('value'=>'label of option'))
*
* @param string $perms Permission
* @param int $list Into list view by default
* @return int <=0 if KO, >0 if OK
*/
private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='')
private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0)
{
if ($elementtype == 'thirdparty') $elementtype='societe';
@ -225,9 +234,11 @@ class ExtraFields
* @param int $required Is field required or not
* @param array||string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param int $list Into list view by default
* @return int <=0 if KO, >0 if OK
*/
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0)
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=0)
{
global $conf;
@ -235,6 +246,7 @@ class ExtraFields
// Clean parameters
if (empty($pos)) $pos=0;
if (empty($list)) $list=0;
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname))
{
@ -251,7 +263,7 @@ class ExtraFields
$params='';
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable)";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable, perms, list)";
$sql.= " VALUES('".$attrname."',";
$sql.= " '".$this->db->escape($label)."',";
$sql.= " '".$type."',";
@ -262,7 +274,9 @@ class ExtraFields
$sql.= " '".$unique."',";
$sql.= " '".$required."',";
$sql.= " '".$params."',";
$sql.= " '".$alwayseditable."'";
$sql.= " '".$alwayseditable."',";
$sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").",";
$sql.= " ".$list;
$sql.=')';
dol_syslog(get_class($this)."::create_label", LOG_DEBUG);
@ -363,9 +377,11 @@ class ExtraFields
* @param int $pos Position of attribute
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param int $list Into list view by default
* @return int >0 if OK, <=0 if KO
*/
function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0)
function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='',$list='')
{
if ($elementtype == 'thirdparty') $elementtype='societe';
@ -402,7 +418,7 @@ class ExtraFields
{
if ($label)
{
$result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable);
$result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list);
}
if ($result > 0)
{
@ -451,14 +467,18 @@ class ExtraFields
* @param int $pos Position of attribute
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param int $list Into list view by default
* @return int <=0 if KO, >0 if OK
*/
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0)
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0)
{
global $conf;
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required);
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list);
// Clean parameters
if ($elementtype == 'thirdparty') $elementtype='societe';
if (empty($list)) $list=0;
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
@ -485,9 +505,11 @@ class ExtraFields
$sql.= " elementtype,";
$sql.= " fieldunique,";
$sql.= " fieldrequired,";
$sql.= " perms,";
$sql.= " pos,";
$sql.= " alwayseditable,";
$sql.= " param";
$sql.= " param,";
$sql.= " list";
$sql.= ") VALUES (";
$sql.= "'".$attrname."',";
$sql.= " ".$conf->entity.",";
@ -497,9 +519,11 @@ class ExtraFields
$sql.= " '".$elementtype."',";
$sql.= " '".$unique."',";
$sql.= " '".$required."',";
$sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").",";
$sql.= " '".$pos."',";
$sql.= " '".$alwayseditable."',";
$sql.= " '".$param."'";
$sql.= " ".$list;
$sql.= ")";
dol_syslog(get_class($this)."::update_label", LOG_DEBUG);
$resql2=$this->db->query($sql);
@ -542,7 +566,7 @@ class ExtraFields
// For avoid conflicts with external modules
if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label;
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable";
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
$sql.= " WHERE entity IN (0,".$conf->entity.")";
if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'";
@ -571,6 +595,8 @@ class ExtraFields
$this->attribute_param[$tab->name]=unserialize($tab->param);
$this->attribute_pos[$tab->name]=$tab->pos;
$this->attribute_alwayseditable[$tab->name]=$tab->alwayseditable;
$this->attribute_perms[$tab->name]=$tab->perms;
$this->attribute_perms[$tab->name]=$tab->list;
}
}
}
@ -603,6 +629,9 @@ class ExtraFields
$unique=$this->attribute_unique[$key];
$required=$this->attribute_required[$key];
$param=$this->attribute_param[$key];
$perms=$this->attribute_perms[$key];
$list=$this->attribute_list[$key];
if ($type == 'date')
{
$showsize=10;
@ -883,7 +912,7 @@ class ExtraFields
elseif ($type == 'chkbxlst')
{
$value_arr = explode(',', $value);
if (is_array($param['options'])) {
$param_list = array_keys($param['options']);
$InfoFieldList = explode(":", $param_list[0]);
@ -893,7 +922,7 @@ class ExtraFields
// 3 : key field parent (for dependent lists)
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid');
if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) {
list ( $parentName, $parentField ) = explode('|', $InfoFieldList[3]);
$keyList .= ', ' . $parentField;
@ -905,13 +934,13 @@ class ExtraFields
$keyList = $InfoFieldList[2] . ' as rowid';
}
}
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
$keyList .= ', ';
$keyList .= implode(', ', $fields_label);
}
$sqlwhere = '';
$sql = 'SELECT ' . $keyList;
$sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
@ -927,7 +956,7 @@ class ExtraFields
$sqlwhere .= ' WHERE 1';
}
if (in_array($InfoFieldList[0], array (
'tablewithentity'
'tablewithentity'
)))
$sqlwhere .= ' AND entity = ' . $conf->entity; // Some tables may have field, some other not. For the moment we disable it.
// $sql.=preg_replace('/^ AND /','',$sqlwhere);
@ -941,7 +970,7 @@ class ExtraFields
while ( $i < $num ) {
$labeltoshow = '';
$obj = $this->db->fetch_object($resql);
// Several field into label (eq table:code|libelle:rowid)
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
@ -953,7 +982,7 @@ class ExtraFields
$labeltoshow = $obj->$InfoFieldList[1];
}
$labeltoshow = dol_trunc($labeltoshow, 45);
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
foreach ( $fields_label as $field_toshow ) {
$translabel = $langs->trans($obj->$field_toshow);
@ -965,9 +994,9 @@ class ExtraFields
}
$out .= '<input class="flat" type="checkbox" name="options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
$out .= ' value="' . $obj->rowid . '"';
$out .= 'checked="checked"';
$out .= '/>' . $labeltoshow . '<br>';
} else {
if (! $notrans) {
@ -980,31 +1009,31 @@ class ExtraFields
}
if (empty($labeltoshow))
$labeltoshow = '(not defined)';
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
$out .= '<input class="flat" type="checkbox" name="options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
$out .= ' value="' . $obj->rowid . '"';
$out .= 'checked="checked"';
$out .= '';
$out .= '/>' . $labeltoshow . '<br>';
}
if (! empty($InfoFieldList[3])) {
$parent = $parentName . ':' . $obj->{$parentField};
}
$out .= '<input class="flat" type="checkbox" name="options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
$out .= ' value="' . $obj->rowid . '"';
$out .= ((is_array($value_arr) && in_array($obj->rowid, $value_arr)) ? ' checked="checked" ' : '');
;
$out .= '';
$out .= '/>' . $labeltoshow . '<br>';
}
$i ++;
}
$this->db->free($resql);
@ -1040,6 +1069,9 @@ class ExtraFields
$unique=$this->attribute_unique[$key];
$required=$this->attribute_required[$key];
$params=$this->attribute_param[$key];
$perms=$this->attribute_perms[$key];
$list=$this->attribute_list[$key];
if ($type == 'date')
{
$showsize=10;
@ -1172,24 +1204,24 @@ class ExtraFields
elseif ($type == 'chkbxlst')
{
$value_arr = explode(',', $value);
$param_list = array_keys($params['options']);
$InfoFieldList = explode(":", $param_list[0]);
$selectkey = "rowid";
$keyList = 'rowid';
if (count($InfoFieldList) >= 3) {
$selectkey = $InfoFieldList[2];
$keyList = $InfoFieldList[2] . ' as rowid';
}
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
$keyList .= ', ';
$keyList .= implode(', ', $fields_label);
}
$sql = 'SELECT ' . $keyList;
$sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
if (strpos($InfoFieldList[4], 'extra') !== false) {
@ -1197,14 +1229,14 @@ class ExtraFields
}
// $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
// $sql.= ' AND entity = '.$conf->entity;
dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst',LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$value = ''; // value was used, so now we reste it to use it to build final output
while ( $obj = $this->db->fetch_object($resql) ) {
// Several field into label (eq table:code|libelle:rowid)
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {

View File

@ -480,7 +480,7 @@ class Form
* @param string $selected Id or Code or Label of preselected country
* @param string $htmlname Name of html select object
* @param string $htmloption Options html on select object
* @param string $maxlength Max length for labels (0=no limit)
* @param integer $maxlength Max length for labels (0=no limit)
* @return string HTML string with select
*/
function select_country($selected='',$htmlname='country_id',$htmloption='',$maxlength=0)
@ -658,7 +658,7 @@ class Form
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select)
* @param string $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, -1=Force none (and set hidden field to 'service')
* @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, -1=Force none (and set hidden field to 'service')
* @return void
*/
function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0)
@ -1072,9 +1072,9 @@ class Form
* @param int $showempty 0=no empty value, 1=add an empty value
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param string $showfunction Add function into label
* @param integer $showfunction Add function into label
* @param string $moreclass Add more class to class style
* @param string $showsoc Add company into label
* @param integer $showsoc Add company into label
* @param int $forcecombo Force to use combo box
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param bool $options_only Return options only (for ajax treatment)
@ -1095,10 +1095,10 @@ class Form
* @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit)
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param string $showfunction Add function into label
* @param integer $showfunction Add function into label
* @param string $moreclass Add more class to class style
* @param bool $options_only Return options only (for ajax treatment)
* @param string $showsoc Add company into label
* @param integer $showsoc Add company into label
* @param int $forcecombo Force to use combo box
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @return int <0 if KO, Nb of contact in list if OK

View File

@ -45,7 +45,7 @@ class FormBank
/**
* Retourne la liste des types de comptes financiers
*
* @param string $selected Type pre-selectionne
* @param integer $selected Type pre-selectionne
* @param string $htmlname Nom champ formulaire
* @return void
*/

View File

@ -47,8 +47,8 @@ class FormCron extends Form
* Display On Off selector
*
* @param string $htmlname Html control name
* @param string $selected selected value
* @param string $readonly Select is read only or not
* @param integer $selected selected value
* @param integer $readonly Select is read only or not
* @return string HTML select field
*/
function select_typejob($htmlname,$selected=0,$readonly=0)

View File

@ -48,7 +48,7 @@ class FormMailing extends Form
*
* @param string $selectedid the selected id
* @param string $htmlname name of controm
* @param number $show_empty show empty option
* @param integer $show_empty show empty option
* @return string HTML select
*/
public function selectDestinariesStatus($selectedid='',$htmlname='dest_status', $show_empty=0) {

View File

@ -57,11 +57,11 @@ class FormOrder
{
print '<select class="flat" name="'.$hmlname.'">';
print '<option value="-1">&nbsp;</option>';
$statustohow=array(0,1,2,3,4,5,6,9); // 7 is same label than 6. 8 does not exist.
$statustohow=array('0'=>'0','1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6,7','9'=>'9'); // 7 is same label than 6. 8 does not exist.
foreach($statustohow as $key)
foreach($statustohow as $key => $value)
{
print '<option value="'.$key.'"'.($selected == $key?' selected="selected"':'').'>';
print '<option value="'.$value.'"'.(($selected == $key || $selected == $value)?' selected="selected"':'').'>';
print CommandeFournisseur::LibStatut($key,$short);
print '</option>';
}

View File

@ -157,7 +157,7 @@ class FormOther
*
* @param string $selected Preselected ecotaxes
* @param string $htmlname Name of combo list
* @return void
* @return integer
*/
function select_ecotaxes($selected='',$htmlname='ecotaxe_id')
{
@ -268,7 +268,7 @@ class FormOther
/**
* Return a HTML select list to select a percent
*
* @param string $selected pourcentage pre-selectionne
* @param integer $selected pourcentage pre-selectionne
* @param string $htmlname nom de la liste deroulante
* @param int $disabled Disabled or not
* @param int $increment increment value
@ -303,7 +303,7 @@ class FormOther
* Return select list for categories (to use in form search selectors)
*
* @param int $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members)
* @param string $selected Preselected value
* @param integer $selected Preselected value
* @param string $htmlname Name of combo list
* @param int $nocateg Show also an entry "Not categorized"
* @return string Html combo list code
@ -834,7 +834,7 @@ class FormOther
* @param int $offset Offset
* @param int $invert Invert
* @param string $option Option
* @return void
* @return string
*/
function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='')
{

View File

@ -53,7 +53,7 @@ class Menu
*
* @param string $url Url to follow on click
* @param string $titre Label of menu to add
* @param string $level Level of menu to add
* @param integer $level Level of menu to add
* @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey)
* @param string $target Target lien
* @param string $mainmenu Main menu ('home', 'companies', 'products', ...)
@ -71,7 +71,7 @@ class Menu
* @param int $idafter Array key after which inserting new entry
* @param string $url Url to follow on click
* @param string $titre Label of menu to add
* @param string $level Level of menu to add
* @param integer $level Level of menu to add
* @param int $enabled Menu active or not
* @param string $target Target lien
* @param string $mainmenu Main menu ('home', 'companies', 'products', ...)

View File

@ -687,7 +687,7 @@ class MobileDetect
/**
* Retrieve the User-Agent.
*
* @return string|null The user agent if it's set.
* @return string The user agent if it's set.
*/
public function getUserAgent()
{
@ -879,7 +879,7 @@ class MobileDetect
*
* @param string $name Name
* @param array $arguments Arguments
* @return mixed
* @return null|boolean
*
* @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
* @method boolean is[...]()
@ -926,7 +926,7 @@ class MobileDetect
*
* @param string $key Key
* @param string $userAgent deprecated
* @return mixed
* @return null|boolean
*/
protected function matchUAAgainstKey($key, $userAgent = null)
{
@ -1009,7 +1009,7 @@ class MobileDetect
* @param string $key key
* @param string $userAgent deprecated
* @param string $httpHeaders deprecated
* @return bool|int|null
* @return null|boolean
*
* @todo: The httpHeaders part is not yet used.
*/

View File

@ -150,7 +150,7 @@ class SimpleOpenID
/**
* GetIdentity
*
* @return void
* @return string
*/
function GetIdentity()
{ // Get Identity
@ -187,7 +187,7 @@ class SimpleOpenID
/**
* IsError
*
* @return void
* @return boolean
*/
function IsError()
{
@ -225,7 +225,7 @@ class SimpleOpenID
* OpenID_Standarize
*
* @param string $openid_identity Server
* @return void
* @return string
*/
function OpenID_Standarize($openid_identity = null)
{
@ -251,7 +251,7 @@ class SimpleOpenID
* array2url
*
* @param array $arr An array
* @return boolean|string false if KO, string of url if OK
* @return false|string false if KO, string of url if OK
*/
function array2url($arr)
{ // converts associated array to URL Query String
@ -303,7 +303,7 @@ class SimpleOpenID
* @param string $url URL
* @param string $method Method
* @param string $params Params
* @return boolean|unknown
* @return string
*/
function CURL_Request($url, $method="GET", $params = "")
{ // Remember, SSL MUST BE SUPPORTED
@ -384,7 +384,7 @@ class SimpleOpenID
/**
* GetRedirectURL
*
* @return void
* @return string
*/
function GetRedirectURL()
{
@ -428,7 +428,7 @@ class SimpleOpenID
/**
* ValidateWithServer
*
* @return void
* @return boolean
*/
function ValidateWithServer()
{

View File

@ -153,7 +153,7 @@ class Translate
* If $domain is "file@module" instead of "file" then we look for module lang file
* in htdocs/custom/modules/mymodule/langs/code_CODE/file.lang
* then in htdocs/module/langs/code_CODE/file.lang instead of htdocs/langs/code_CODE/file.lang
* @param string $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US)
* @param integer $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US)
* @param int $stopafterdirection Stop when the DIRECTION tag is found (optimize speed)
* @param int $forcelangdir To force a different lang directory
* @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK
@ -548,7 +548,7 @@ class Translate
* Return list of all available languages
*
* @param string $langdir Directory to scan
* @param string $maxlength Max length for each value in combo box (will be truncated)
* @param integer $maxlength Max length for each value in combo box (will be truncated)
* @param int $usecode Show code instead of country name for language variant
* @return array List of languages
*/
@ -583,7 +583,7 @@ class Translate
* Return if a filename $filename exists for current language (or alternate language)
*
* @param string $filename Language filename to search
* @param string $searchalt Search also alernate language file
* @param integer $searchalt Search also alernate language file
* @return boolean true if exists and readable
*/
function file_exists($filename,$searchalt=0)
@ -720,7 +720,7 @@ class Translate
* Return a currency code into its symbol
*
* @param string $currency_code Currency code
* @param string $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency.
* @param integer $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency.
* @return string Currency symbol encoded into UTF8
*/
function getCurrencySymbol($currency_code, $forceloadall=0)

View File

@ -49,8 +49,8 @@ class WorkboardResponse
public $url_late;
/**
* Delay time to mark an item as late
* @var int
* Delay time to mark an item as late. In number of days.
* @var double
*/
public $warning_delay;

View File

@ -122,7 +122,7 @@ print '</body></html>'."\n";
* Convert date to timestamp
*
* @param string $mysqldate Date YYYMMDD
* @return timestamp Timestamp
* @return integer Timestamp
*/
function xyzToUnixTimestamp($mysqldate)
{

View File

@ -1,6 +1,7 @@
<?php
/*
* Copyright (C) 2013-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014-2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -270,10 +271,11 @@ abstract class DoliDB implements Database
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return timestamp|string Date TMS
* @return int|string Date TMS
*/
function jdate($string, $gm=false)
{
if ($string==0 || $string=="0000-00-00 00:00:00") return '';
$string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);

View File

@ -237,10 +237,10 @@ class DoliDBMssql extends DoliDB
$res=mssql_query('select @@TRANCOUNT');
$this->transaction_opened=mssql_result($res, 0, 0);
if ($this->transaction_opened == 0)
{
//return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTIONS ON' generate also a mess
//return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTIONS ON' generate also a mess
$ret=mssql_query("SET IMPLICIT_TRANSACTIONS OFF;BEGIN TRANSACTION;",$this->db);
if ($ret)
{
@ -264,7 +264,7 @@ class DoliDBMssql extends DoliDB
{
$res=mssql_query('select @@TRANCOUNT');
$this->transaction_opened=mssql_result($res, 0, 0);
if ($this->transaction_opened == 1)
{
//return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTION ON' generate also a mess
@ -296,7 +296,7 @@ class DoliDBMssql extends DoliDB
{
$res=mssql_query('select @@TRANCOUNT');
$this->transaction_opened=mssql_result($res, 0, 0);
if ($this->transaction_opened == 1)
{
$ret=mssql_query("ROLLBACK TRANSACTION",$this->db);
@ -322,7 +322,7 @@ class DoliDBMssql extends DoliDB
function query($query,$usesavepoint=0,$type='auto')
{
$query = trim($query);
if (preg_match('/^--/',$query)) return true;
// Conversion syntaxe MySql vers MSDE.
@ -331,7 +331,7 @@ class DoliDBMssql extends DoliDB
$query = str_ireplace(", tms = tms", "", $query);
$query=preg_replace("/([. ,\t(])(percent|file|public)([. ,=\t)])/","$1[$2]$3",$query);
if ($type=="auto" || $type='dml')
{
$query=preg_replace('/AUTO_INCREMENT/i','IDENTITY',$query);
@ -339,7 +339,7 @@ class DoliDBMssql extends DoliDB
$query=preg_replace('/float\((.*)\)/','numeric($1)',$query);
$query=preg_replace('/([ \t])unsigned|IF NOT EXISTS[ \t]/i','$1',$query);
$query=preg_replace('/([ \t])(MEDIUM|TINY|LONG){0,1}TEXT([ \t,])/i',"$1VARCHAR(MAX)$3",$query);
$matches=array();
$original_query='';
if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+(?:(UNIQUE)|INDEX)\h+(?:INDEX)?\h*(\w+?)\h*\((.+)\)/is', $query,$matches))
@ -360,7 +360,7 @@ class DoliDBMssql extends DoliDB
if ($query_comp)
$query.=" WHERE ".implode(" AND ",$query_comp);
}
}
}
else
{
if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+PRIMARY\h+KEY\h+(\w+?)\h*\((.+)\)/is', $query, $matches))
@ -369,7 +369,7 @@ class DoliDBMssql extends DoliDB
$query="ALTER TABLE [".$matches[1]."] ADD CONSTRAINT [".$matches[2]."] PRIMARY KEY CLUSTERED (".$matches[3].")";
}
}
}
if ($type=="auto" || $type='ddl')
@ -384,13 +384,13 @@ class DoliDBMssql extends DoliDB
// Supprimer l'instruction MySql
$query = str_ireplace(" limit ".$number, "", $query);
}
$itemfound = stripos($query, " week(");
if ($itemfound !== false) {
// Recreer une requete sans instruction Mysql
$positionMySql = stripos($query, " week(");
$newquery = substr($query, 0, $positionMySql);
// Recuperer la date passee en parametre
$extractvalue = stristr($query, " week(");
$extractvalue = substr($extractvalue, 6);
@ -398,7 +398,7 @@ class DoliDBMssql extends DoliDB
// Conserver la fin de la requete
$endofquery = substr($extractvalue, $positionMySql);
$extractvalue = substr($extractvalue, 0, $positionMySql);
// Remplacer l'instruction MySql en Sql Server
// Inserer la date en parametre et le reste de la requete
$query = $newquery." DATEPART(week, ".$extractvalue.$endofquery;
@ -407,11 +407,11 @@ class DoliDBMssql extends DoliDB
{
//var_dump($query);
//var_dump($matches);
if (stripos($query,'llx_c_departements') !== false) var_dump($query);
//if (stripos($query,'llx_c_departements') !== false) var_dump($query);
$sql='SET IDENTITY_INSERT ['.trim($matches[1]).'] ON;';
@mssql_query($sql, $this->db);
$post_query='SET IDENTITY_INSERT ['.trim($matches[1]).'] OFF;';
}
}
//print "<!--".$query."-->";
@ -427,7 +427,7 @@ class DoliDBMssql extends DoliDB
{
$ret = mssql_query($query, $this->db);
}
if (!empty($post_query))
{
@mssql_query($post_query, $this->db);
@ -732,13 +732,13 @@ class DoliDBMssql extends DoliDB
//TODO: Check if we need to force a charset
//$sql.= ' DEFAULT CHARACTER SET '.$charset.' DEFAULT COLLATE '.$collation;
$ret=$this->query($sql);
$this->select_db($database);
$sql="CREATE USER [$owner] FOR LOGIN [$owner]";
mssql_query($sql,$this->db);
$sql="ALTER ROLE [db_owner] ADD MEMBER [$owner]";
mssql_query($sql,$this->db);
$sql="ALTER DATABASE [$database] SET ANSI_NULL_DEFAULT ON;";
@mssql_query($sql,$this->db);
$sql="ALTER DATABASE [$database] SET ANSI_NULL ON;";
@ -976,12 +976,12 @@ class DoliDBMssql extends DoliDB
}
$sql="SELECT name from sys.databases where name='".$dolibarr_main_db_name."'";
$ressql=$this->query($sql);
if (! $ressql)
if (! $ressql)
{
dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_WARNING);
return -1;
}
else
}
else
{
if ($num)
{
@ -1106,7 +1106,7 @@ class DoliDBMssql extends DoliDB
return array();
}
/**
* Escape a field name according to escape's syntax
*
@ -1116,18 +1116,18 @@ class DoliDBMssql extends DoliDB
function EscapeFieldName($fieldname) {
return "[".$fieldname."]";
}
/**
* Get information on field
*
*
* @param string $table Table name which contains fields
* @param mixed $fields String for one field or array of string for multiple field
* @return boolean|multitype:object
*/
function GetFieldInformation($table,$fields) {
$sql="SELECT * from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='".$this->escape($table)."' AND COLUMN_NAME";
if (is_array($fields))
if (is_array($fields))
{
$where=" IN ('".implode("','",$fields)."')";
}
@ -1144,7 +1144,7 @@ class DoliDBMssql extends DoliDB
$result[]=$obj;
}
}
else
else
return false;
return $result;

View File

@ -183,7 +183,7 @@ class DoliDBMysql extends DoliDB
* @param string $login login
* @param string $passwd password
* @param string $name name of database (not used for mysql, used for pgsql)
* @param string $port Port of database server
* @param integer $port Port of database server
* @return resource Database access handler
* @see close
*/
@ -314,7 +314,7 @@ class DoliDBMysql extends DoliDB
/**
* Return datas as an array
*
* @param Resultset $resultset Resultset of request
* @param resource $resultset Resultset of request
* @return array Array
*/
function fetch_row($resultset)

View File

@ -186,7 +186,7 @@ class DoliDBMysqli extends DoliDB
* @param string $login login
* @param string $passwd password
* @param string $name name of database (not used for mysql, used for pgsql)
* @param string $port Port of database server
* @param integer $port Port of database server
* @return resource Database access handler
* @see close
*/
@ -317,7 +317,7 @@ class DoliDBMysqli extends DoliDB
/**
* Return datas as an array
*
* @param Resultset $resultset Resultset of request
* @param resource $resultset Resultset of request
* @return array Array
*/
function fetch_row($resultset)
@ -716,7 +716,7 @@ class DoliDBMysqli extends DoliDB
*
* @param string $table Name of table
* @param string $field Optionnel : Name of field if we want description of field
* @return resultset Resultset x (x->Field, x->Type, ...)
* @return resource Resultset x (x->Field, x->Type, ...)
*/
function DDLDescTable($table,$field="")
{

View File

@ -368,7 +368,7 @@ class DoliDBPgsql extends DoliDB
* @param string $login Login
* @param string $passwd Password
* @param string $name Name of database (not used for mysql, used for pgsql)
* @param string $port Port of database server
* @param integer $port Port of database server
* @return resource Database access handler
* @see close
*/
@ -546,7 +546,7 @@ class DoliDBPgsql extends DoliDB
/**
* Return datas as an array
*
* @param Resultset $resultset Resultset of request
* @param resource $resultset Resultset of request
* @return array Array
*/
function fetch_array($resultset)
@ -559,7 +559,7 @@ class DoliDBPgsql extends DoliDB
/**
* Return datas as an array
*
* @param Resultset $resultset Resultset of request
* @param resource $resultset Resultset of request
* @return array Array
*/
function fetch_row($resultset)
@ -771,7 +771,7 @@ class DoliDBPgsql extends DoliDB
*
* @param string $fieldorvalue Field name or value to encrypt
* @param int $withQuotes Return string with quotes
* @return return XXX(field) or XXX('value') or field or 'value'
* @return string XXX(field) or XXX('value') or field or 'value'
*/
function encrypt($fieldorvalue, $withQuotes=0)
{
@ -1010,7 +1010,7 @@ class DoliDBPgsql extends DoliDB
*
* @param string $table Name of table
* @param string $field Optionnel : Name of field if we want description of field
* @return resultset Resultset x (x->attname)
* @return resource Resultset x (x->attname)
*/
function DDLDescTable($table,$field="")
{

View File

@ -50,6 +50,7 @@ class DoliDBSqlite extends DoliDB
* @param string $pass Mot de passe
* @param string $name Nom de la database
* @param int $port Port of database server
* @return int 1 if OK, 0 if not
*/
function __construct($type, $host, $user, $pass, $name='', $port=0)
{

File diff suppressed because it is too large Load Diff

View File

@ -1157,7 +1157,7 @@ function dol_getdate($timestamp,$fast=false)
* @param int $year Year
* @param mixed $gm True or 1 or 'gmt'=Input informations are GMT values, False or 0 or 'server' = local to server TZ, 'user' = local to user TZ
* @param int $check 0=No check on parameters (Can use day 32, etc...)
* @return timestamp|string Date as a timestamp, '' or false if error
* @return int|string Date as a timestamp, '' or false if error
* @see dol_print_date, dol_stringtotime, dol_getdate
*/
function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
@ -4946,34 +4946,64 @@ function dol_getmypid()
/**
* Natural search
* Generate natural SQL search string
*
* @param mixed $fields String or array of strings filled with the fields names in the SQL query
* @param string $value The value to look for (example: "keyword1 keyword2")
* @return string $res The statement to append to the SQL query
* @param string|string[] $fields String or array of strings, filled with the name of fields in the SQL query
* @param string $value The value to look for.
* If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2
* If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000"
* @param string $numeric 0=value is list of keywords, 1=value is a numeric test
* @return string $res The statement to append to the SQL query
*/
function natural_search($fields, $value)
function natural_search($fields, $value, $numeric=0)
{
global $db;
global $db,$langs;
if ($numeric)
{
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
}
$crits = explode(' ', $value);
$res = '';
if (! is_array($fields)) $fields = array($fields);
$end = count($fields);
$nboffields = count($fields);
$end2 = count($crits);
$j = 0;
foreach ($crits as $crit) {
$i = 0;
foreach ($fields as $field) {
if ( $i > 0 && $i < $end) $res .= " OR ";
$res .= $field . " LIKE '%" . $db->escape(trim($crit)) . "%'";
foreach ($crits as $crit)
{
$i = 0; $i2 = 0;
$newres = '';
foreach ($fields as $field)
{
if ($numeric)
{
$operator='=';
$newcrit = preg_replace('/([<>=]+)/','',trim($crit));
preg_match('/([<>=]+)/',trim($crit), $reg);
if ($reg[1])
{
$operator = $reg[1];
}
if ($newcrit != '')
{
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' '.$operator.' '.price2num($newcrit);
$i2++; // a criteria was added to string
}
}
else
{
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " LIKE '%" . $db->escape(trim($crit)) . "%'";
$i2++; // a criteria was added to string
}
$i++;
}
if ($end > 1) $res .= ')';
if ($j < $end2 - 1) $res .= " AND ";
if ($end > 1 && $j < $end2 - 1) $res .= '(';
if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : '');
$j++;
}
return " AND " . ($end > 1? '(' : '') . $res;
$res = " AND (" . $res . ")";
//print 'xx'.$res.'yy';
return $res;
}

View File

@ -269,7 +269,7 @@ function dol_json_decode($json, $assoc=false)
/**
* Return text according to type
*
* @param mixed $val Value to decode
* @param string $val Value to decode
* @return string Formated value
*/
function _unval($val)

View File

@ -555,10 +555,12 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=$lines[$i]->label;
$taskstatic->date_start=$lines[$i]->date_start;
$taskstatic->date_end=$lines[$i]->date_end;
print $taskstatic->getNomUrl(0);
print "<br>";
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
//print "<br>";
//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
//print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
print "</td>\n";
// Planned Workload
@ -714,10 +716,12 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=$lines[$i]->label;
$taskstatic->date_start=$lines[$i]->date_start;
$taskstatic->date_end=$lines[$i]->date_end;
print $taskstatic->getNomUrl(0);
print "<br>";
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
//print "<br>";
//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
//print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
print "</td>\n";
// Planned Workload

View File

@ -39,166 +39,166 @@ abstract class DolibarrModules
*/
public $db;
/**
* @var string Relative path to module style sheet
* @deprecated
*/
public $style_sheet = '';
/**
* @var string Relative path to module style sheet
* @deprecated
*/
public $style_sheet = '';
/**
* @var array Paths to create when module is activated
*/
public $dirs = array();
/**
* @var array Paths to create when module is activated
*/
public $dirs = array();
/**
* @var array Module boxes
*/
public $boxes = array();
/**
* @var array Module boxes
*/
public $boxes = array();
/**
* @var array Module constants
*/
public $const = array();
/**
* @var array Module constants
*/
public $const = array();
/**
* @var array Module access rights
*/
public $rights;
/**
* @var array Module access rights
*/
public $rights;
/**
* @var string Module access rights family
*/
public $rights_class;
/**
* @var string Module access rights family
*/
public $rights_class;
/**
* @var array Module menu entries
*/
public $menu = array();
/**
* @var array Module menu entries
*/
public $menu = array();
/**
* @var array Module parts
* array(
* // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)
* 'triggers' => 0,
* // Set this to 1 if module has its own login method directory (/mymodule/core/login)
/**
* @var array Module parts
* array(
* // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)
* 'triggers' => 0,
* // Set this to 1 if module has its own login method directory (/mymodule/core/login)
* 'login' => 0,
* // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions)
* // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions)
* 'substitutions' => 0,
* // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus)
* // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus)
* 'menus' => 0,
* // Set this to 1 if module has its own theme directory (/mymodule/theme)
* // Set this to 1 if module has its own theme directory (/mymodule/theme)
* 'theme' => 0,
* // Set this to 1 if module overwrite template dir (/mymodule/core/tpl)
* 'tpl' => 0,
* // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode)
* // Set this to 1 if module overwrite template dir (/mymodule/core/tpl)
* 'tpl' => 0,
* // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode)
* 'barcode' => 0,
* // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx)
* // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx)
* 'models' => 0,
* // Set this to relative path of css file if module has its own css file
* // Set this to relative path of css file if module has its own css file
* 'css' => '/mymodule/css/mymodule.css.php',
* // Set this to relative path of js file if module must load a js on all pages
* // Set this to relative path of js file if module must load a js on all pages
* 'js' => '/mymodule/js/mymodule.js',
* // Set here all hooks context managed by module
* // Set here all hooks context managed by module
* 'hooks' => array('hookcontext1','hookcontext2'),
* // Set here all workflow context managed by module
* // Set here all workflow context managed by module
* 'workflow' => array(
* 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array(
* 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)',
* 'picto'=>'yourpicto@mymodule'
* )
* )
* )
*/
public $module_parts = array();
* 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array(
* 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)',
* 'picto'=>'yourpicto@mymodule'
* )
* )
* )
*/
public $module_parts = array();
/**
* @var string Module documents ?
* @deprecated Seems unused anywhere
*/
public $docs;
/**
* @var string Module documents ?
* @deprecated Seems unused anywhere
*/
public $docs;
/**
* @var string ?
* @deprecated Seems unused anywhere
*/
public $dbversion = "-";
/**
* @var string ?
* @deprecated Seems unused anywhere
*/
public $dbversion = "-";
/**
* @var string Error message
*/
public $error;
/**
* @var string Error message
*/
public $error;
/**
* @var int Module unique ID
*/
public $numero;
/**
* @var int Module unique ID
*/
public $numero;
/**
* @var string Module name
*/
public $name;
/**
* @var string Module name
*/
public $name;
/**
* @var string Module version
*/
public $version;
/**
* @var string Module version
*/
public $version;
/**
* @var string Module description
*/
public $description;
/**
* @var string Module description
*/
public $description;
/**
* @var string[] Module language files
*/
public $langfiles;
/**
* @var string[] Module language files
*/
public $langfiles;
/**
* @var string Module export code
*/
public $export_code;
/**
* @var string Module export code
*/
public $export_code;
/**
* @var string Module export label
*/
public $export_label;
/**
* @var string Module export label
*/
public $export_label;
/**
* @var string Module import code
*/
public $import_code;
/**
* @var string Module import code
*/
public $import_code;
/**
* @var string Module import label
*/
public $import_label;
/**
* @var string Module import label
*/
public $import_label;
/**
* @var string Module constant name
*/
public $const_name;
/**
* @var string Module constant name
*/
public $const_name;
/**
* @var bool Module can't be disabled
*/
public $always_enabled;
/**
* @var bool Module can't be disabled
*/
public $always_enabled;
/**
* @var bool Module is enabled globally (Multicompany support)
*/
public $core_enabled;
/**
* @var bool Module is enabled globally (Multicompany support)
*/
public $core_enabled;
/**
* Enables a module.
* Inserts all informations into database
*
/**
* Enables a module.
* Inserts all informations into database
*
* @param array $array_sql SQL requests to be executed when enabling module
* @param string $options String with options when disabling module:
* 'noboxes' = Do not insert boxes
* 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
*
* @return int 1 if OK, 0 if KO
*/
* @param string $options String with options when disabling module:
* 'noboxes' = Do not insert boxes
* 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
*
* @return int 1 if OK, 0 if KO
*/
function _init($array_sql, $options='')
{
global $conf;
@ -232,12 +232,12 @@ abstract class DolibarrModules
// Execute addons requests
$num=count($array_sql);
for ($i = 0; $i < $num; $i++)
for ($i = 0; $i < $num; $i++)
{
if (! $err)
{
$val=$array_sql[$i];
$sql=$val;
$sql=$val;
$ignoreerror=0;
if (is_array($val))
{
@ -367,12 +367,12 @@ abstract class DolibarrModules
// If module name translation using it's unique id does not exists, we take use its name to find translation
if (is_array($this->langfiles))
{
foreach($this->langfiles as $val)
{
if ($val) $langs->load($val);
}
foreach($this->langfiles as $val)
{
if ($val) $langs->load($val);
}
}
return $langs->trans($this->name);
return $langs->trans($this->name);
}
}
@ -389,20 +389,20 @@ abstract class DolibarrModules
if ($langs->trans("Module".$this->numero."Desc") != ("Module".$this->numero."Desc"))
{
// If module description translation exists
// If module description translation exists
return $langs->trans("Module".$this->numero."Desc");
}
else
{
{
// If module description translation using it's unique id does not exists, we take use its name to find translation
if (is_array($this->langfiles))
{
foreach($this->langfiles as $val)
{
if ($val) $langs->load($val);
}
foreach($this->langfiles as $val)
{
if ($val) $langs->load($val);
}
}
return $langs->trans($this->description);
return $langs->trans($this->description);
}
}
@ -429,7 +429,7 @@ abstract class DolibarrModules
else $ret=$langs->trans("VersionUnknown");
if (preg_match('/_deprecated/',$this->version)) $ret.=' ('.$langs->trans("Deprecated").')';
return $ret;
return $ret;
}
@ -582,9 +582,9 @@ abstract class DolibarrModules
global $conf;
$error=0;
$dirfound=0;
$dirfound=0;
if (empty($reldir)) return 1;
if (empty($reldir)) return 1;
include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
@ -599,10 +599,10 @@ abstract class DolibarrModules
$handle=@opendir($dir); // Dir may not exists
if (is_resource($handle))
{
$dirfound++;
$dirfound++;
// Run llx_mytable.sql files
while (($file = readdir($handle))!==false)
// Run llx_mytable.sql files
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data')
{
@ -613,8 +613,8 @@ abstract class DolibarrModules
rewinddir($handle);
// Run llx_mytable.key.sql files (Must be done after llx_mytable.sql)
while (($file = readdir($handle))!==false)
// Run llx_mytable.key.sql files (Must be done after llx_mytable.sql)
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data')
{
@ -626,7 +626,7 @@ abstract class DolibarrModules
rewinddir($handle);
// Run data_xxx.sql files (Must be done after llx_mytable.key.sql)
while (($file = readdir($handle))!==false)
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'data')
{
@ -638,7 +638,7 @@ abstract class DolibarrModules
rewinddir($handle);
// Run update_xxx.sql files
while (($file = readdir($handle))!==false)
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,6) == 'update')
{
@ -671,9 +671,9 @@ abstract class DolibarrModules
*/
function insert_boxes($option='')
{
require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php';
global $conf;
global $conf;
$err=0;
@ -681,8 +681,8 @@ abstract class DolibarrModules
{
$pos_name = InfoBox::getListOfPagesForBoxes();
foreach ($this->boxes as $key => $value)
{
foreach ($this->boxes as $key => $value)
{
$file = isset($this->boxes[$key]['file'])?$this->boxes[$key]['file']:'';
$note = isset($this->boxes[$key]['note'])?$this->boxes[$key]['note']:'';
$enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton'])?$this->boxes[$key]['enabledbydefaulton']:'Home';
@ -724,15 +724,15 @@ abstract class DolibarrModules
foreach ($pos_name as $key2 => $val2)
{
//print 'key2='.$key2.'-val2='.$val2."<br>\n";
//print 'key2='.$key2.'-val2='.$val2."<br>\n";
if ($enabledbydefaulton && $val2 != $enabledbydefaulton) continue; // Not enabled by default onto this page.
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)";
$sql.= " VALUES (".$lastid.", ".$key2.", '0', 0, ".$conf->entity.")";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)";
$sql.= " VALUES (".$lastid.", ".$key2.", '0', 0, ".$conf->entity.")";
dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) $err++;
dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) $err++;
}
}
@ -741,7 +741,7 @@ abstract class DolibarrModules
$this->db->commit();
}
else
{
{
$this->error=$this->db->lasterror();
$this->db->rollback();
}
@ -781,11 +781,22 @@ abstract class DolibarrModules
if (empty($file)) $file = isset($this->boxes[$key][1])?$this->boxes[$key][1]:''; // For backward compatibility
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";
$sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";
$sql.= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'";
$sql.= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;
if ($this->db->type == 'sqlite3') {
// sqlite doesn't support "USING" syntax.
// TODO: remove this dependency.
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes ";
$sql .= "WHERE ".MAIN_DB_PREFIX."boxes.box_id IN (";
$sql .= "SELECT ".MAIN_DB_PREFIX."boxes_def.rowid ";
$sql .= "FROM ".MAIN_DB_PREFIX."boxes_def ";
$sql .= "WHERE ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."') ";
$sql .= "AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;
} else {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";
$sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";
$sql.= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'";
$sql.= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;
}
dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG);
$resql=$this->db->query($sql);
@ -1012,7 +1023,7 @@ abstract class DolibarrModules
if ($resql)
{
$obj=$this->db->fetch_object($resql);
if (! empty($obj->value) && ! empty($this->rights))
if ($obj !== null && ! empty($obj->value) && ! empty($this->rights))
{
// Si module actif
foreach ($this->rights as $key => $value)
@ -1027,54 +1038,54 @@ abstract class DolibarrModules
if (empty($r_type)) $r_type='w';
// Search if perm already present
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE id = ".$r_id." AND entity = ".$entity;
$resqlselect=$this->db->query($sql);
// Search if perm already present
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE id = ".$r_id." AND entity = ".$entity;
$resqlselect=$this->db->query($sql);
$obj = $this->db->fetch_object($resqlselect);
$obj = $this->db->fetch_object($resqlselect);
if ($obj->nb == 0)
{
if (dol_strlen($r_perms) )
{
if (dol_strlen($r_subperms) )
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
$sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)";
$sql.= " VALUES ";
$sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')";
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
$sql.= " (id, entity, libelle, module, type, bydefault, perms)";
$sql.= " VALUES ";
$sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')";
}
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
$sql .= " (id, entity, libelle, module, type, bydefault)";
$sql .= " VALUES ";
$sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")";
}
if (dol_strlen($r_perms) )
{
if (dol_strlen($r_subperms) )
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
$sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)";
$sql.= " VALUES ";
$sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')";
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
$sql.= " (id, entity, libelle, module, type, bydefault, perms)";
$sql.= " VALUES ";
$sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')";
}
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
$sql .= " (id, entity, libelle, module, type, bydefault)";
$sql .= " VALUES ";
$sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")";
}
$resqlinsert=$this->db->query($sql,1);
$resqlinsert=$this->db->query($sql,1);
if (! $resqlinsert)
{
if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS")
{
$this->error=$this->db->lasterror();
$err++;
break;
}
else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO);
if (! $resqlinsert)
{
if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS")
{
$this->error=$this->db->lasterror();
$err++;
break;
}
else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO);
}
}
$this->db->free($resqlinsert);
$this->db->free($resqlinsert);
}
$this->db->free($resqlselect);
@ -1082,9 +1093,9 @@ abstract class DolibarrModules
// If we want to init permissions on admin users
if ($reinitadminperms)
{
if (! class_exists('User')) {
require DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
}
if (! class_exists('User')) {
require DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
}
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1";
dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG);
$resqlseladmin=$this->db->query($sql,1);
@ -1099,7 +1110,7 @@ abstract class DolibarrModules
$tmpuser=new User($this->db);
$tmpuser->fetch($obj2->rowid);
if (!empty($tmpuser->id)) {
$tmpuser->addrights($r_id);
$tmpuser->addrights($r_id);
}
$i++;
}
@ -1158,7 +1169,7 @@ abstract class DolibarrModules
*/
function insert_menus()
{
global $user;
global $user;
require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php';
@ -1415,68 +1426,68 @@ abstract class DolibarrModules
*/
function insert_module_parts()
{
global $conf;
global $conf;
$error=0;
$entity=$conf->entity;
$error=0;
$entity=$conf->entity;
if (is_array($this->module_parts) && ! empty($this->module_parts))
{
foreach($this->module_parts as $key => $value)
{
if (is_array($this->module_parts) && ! empty($this->module_parts))
{
foreach($this->module_parts as $key => $value)
{
if (is_array($value) && count($value) == 0) continue; // Discard empty arrays
$newvalue = $value;
$newvalue = $value;
// Serialize array parameters
if (is_array($value))
{
// Can defined other parameters
if (is_array($value['data']) && ! empty($value['data']))
{
$newvalue = json_encode($value['data']);
if (isset($value['entity'])) $entity = $value['entity'];
}
else
{
$newvalue = json_encode($value);
}
}
// Serialize array parameters
if (is_array($value))
{
// Can defined other parameters
if (is_array($value['data']) && ! empty($value['data']))
{
$newvalue = json_encode($value['data']);
if (isset($value['entity'])) $entity = $value['entity'];
}
else
{
$newvalue = json_encode($value);
}
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";
$sql.= "name";
$sql.= ", type";
$sql.= ", value";
$sql.= ", note";
$sql.= ", visible";
$sql.= ", entity";
$sql.= ")";
$sql.= " VALUES (";
$sql.= $this->db->encrypt($this->const_name."_".strtoupper($key), 1);
$sql.= ", 'chaine'";
$sql.= ", ".$this->db->encrypt($newvalue, 1);
$sql.= ", null";
$sql.= ", '0'";
$sql.= ", ".$entity;
$sql.= ")";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";
$sql.= "name";
$sql.= ", type";
$sql.= ", value";
$sql.= ", note";
$sql.= ", visible";
$sql.= ", entity";
$sql.= ")";
$sql.= " VALUES (";
$sql.= $this->db->encrypt($this->const_name."_".strtoupper($key), 1);
$sql.= ", 'chaine'";
$sql.= ", ".$this->db->encrypt($newvalue, 1);
$sql.= ", null";
$sql.= ", '0'";
$sql.= ", ".$entity;
$sql.= ")";
dol_syslog(get_class($this)."::insert_const_".$key."", LOG_DEBUG);
$resql=$this->db->query($sql,1);
if (! $resql)
{
if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$error++;
$this->error=$this->db->lasterror();
}
else
{
dol_syslog(get_class($this)."::insert_const_".$key." Record already exists.", LOG_WARNING);
}
}
}
}
return $error;
dol_syslog(get_class($this)."::insert_const_".$key."", LOG_DEBUG);
$resql=$this->db->query($sql,1);
if (! $resql)
{
if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$error++;
$this->error=$this->db->lasterror();
}
else
{
dol_syslog(get_class($this)."::insert_const_".$key." Record already exists.", LOG_WARNING);
}
}
}
}
return $error;
}
/**
@ -1486,31 +1497,31 @@ abstract class DolibarrModules
*/
function delete_module_parts()
{
global $conf;
global $conf;
$err=0;
$entity=$conf->entity;
$err=0;
$entity=$conf->entity;
if (is_array($this->module_parts) && ! empty($this->module_parts))
{
foreach($this->module_parts as $key => $value)
{
// If entity is defined
if (is_array($value) && isset($value['entity'])) $entity = $value['entity'];
if (is_array($this->module_parts) && ! empty($this->module_parts))
{
foreach($this->module_parts as $key => $value)
{
// If entity is defined
if (is_array($value) && isset($value['entity'])) $entity = $value['entity'];
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
$sql.= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->const_name."_".strtoupper($key)."'";
$sql.= " AND entity = ".$entity;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
$sql.= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->const_name."_".strtoupper($key)."'";
$sql.= " AND entity = ".$entity;
dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG);
if (! $this->db->query($sql))
{
$this->error=$this->db->lasterror();
$err++;
}
}
}
return $err;
dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG);
if (! $this->db->query($sql))
{
$this->error=$this->db->lasterror();
$err++;
}
}
}
return $err;
}
}

View File

@ -591,12 +591,9 @@ class pdf_aurore extends ModelePDFAskPriceSupplier
}
else
{
$this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
$this->error=$langs->trans("ErrorConstantNotDefined","ASKSUPPLIERPICE_OUTPUTDIR");
return 0;
}
$this->error=$langs->trans("ErrorUnknown");
return 0; // Erreur par defaut
}
/**

View File

@ -43,7 +43,7 @@ abstract class ModelePDFAskPriceSupplier extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@ -149,7 +149,7 @@ abstract class ModeleNumRefAskPriceSupplier
* Create a document onto disk according to template module.
*
* @param DoliDB $db Database handler
* @param object $object Object askpricesupplier
* @param AskPriceSupplier $object Object askpricesupplier
* @param string $modele Force model to use ('' to not force)
* @param Translate $outputlangs Object langs to use for output
* @param int $hidedetails Hide details of lines

View File

@ -45,7 +45,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@ -153,7 +153,7 @@ abstract class ModeleNumRefCommandes
* Create a document onto disk accordign to template module.
*
* @param DoliDB $db Database handler
* @param Object $object Object order
* @param Commande $object Object order
* @param string $modele Force le modele a utiliser ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines

View File

@ -44,7 +44,7 @@ abstract class ModelePDFContract extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@ -148,7 +148,7 @@ class ModelNumRefContracts
* Create a contract document on disk using template defined into CONTRACT_ADDON_PDF
*
* @param DoliDB $db objet base de donnee
* @param Object $object Object contract
* @param Contrat $object Object contract
* @param string $modele force le modele a utiliser ('' par defaut)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines

View File

@ -40,7 +40,7 @@ abstract class ModeleDon extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)

View File

@ -43,7 +43,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@ -146,7 +146,7 @@ abstract class ModelNumRefExpedition
* Cree un bon d'expedition sur disque
*
* @param DoliDB $db Objet base de donnee
* @param Object $object Object expedition
* @param Expedition $object Object expedition
* @param string $modele Force le modele a utiliser ('' to not force)
* @param Translate $outputlangs Objet lang a utiliser pour traduction
* @return int <=0 if KO, >0 if OK

View File

@ -508,7 +508,7 @@ class pdf_standard extends ModeleExpenseReport
*/
// Filligrane brouillon
if ($object->fk_c_expensereport_statuts==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT))
if ($object->fk_statut==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT))
{
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_FREE_TEXT);
}
@ -640,7 +640,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outpulangs),0,'L');
}
if ($object->fk_c_expensereport_statuts==99)
if ($object->fk_statut==99)
{
if ($object->fk_user_refuse > 0)
{
@ -656,7 +656,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outpulangs),0,'L');
}
}
else if($object->fk_c_expensereport_statuts==4)
else if($object->fk_statut==4)
{
if ($object->fk_user_cancel > 0)
{
@ -686,7 +686,7 @@ class pdf_standard extends ModeleExpenseReport
}
}
if($object->fk_c_expensereport_statuts==6)
if($object->fk_statut==6)
{
if ($object->fk_user_paid > 0)
{

View File

@ -30,7 +30,7 @@ class ModeleExpenseReport extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@ -52,7 +52,7 @@ class ModeleExpenseReport extends CommonDocGenerator
* expensereport_pdf_create
*
* @param DoliDB $db Database handler
* @param Object $object Object order
* @param ExpenseReport $object Object order
* @param string $message Message
* @param string $modele Force le modele a utiliser ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction

View File

@ -43,7 +43,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
* Load into memory list of available export format
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates (same content than array this->driverlabel)
*/
function liste_modeles($db,$maxfilenamelength=0)

View File

@ -43,7 +43,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@ -148,7 +148,7 @@ abstract class ModeleNumRefFactures
* Create a document onto disk according to template module.
*
* @param DoliDB $db Database handler
* @param Object $object Object invoice
* @param Facture $object Object invoice
* @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
@ -21,11 +21,11 @@
*/
/**
* \defgroup askpricesupplier Module de demandes de prix fournisseurs
* \brief Module pour gerer la tenue des demandes fournisseurs
* \defgroup askpricesupplier Module to request supplier price proposals
* \brief Module to request supplier price proposals
* \file htdocs/core/modules/modAskPriceSupplier.class.php
* \ingroup askpricesupplier
* \brief Fichier de description et activation du module AskPriceSupplier
* \brief File to describe and activate module AskPriceSupplier
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
@ -110,7 +110,6 @@ class modAskPriceSupplier extends DolibarrModules
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'creer';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Validate supplier proposals'; // libelle de la permission

View File

@ -151,8 +151,9 @@ class modCommande extends DolibarrModules
$this->rights[$r][1] = 'Annuler les commandes clients';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'annuler';
$this->rights[$r][4] = 'order_advance';
$this->rights[$r][5] = 'annuler';
$r++;
$this->rights[$r][0] = 89;
$this->rights[$r][1] = 'Supprimer les commandes clients';

View File

@ -41,7 +41,7 @@ class modContrat extends DolibarrModules
*/
function __construct($db)
{
global $conf;
global $conf, $langs;
$this->db = $db;
$this->numero = 54;
@ -118,10 +118,12 @@ class modContrat extends DolibarrModules
// Exports
//--------
$langs->load("contracts");
$r=1;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='ContractAndServices'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_label[$r]=$langs->trans('ContractsAndLine'); // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='contract';
$this->export_permission[$r]=array(array("contrat","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode',

View File

@ -84,7 +84,7 @@ class modExpenseReport extends DolibarrModules
// Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->conflictwith = array("modDeplacement");
// $this->conflictwith = array("modDeplacement"); // Deactivate for access on old information
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(4,3); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,7); // Minimum version of Dolibarr required by module
@ -270,7 +270,7 @@ class modExpenseReport extends DolibarrModules
'titre'=>'ListToApprove',
'mainmenu'=>'hrm',
'leftmenu'=>'expensereport_detaillist_approve',
'url'=>'/expensereport/list.php?search_state=2',
'url'=>'/expensereport/list.php?search_status=2',
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
'enabled'=>'$conf->expensereport->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.

View File

@ -235,10 +235,10 @@ class modFacture extends DolibarrModules
$this->export_label[$r]='CustomersInvoicesAndPayments'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='bill';
$this->export_permission[$r]=array(array("facture","facture","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user');
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','p.fk_bank'=>'IdTransaction');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number','p.fk_bank'=>'Number');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number','p.fk_bank'=>'Number');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment','p.fk_bank'=>'payment','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user');
$this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture'";

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
@ -177,6 +177,14 @@ class modFournisseur extends DolibarrModules
$this->rights[$r][4] = 'commande';
$this->rights[$r][5] = 'receptionner';
$r++;
$this->rights[$r][0] = 1189;
$this->rights[$r][1] = 'Check/Uncheck a supplier order reception';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'commande_advance';
$this->rights[$r][5] = 'check';
$r++;
$this->rights[$r][0] = 1188;
$this->rights[$r][1] = 'Supprimer une commande fournisseur';
@ -251,11 +259,11 @@ class modFournisseur extends DolibarrModules
$this->export_icon[$r]='bill';
$this->export_permission[$r]=array(array("fournisseur","facture","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Number','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Number','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product');
$this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
// Add extra fields object
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
@ -288,13 +296,48 @@ class modFournisseur extends DolibarrModules
$this->export_entities_array[$r][$fieldname]='invoice';
}
}
// End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT ';
// End add extra fields
// Add extra fields line
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extraline.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='invoice_line';
}
}
// End add extra fields line
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')';
@ -309,7 +352,7 @@ class modFournisseur extends DolibarrModules
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment');
$this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
// Add extra fields object
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
@ -342,7 +385,7 @@ class modFournisseur extends DolibarrModules
$this->export_entities_array[$r][$fieldname]='invoice';
}
}
// End add axtra fields
// End add extra fields object
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
@ -361,10 +404,10 @@ class modFournisseur extends DolibarrModules
$this->export_icon[$r]='order';
$this->export_permission[$r]=array(array("fournisseur","commande","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
$this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Number','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"order",'f.ref'=>"order",'f.ref_supplier'=>"order",'f.date_creation'=>"order",'f.date_commande'=>"order",'f.total_ht'=>"order",'f.total_ttc'=>"order",'f.tva'=>"order",'f.fk_statut'=>'order','f.note_public'=>"order",'f.note_private'=>"order",'fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product');
$this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
// Add extra fields object
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
@ -397,13 +440,48 @@ class modFournisseur extends DolibarrModules
$this->export_entities_array[$r][$fieldname]='order';
}
}
// End add axtra fields
// End add extra fields object
// Add extra fields line
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extraline.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='order_line';
}
}
// End add extra fields line
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')';

View File

@ -65,7 +65,7 @@ if (empty($reshook) && ! empty($extrafields->attribute_label))
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
print '</tr></table>';
print '<td colspan="5">';
print '<td colspan="'.$cols.'">';
// Convert date into timestamp format
if (in_array($extrafields->attribute_type[$key], array('date','datetime'))) {

View File

@ -31,7 +31,7 @@
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal', 'askpricesupplier','commande'))) $usemargins=1;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','askpricesupplier','commande'))) $usemargins=1;
global $forceall, $senderissupplier, $inputalsopricewithtax;
if (empty($dateSelector)) $dateSelector=0;
@ -42,8 +42,8 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
// Define colspan for button Add
$colspan = 3; // Col total ht + col edit + col delete
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
//print $object->element;
?>
<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->
@ -161,12 +161,12 @@ else {
if (empty($senderissupplier))
{
$form->select_produits('', 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id);
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id);
}
else
{
$ajaxoptions=array(
'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tag will be edited with which ajax json response key
'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tags that will be edited with which ajax json response key
'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error'
);
@ -204,23 +204,16 @@ else {
<?php } ?>
<td align="right"><?php
if (GETPOST('prod_entry_mode') != 'predef')
{
if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">0';
else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer);
}
if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">0';
else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer);
?>
</td>
<td align="right">
<?php if (GETPOST('prod_entry_mode') != 'predef') { ?>
<input type="text" size="5" name="price_ht" id="price_ht" class="flat" value="<?php echo (isset($_POST["price_ht"])?$_POST["price_ht"]:''); ?>">
<?php } ?>
</td>
<?php if (! empty($inputalsopricewithtax)) { ?>
<td align="right">
<?php if ($object->element == 'askpricesupplier' || GETPOST('prod_entry_mode') != 'predef') { ?>
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?$_POST["price_ttc"]:''); ?>">
<?php } ?>
</td>
<?php } ?>
<td align="right"><input type="text" size="2" name="qty" id="qty" class="flat" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>">
@ -301,13 +294,13 @@ else {
</tr>
<?php
if (! empty($conf->service->enabled) && $dateSelector && GETPOST('type') != '0')
if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
{
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
else $colspan = 9;
if($this->situation_cycle_ref) $colspan++;
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
if (in_array($object->element,array('propal','askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
if (! empty($usemargins))
{
@ -555,6 +548,11 @@ jQuery(document).ready(function() {
if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus();
if (jQuery('#idprodfournprice').val() > 0) jQuery('#dp_desc').focus();
});
<?php if (GETPOST('prod_entry_mode') == 'predef') { // When we submit with a predef product and it fails we must start with predef ?>
setforpredef();
<?php } ?>
});
/* Function to set fields from choice */
@ -582,10 +580,8 @@ function setforpredef() {
jQuery("#select_type").val(-1);
jQuery("#prod_entry_mode_free").attr('checked',false);
jQuery("#prod_entry_mode_predef").attr('checked',true);
<?php if ($object->element != 'askpricesupplier') { ?>
jQuery("#price_ht").hide();
jQuery("#title_up_ht").hide();
<?php } ?>
jQuery("#price_ht").hide();
jQuery("#title_up_ht").hide();
jQuery("#price_ttc").hide(); // May no exists
jQuery("#tva_tx").hide();
jQuery("#buying_price").show();

View File

@ -52,7 +52,7 @@ if (empty($usemargins)) $usemargins=0;
<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
<td align="center"><?php $coldisplay++; ?><?php echo ($i+1); ?></td>
<?php } ?>
<td><?php $coldisplay++; ?><div id="row-<?php echo $line->id; ?>"></div>
<td><?php $coldisplay++; ?><div id="line_<?php echo $line->id; ?>"></div>
<?php if (($line->info_bits & 2) == 2) { ?>
<a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid; ?>">
<?php
@ -183,7 +183,7 @@ if (empty($usemargins)) $usemargins=0;
<td align="center"><?php $coldisplay++; ?>
<?php if (($line->info_bits & 2) == 2) { ?>
<?php } else { ?>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#'.$line->id; ?>">
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#line_'.$line->id; ?>">
<?php echo img_edit(); ?>
</a>
<?php } ?>

View File

@ -147,7 +147,7 @@ class ExpeditionLineBatch extends CommonObject
/**
* Delete batch record attach to a shipment
*
* @param object $db Database object
* @param DoliDB $db Database object
* @param int $id_expedition rowid of shipment
* @return int -1 if KO, 1 if OK
*/
@ -172,7 +172,7 @@ class ExpeditionLineBatch extends CommonObject
/**
* Retrieve all batch number details link to a shipment line
*
* @param object $db Database object
* @param DoliDB $db Database object
* @param int $id_line_expdet id of shipment line
* @return variant -1 if KO, array of ExpeditionLineBatch if OK
*/

View File

@ -402,7 +402,7 @@ if ($id > 0 || ! empty($ref))
print '<td align="center">'.$langs->trans("KeepToShip").'</td>';
if (! empty($conf->stock->enabled))
{
print '<td align="center">'.$langs->trans("Stock").'</td>';
print '<td align="center">'.$langs->trans("RealStock").'</td>';
}
else
{

View File

View File

@ -109,7 +109,7 @@ if ($action == 'add' && $user->rights->expensereport->creer)
$object->date_debut = $date_start;
$object->date_fin = $date_end;
$object->fk_c_expensereport_statuts = 1;
$object->fk_statut = 1;
$object->fk_c_paiement = GETPOST('fk_c_paiement','int');
$object->fk_user_validator = GETPOST('fk_user_validator','int');
$object->note_public = GETPOST('note_public');
@ -151,7 +151,7 @@ if ($action == 'update' && $user->rights->expensereport->creer)
$object->date_debut = $date_start;
$object->date_fin = $date_end;
if($object->fk_c_expensereport_statuts < 3)
if($object->fk_statut < 3)
{
$object->fk_user_validator = GETPOST('fk_user_validator','int');
}
@ -733,12 +733,12 @@ if ($action == "confirm_paid" && GETPOST('confirm')=="yes" && $id > 0 && $user->
$insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
if ($insertid > 0):
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport d";
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport as d";
$sql.= " SET integration_compta = 1, fk_bank_account = $idAccount";
$sql.= " WHERE rowid = $idTrip";
$resql=$db->query($sql);
if($result):
Header("Location: ".$_SEVER["PHP_SELF"]."?id=".$id);
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
else:
dol_print_error($db);
@ -1197,7 +1197,7 @@ else
$head = expensereport_prepare_head($object);
if ($action == 'edit' && ($object->fk_c_expensereport_statuts < 3 || $object->fk_c_expensereport_statuts==99))
if ($action == 'edit' && ($object->fk_statut < 3 || $object->fk_statut==99))
{
print "<form name='update' action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -1205,7 +1205,7 @@ else
dol_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip');
if($object->fk_c_expensereport_statuts==99)
if($object->fk_statut==99)
{
print '<input type="hidden" name="action" value="updateFromRefuse">';
}
@ -1246,7 +1246,7 @@ else
print '</tr>';
}
if($object->fk_c_expensereport_statuts<3)
if($object->fk_statut<3)
{
print '<tr>';
print '<td>'.$langs->trans("VALIDATOR").'</td>'; // Approbator
@ -1275,7 +1275,7 @@ else
$userfee->fetch($object->fk_user_author);
print $userfee->getNomUrl(1);
print '</td></tr>';
if ($object->fk_c_expensereport_statuts==6)
if ($object->fk_statut==6)
{
print '<tr>';
print '<td>'.$langs->trans("AUTHORPAIEMENT").'</td>';
@ -1437,7 +1437,7 @@ else
print '<td>'.$langs->trans("DATE_SAVE").'</td>';
print '<td>'.dol_print_date($object->date_create,'dayhour').'</td></tr>';
print '</tr>';
if($object->fk_c_expensereport_statuts==6)
if($object->fk_statut==6)
{
print '<tr>';
print '<td>'.$langs->trans("AUTHORPAIEMENT").'</td>';
@ -1452,7 +1452,7 @@ else
print '</tr>';
}
if($object->fk_c_expensereport_statuts<3) // informed
if($object->fk_statut<3) // informed
{
print '<tr>';
print '<td>'.$langs->trans("VALIDATOR").'</td>';
@ -1465,7 +1465,7 @@ else
}
print '</td></tr>';
}
elseif($object->fk_c_expensereport_statuts==4)
elseif($object->fk_statut==4)
{
print '<tr>';
print '<td>'.$langs->trans("CANCEL_USER").'</span></td>';
@ -1504,7 +1504,7 @@ else
print '</tr>';
}
if($object->fk_c_expensereport_statuts==99 || !empty($object->detail_refuse))
if($object->fk_statut==99 || !empty($object->detail_refuse))
{
print '<tr>';
print '<td>'.$langs->trans("REFUSEUR").'</td>';
@ -1529,9 +1529,9 @@ else
$sql.= ' fde.fk_c_tva as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
$sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
$sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det fde';
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees ctf ON fde.fk_c_type_fees=ctf.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet pjt ON fde.fk_projet=pjt.rowid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid';
$sql.= ' WHERE fde.fk_expensereport = '.$id;
$resql = $db->query($sql);
@ -1566,7 +1566,7 @@ else
print '<td style="text-align:right;">'.$langs->trans('AmountTTC').'</td>';
}
// Ajout des boutons de modification/suppression
if ($object->fk_c_expensereport_statuts < 2 || $object->fk_c_expensereport_statuts==99)
if ($object->fk_statut < 2 || $object->fk_statut==99)
{
print '<td style="text-align:right;"></td>';
}
@ -1609,7 +1609,7 @@ else
}
// Ajout des boutons de modification/suppression
if($object->fk_c_expensereport_statuts<2 OR $object->fk_c_expensereport_statuts==99)
if($object->fk_statut<2 OR $object->fk_statut==99)
{
print '<td style="text-align:right;" class="nowrap">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;rowid='.$objp->rowid.'#'.$objp->rowid.'">';
@ -1689,7 +1689,7 @@ else
//print '</div>';
// Add a line
if (($object->fk_c_expensereport_statuts==0 || $object->fk_c_expensereport_statuts==99) && $action != 'editline')
if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline')
{
print_fiche_titre($langs->trans("AddLine"),'','');
@ -1712,17 +1712,17 @@ else
print '<tr>';
// Sélection date
// Select date
print '<td style="text-align:center;">';
$form->select_date($date?$date:-1,'date');
print '</td>';
// Sélection projet
// Select project
print '<td>';
$formproject->select_projects(-1, GETPOST('fk_projet'), 'fk_projet', 0, 0, 1, 1);
print '</td>';
// Sélection type
// Select type
print '<td>';
select_type_fees_id(GETPOST('fk_c_type_fees'),'fk_c_type_fees',1);
print '</td>';
@ -1732,7 +1732,7 @@ else
print '<textarea class="flat_ndf centpercent" name="comments">'.GETPOST('comments').'</textarea>';
print '</td>';
// Sélection TVA
// Select VAT
print '<td style="text-align:right;">';
$defaultvat=-1;
if (! empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none';
@ -1747,7 +1747,7 @@ else
print '<input type="text" size="6" name="value_unit" value="'.GETPOST('value_unit').'">';
print '</td>';
// Quantité
// Quantity
print '<td style="text-align:right;">';
print '<input type="text" size="4" name="qty" value="'.GETPOST('qty').'">';
print '</td>';
@ -1799,7 +1799,7 @@ if ($action != 'create' && $action != 'edit')
* ET fk_user_author == user courant
* Afficher : "Enregistrer" / "Modifier" / "Supprimer"
*/
if ($user->rights->expensereport->creer && $object->fk_c_expensereport_statuts==0)
if ($user->rights->expensereport->creer && $object->fk_statut==0)
{
if ($object->fk_user_author == $user->id)
{
@ -1825,7 +1825,7 @@ if ($action != 'create' && $action != 'edit')
* ET fk_user_author == user courant
* Afficher : "Enregistrer" / "Modifier" / "Supprimer"
*/
if($user->rights->expensereport->creer && $object->fk_c_expensereport_statuts==99)
if($user->rights->expensereport->creer && $object->fk_statut==99)
{
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
@ -1845,7 +1845,7 @@ if ($action != 'create' && $action != 'edit')
}
}
if ($user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts==5)
if ($user->rights->expensereport->to_paid && $object->fk_statut==5)
{
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
@ -1859,7 +1859,7 @@ if ($action != 'create' && $action != 'edit')
* ET fk_user_validator == user courant
* Afficher : "Valider" / "Refuser" / "Supprimer"
*/
if ($object->fk_c_expensereport_statuts == 2)
if ($object->fk_statut == 2)
{
if ($object->fk_user_author == $user->id)
{
@ -1868,7 +1868,7 @@ if ($action != 'create' && $action != 'edit')
}
}
if ($user->rights->expensereport->approve && $object->fk_c_expensereport_statuts == 2)
if ($user->rights->expensereport->approve && $object->fk_statut == 2)
{
//if($object->fk_user_validator==$user->id)
//{
@ -1895,7 +1895,7 @@ if ($action != 'create' && $action != 'edit')
* ET user à droit de "to_paid"
* Afficher : "Annuler" / "Payer" / "Supprimer"
*/
if ($user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts == 5)
if ($user->rights->expensereport->to_paid && $object->fk_statut == 5)
{
// Payer
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$id.'">'.$langs->trans('TO_PAID').'</a>';
@ -1918,7 +1918,7 @@ if ($action != 'create' && $action != 'edit')
* ET user à droit "to_paid"
* Afficher : "Annuler"
*/
if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts==6)
if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6)
{
// Annuler
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>';
@ -1933,7 +1933,7 @@ if ($action != 'create' && $action != 'edit')
* ET user à droit "supprimer"
* Afficher : "Supprimer"
*/
if ($user->rights->expensereport->supprimer && $object->fk_c_expensereport_statuts==4)
if ($user->rights->expensereport->supprimer && $object->fk_statut==4)
{
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
@ -1959,7 +1959,7 @@ print '<div style="width:50%">';
/*
* Documents generes
*/
if($user->rights->expensereport->export && $object->fk_c_expensereport_statuts>0 && $action != 'edit')
if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'edit')
{
$filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);

View File

@ -1,5 +1,22 @@
<?php
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
/**
* Class to manage Trips and Expenses
@ -26,7 +43,7 @@ class ExpenseReport extends CommonObject
var $fk_user_validator;
var $status;
var $fk_c_expensereport_statuts; // -- 1=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied
var $fk_statut; // -- 1=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied
var $fk_c_paiement;
var $user_author_infos;
@ -133,7 +150,7 @@ class ExpenseReport extends CommonObject
$sql.= ",date_create";
$sql.= ",fk_user_author";
$sql.= ",fk_user_validator";
$sql.= ",fk_c_expensereport_statuts";
$sql.= ",fk_statut";
$sql.= ",fk_c_paiement";
$sql.= ",note_public";
$sql.= ",note_private";
@ -147,7 +164,7 @@ class ExpenseReport extends CommonObject
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ", ".($user->id > 0 ? $user->id:"null");
$sql.= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null");
$sql.= ", ".($this->fk_c_expensereport_statuts > 1 ? $this->fk_c_expensereport_statuts:0);
$sql.= ", ".($this->fk_statut > 1 ? $this->fk_statut:0);
$sql.= ", ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null");
$sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
@ -231,7 +248,7 @@ class ExpenseReport extends CommonObject
$sql.= " , fk_user_validator = ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null");
$sql.= " , fk_user_valid = ".($this->fk_user_valid > 0 ? $this->fk_user_valid:"null");
$sql.= " , fk_user_paid = ".($this->fk_user_paid > 0 ? $this->fk_user_paid:"null");
$sql.= " , fk_c_expensereport_statuts = ".($this->fk_c_expensereport_statuts >= 0 ? $this->fk_c_expensereport_statuts:'0');
$sql.= " , fk_statut = ".($this->fk_statut >= 0 ? $this->fk_statut:'0');
$sql.= " , fk_c_paiement = ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null");
$sql.= " , note_public = ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"''");
$sql.= " , note_private = ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"''");
@ -267,10 +284,10 @@ class ExpenseReport extends CommonObject
$sql.= " d.date_refuse, d.date_cancel,"; // ACTIONS
$sql.= " d.total_ht, d.total_ttc, d.total_tva,"; // TOTAUX (int)
$sql.= " d.date_debut, d.date_fin, d.date_create, d.date_valid, d.date_approve, d.date_paiement,"; // DATES (datetime)
$sql.= " d.fk_user_author, d.fk_user_validator, d.fk_c_expensereport_statuts as status, d.fk_c_paiement,";
$sql.= " d.fk_user_author, d.fk_user_validator, d.fk_statut as status, d.fk_c_paiement,";
$sql.= " d.fk_user_valid, d.fk_user_approve, d.fk_user_paid,";
$sql.= " dp.libelle as libelle_paiement, dp.code as code_paiement"; // INNER JOIN paiement
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement dp ON d.fk_c_paiement = dp.id";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id";
if ($ref) $sql.= " WHERE d.ref = '".$this->db->escape($ref)."'";
else $sql.= " WHERE d.rowid = ".$id;
$sql.= $restrict;
@ -318,18 +335,18 @@ class ExpenseReport extends CommonObject
if ($this->fk_user_validator > 0) $user_approver->fetch($this->fk_user_validator);
$this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname);
$this->fk_c_expensereport_statuts = $obj->status;
$this->fk_statut = $obj->status;
$this->status = $obj->status;
$this->fk_c_paiement = $obj->fk_c_paiement;
if ($this->fk_c_expensereport_statuts==5 || $this->fk_c_expensereport_statuts==6)
if ($this->fk_statut==5 || $this->fk_statut==6)
{
$user_valid = new User($this->db);
if ($this->fk_user_valid > 0) $user_valid->fetch($this->fk_user_valid);
$this->user_valid_infos = dolGetFirstLastname($user_valid->firstname, $user_valid->lastname);
}
if ($this->fk_c_expensereport_statuts==6)
if ($this->fk_statut==6)
{
$user_paid = new User($this->db);
if ($this->fk_user_paid > 0) $user_paid->fetch($this->fk_user_paid);
@ -497,7 +514,7 @@ class ExpenseReport extends CommonObject
$this->date_approve = $now;
$this->status = 5;
$this->fk_c_expensereport_statuts = 5;
$this->fk_statut = 5;
$this->fk_user_author = $user->id;
$this->fk_user_valid = $user->id;
@ -567,7 +584,7 @@ class ExpenseReport extends CommonObject
$objp = $db->fetch_object($result);
$sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_c_expensereport_statuts";
$sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_statut";
$sql2.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql2.= " WHERE d.rowid = '".$objp->fk_expensereport."'";
@ -576,7 +593,7 @@ class ExpenseReport extends CommonObject
$objp->fk_user_author = $obj->fk_user_author;
$objp->ref = $obj->ref;
$objp->fk_c_expensereport_status = $obj->fk_c_expensereport_statuts;
$objp->fk_c_expensereport_status = $obj->fk_statut;
$objp->rowid = $obj->rowid;
$total_HT = $total_HT + $objp->total_ht;
@ -707,8 +724,8 @@ class ExpenseReport extends CommonObject
$sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,';
$sql.= ' p.ref as ref_projet, p.title as title_projet';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de';
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees ctf ON de.fk_c_type_fees = ctf.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet p ON de.fk_projet = p.rowid';
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON de.fk_projet = p.rowid';
$sql.= ' WHERE de.'.$this->fk_element.' = '.$this->id;
dol_syslog('ExpenseReport::fetch_lines sql='.$sql, LOG_DEBUG);
@ -831,10 +848,10 @@ class ExpenseReport extends CommonObject
$this->ref = strtoupper($user->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d');
}
if ($this->fk_c_expensereport_statuts != 2)
if ($this->fk_statut != 2)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 2, fk_user_valid = ".$user->id.",";
$sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$user->id.",";
$sql.= " ref_number_int = ".$ref_number_int;
$sql.= ' WHERE rowid = '.$this->id;
@ -877,10 +894,10 @@ class ExpenseReport extends CommonObject
$this->date_debut = $this->db->jdate($objp->date_debut);
if ($this->fk_c_expensereport_statuts != 2)
if ($this->fk_statut != 2)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_c_expensereport_statuts = 2";
$sql.= " SET fk_statut = 2";
$sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::set_save_from_refuse sql=".$sql, LOG_DEBUG);
@ -913,10 +930,10 @@ class ExpenseReport extends CommonObject
// date approval
$this->date_approve = $this->db->idate($now);
if ($this->fk_c_expensereport_statuts != 5)
if ($this->fk_statut != 5)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 5, fk_user_approve = ".$user->id.",";
$sql.= " SET ref = '".$this->ref."', fk_statut = 5, fk_user_approve = ".$user->id.",";
$sql.= " date_approve='".$this->date_approve."'";
$sql.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql))
@ -946,17 +963,17 @@ class ExpenseReport extends CommonObject
$now = dol_now();
// date de refus
if ($this->fk_c_expensereport_statuts != 99)
if ($this->fk_statut != 99)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 99, fk_user_refuse = ".$user->id.",";
$sql.= " SET ref = '".$this->ref."', fk_statut = 99, fk_user_refuse = ".$user->id.",";
$sql.= " date_refuse='".$this->db->idate($now)."',";
$sql.= " detail_refuse='".$this->db->escape($details)."'";
$sql.= " fk_user_approve=NULL,";
$sql.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql))
{
$this->fk_c_expensereport_statuts = 99;
$this->fk_statut = 99;
$this->fk_user_refuse = $user->id;
$this->detail_refuse = $details;
$this->date_refuse = $now;
@ -985,10 +1002,10 @@ class ExpenseReport extends CommonObject
$now= dol_now();
$this->date_paiement = $this->db->idate($now);
if ($this->fk_c_expensereport_statuts != 6)
if ($this->fk_statut != 6)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_c_expensereport_statuts = 6, fk_user_paid = ".$user->id.",";
$sql.= " SET fk_statut = 6, fk_user_paid = ".$user->id.",";
$sql.= " date_paiement='".$this->db->idate($this->date_paiement)."'";
$sql.= ' WHERE rowid = '.$this->id;
@ -1020,7 +1037,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_c_deplacement_statuts != 5)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_c_expensereport_statuts = 5";
$sql.= " SET fk_statut = 5";
$sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG);
@ -1048,10 +1065,10 @@ class ExpenseReport extends CommonObject
function set_cancel($user,$detail)
{
$this->date_cancel = $this->db->idate(gmmktime());
if ($this->fk_c_expensereport_statuts != 4)
if ($this->fk_statut != 4)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_c_expensereport_statuts = 4, fk_user_cancel = ".$user->id;
$sql.= " SET fk_statut = 4, fk_user_cancel = ".$user->id;
$sql.= ", date_cancel='".$this->date_cancel."'";
$sql.= " ,detail_cancel='".$this->db->escape($detail)."'";
$sql.= ' WHERE rowid = '.$this->id;
@ -1180,13 +1197,13 @@ class ExpenseReport extends CommonObject
function updateline($rowid, $type_fees_id, $projet_id, $c_tva, $comments, $qty, $value_unit, $date, $expensereport_id)
{
if ($this->fk_c_expensereport_statuts==0 || $this->fk_c_expensereport_statuts==99)
if ($this->fk_statut==0 || $this->fk_statut==99)
{
$this->db->begin();
// Select du taux de tva par rapport au code
$sql = "SELECT t.taux as taux_tva";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva t";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t";
$sql.= " WHERE t.rowid = ".$c_tva;
$result = $this->db->query($sql);
$objp_tva = $this->db->fetch_object($result);
@ -1222,7 +1239,7 @@ class ExpenseReport extends CommonObject
// Select des infos sur le type fees
$sql = "SELECT c.code as code_type_fees, c.label as libelle_type_fees";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees c";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees as c";
$sql.= " WHERE c.id = ".$type_fees_id;
$result = $this->db->query($sql);
$objp_fees = $this->db->fetch_object($result);
@ -1231,7 +1248,7 @@ class ExpenseReport extends CommonObject
// Select des informations du projet
$sql = "SELECT p.ref as ref_projet, p.title as title_projet";
$sql.= " FROM ".MAIN_DB_PREFIX."projet p";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " WHERE p.rowid = ".$projet_id;
$result = $this->db->query($sql);
$objp_projet = $this->db->fetch_object($result);
@ -1403,6 +1420,39 @@ class ExpenseReport extends CommonObject
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
/**
* List of types
*
* @param int $active Active or not
* @return array
*/
function listOfTypes($active=1)
{
global $langs;
$ret=array();
$sql = "SELECT id, code, label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees";
$sql.= " WHERE active = ".$active;
dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG);
$result = $this->db->query($sql);
if ( $result )
{
$num = $this->db->num_rows($result);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
$ret[$obj->code]=(($langs->trans($obj->code)!=$obj->code)?$langs->trans($obj->code):$obj->label);
$i++;
}
}
else
{
dol_print_error($this->db);
}
return $ret;
}
}
@ -1460,9 +1510,9 @@ class ExpenseReportLine
$sql.= ' fde.fk_c_tva as tva_taux, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
$sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
$sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det fde';
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees ctf ON fde.fk_c_type_fees=ctf.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet pjt ON fde.fk_projet=pjt.rowid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid';
$sql.= ' WHERE fde.rowid = '.$rowid;
$result = $this->db->query($sql);
@ -1643,7 +1693,7 @@ class ExpenseReportLine
* @param int $useempty 1=Add empty line
* @return string HTML select with sattus
*/
function select_expensereport_statut($selected='',$htmlname='fk_c_expensereport_statuts',$useempty=1)
function select_expensereport_statut($selected='',$htmlname='fk_statut',$useempty=1)
{
global $db;
@ -1708,4 +1758,4 @@ function select_type_fees_id($selected='',$htmlname='type',$showempty=0)
}
}
print '</select>';
}
}

View File

@ -19,11 +19,11 @@
/**
* \file htdocs/expensereport/class/expensereportstats.class.php
* \ingroup factures
* \ingroup ExpenseReport
* \brief Fichier de la classe de gestion des stats des expensereport et notes de frais
*/
include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
dol_include_once('/expensereport/class/expensereport.class.php');
include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
/**
* Classe permettant la gestion des stats des expensereports et notes de frais
@ -59,7 +59,7 @@ class ExpenseReportStats extends Stats
$this->from = MAIN_DB_PREFIX.$object->table_element;
$this->field='total_ht';
$this->where = " fk_c_expensereport_statuts > 0 and date_valid > '2000-01-01'";
$this->where = " fk_statut > 0 and date_valid > '2000-01-01'";
//$this->where.= " AND entity = ".$conf->entity;
if ($this->socid)
{

View File

View File

@ -21,8 +21,8 @@
*/
require '../main.inc.php';
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
dol_include_once("/expensereport/class/expensereport.class.php");
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
$langs->load("users");
$langs->load("trips");

View File

View File

@ -25,8 +25,8 @@
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
dol_include_once("/expensereport/class/expensereport.class.php");
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
$langs->load("companies");
$langs->load("users");
@ -111,8 +111,7 @@ print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("Statistics").'</td>';
print "</tr>\n";
//$listoftype=$tripandexpense_static->listOfTypes();
$listoftype=$label;
$listoftype=$tripandexpense_static->listOfTypes();
foreach ($listoftype as $code => $label)
{
$dataseries[]=array('label'=>$label,'data'=>(isset($somme[$code])?(int) $somme[$code]:0));
@ -143,7 +142,7 @@ $max=10;
$langs->load("boxes");
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_c_expensereport_statuts as fk_status";
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as fk_status";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE u.rowid = d.fk_user_author";
@ -187,8 +186,8 @@ if ($result)
print '<tr '.$bc[$var].'>';
print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
print '<td>'.$userstatic->getNomUrl(1).'</td>';
print '<td align="right">'.$obj->total_ht.'</td>';
print '<td align="right">'.$obj->total_ttc.'</td>';
print '<td align="right">'.price($obj->total_ht).'</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>';
print '<td align="right">'.dol_print_date($db->jdate($obj->dm),'day').'</td>';
print '<td align="right">';
//print $obj->libelle;

View File

@ -21,12 +21,13 @@
/**
* \file htdocs/expensereport/index.php
* \brief Page liste des expensereports
* \brief list of expense reports
*/
require "../main.inc.php";
dol_include_once("/expensereport/class/expensereport.class.php");
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
$langs->load("companies");
$langs->load("users");
@ -39,7 +40,7 @@ $result = restrictedArea($user, 'expensereport','','');
$search_ref = GETPOST('search_ref');
$search_user = GETPOST('search_user','int');
$search_state = GETPOST('search_state','int');
$search_status = GETPOST('search_status','int');
$month_start = GETPOST("month_start","int");
$year_start = GETPOST("year_start","int");
$month_end = GETPOST("month_end","int");
@ -49,7 +50,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
{
$search_ref="";
$search_user="";
$search_state="";
$search_status="";
$month_start="";
$year_start="";
$month_end="";
@ -69,13 +70,12 @@ llxHeader('', $langs->trans("ListOfTrips"));
$max_year = 5;
$min_year = 5;
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
$page = $_GET["page"];
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
$page = GETPOST("page");
if (!$sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield="d.date_debut";
if ($page == -1) {
$page = 0 ;
}
@ -85,79 +85,53 @@ $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc, d.fk_c_expensereport_statuts as status,";
$sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
$sql.= " d.date_debut, d.date_fin,";
$sql.= " u.rowid as id_user, u.firstname, u.lastname";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport d\n";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user u ON d.fk_user_author = u.rowid\n";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid";
// WHERE
// Where
if(!empty($search_ref)){
$sql.= " WHERE d.ref LIKE '%".$db->escape($search_ref)."%'\n";
$sql.= " WHERE d.ref LIKE '%".$db->escape($search_ref)."%'";
}else{
$sql.= " WHERE 1 = 1\n";
$sql.= " WHERE 1 = 1";
}
// DATE START
if ($month_start > 0) {
if ($year_start > 0) {
if($month_end > 0) {
if($year_end > 0) {
$sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'";
$sql.= " AND date_format(d.date_fin, '%Y-%m') <= '$year_end-$month_end'";
} else {
$sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'";
$sql.= " AND date_format(d.date_fin, '%m') <= '$month_end'";
}
} else {
if($year_end > 0) {
$sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'";
$sql.= " AND date_format(d.date_fin, '%Y') <= '$year_end'";
} else {
$sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'";
}
}
} else {
$sql.= " AND date_format(d.date_debut, '%m') >= '$month_start'";
}
} else {
if ($year_start > 0) {
if($month_end > 0) {
if($year_end > 0) {
$sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
$sql.= " AND date_format(d.date_fin, '%Y-%m') <= '$year_end-$month_end'";
} else {
$sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
$sql.= " AND date_format(d.date_fin, '%m') <= '$month_end'";
}
} else {
if($year_end > 0) {
$sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
$sql.= " AND date_format(d.date_fin, '%Y') <= '$year_end'";
} else {
$sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
}
}
} else {
if($month_end > 0) {
if($year_end > 0) {
$sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
$sql.= " AND date_format(d.date_fin, '%Y-%m') <= '$year_end-$month_end'";
} else {
$sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
$sql.= " AND date_format(d.date_fin, '%m') <= '$month_end'";
}
} else {
if($year_end > 0) {
$sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
$sql.= " AND date_format(d.date_fin, '%Y') <= '$year_end'";
}
}
}
// Date Start
if ($month_start > 0)
{
if ($year_start > 0 && empty($day))
$sql.= " AND d.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,$month_start,false))."' AND '".$db->idate(dol_get_last_day($year_start,$month_start,false))."'";
else if ($year_start > 0 && ! empty($day))
$sql.= " AND d.date_debut BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_start, $day, $year_start))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_start, $day, $year_start))."'";
else
$sql.= " AND date_format(d.date_debut, '%m') = '".$month_start."'";
}
if (!empty($search_user) && $search_user > 0) $sql.= " AND d.fk_user_author = ".$search_user."\n";
if($search_state != '') $sql.= " AND d.fk_c_expensereport_statuts = '$search_state'\n";
else if ($year_start > 0)
{
$sql.= " AND d.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,1,false))."' AND '".$db->idate(dol_get_last_day($year_start,12,false))."'";
}
// Date Start
if ($month_end > 0)
{
if ($year_end > 0 && empty($day))
$sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,$month_end,false))."' AND '".$db->idate(dol_get_last_day($year_end,$month_end,false))."'";
else if ($year_end > 0 && ! empty($day))
$sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_end, $day, $year_end))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_end, $day, $year_end))."'";
else
$sql.= " AND date_format(d.date_fin, '%m') = '".$month_end."'";
}
else if ($year_end > 0)
{
$sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,1,false))."' AND '".$db->idate(dol_get_last_day($year_end,12,false))."'";
}
// User
if ($search_name)
{
$sql .= natural_search('u.lastname', $search_name);
}
// Status
if($search_status != '') $sql.= " AND d.fk_statut = '".$search_status."'";
// RESTRICT RIGHTS
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous))
@ -219,17 +193,13 @@ if ($resql)
print '<td class="liste_titre">&nbsp;</td>';
}
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
print "</td>";
print '<td class="liste_titre">&nbsp;</td>';
// Status
print '<td class="liste_titre" align="right">';
select_expensereport_statut($search_state,'search_state');
select_expensereport_statut($search_status,'search_status');
print '</td>';
print '<td class="liste_titre" align="right">';
@ -257,10 +227,6 @@ if ($resql)
print '<td align="center">'.($objp->date_debut > 0 ? dol_print_date($objp->date_debut, 'day') : '').'</td>';
print '<td align="center">'.($objp->date_fin > 0 ? dol_print_date($objp->date_fin, 'day') : '').'</td>';
print '<td align="left"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$objp->id_user.'">'.img_object($langs->trans("ShowUser"),"user").' '.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>';
/*print '<td align="right">'.price($objp->total_tva, '', $langs, 0, 'MT', 0, $conf->currency).'</td>';
print '<td align="right">'.price($objp->total_ht, '', $langs, 0, 'MT', 0, $conf->currency).'</td>';
print '<td align="right">'.price($objp->total_ttc, '', $langs, 0, 'MT', 0, $conf->currency).'</td>';
*/
print '<td align="right">'.price($objp->total_ht).'</td>';
print '<td align="right">'.price($objp->total_tva).'</td>';
print '<td align="right">'.price($objp->total_ttc).'</td>';
@ -281,11 +247,7 @@ if ($resql)
print '<tr class="liste_total">';
print '<td colspan="4">'.$langs->trans("Total").'</td>';
/*
print '<td style="text-align:right;">'.price($total_total_tva, '', $langs, 0, 'MT', 0, $conf->currency).'</td>';
print '<td style="text-align:right;">'.price($total_total_ht, '', $langs, 0, 'MT', 0, $conf->currency).'</td>';
print '<td style="text-align:right;">'.price($total_total_ttc, '', $langs, 0, 'MT', 0, $conf->currency).'</td>';
*/
print '<td style="text-align:right;">'.$total_total_ht.'</td>';
print '<td style="text-align:right;">'.$total_total_tva.'</td>';
print '<td style="text-align:right;">'.$total_total_ttc.'</td>';

View File

View File

@ -16,8 +16,8 @@
*/
require '../main.inc.php';
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
dol_include_once("/expensereport/class/expensereport.class.php");
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
$langs->load("companies");
$langs->load("users");
@ -49,12 +49,12 @@ if ($_GET["action"] == 'confirm_ndf_to_account' && $_GET["confirm"] == "yes"):
$insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
if ($insertid > 0):
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport d";
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport as d";
$sql.= " SET integration_compta = 1, fk_bank_account = $idAccount";
$sql.= " WHERE rowid = $idTrip";
$resql=$db->query($sql);
if($result):
Header("Location: synchro_compta.php?account=".$idAccount);
Header("Location: ".$_SERVER["PHP_SELF"]."?account=".$idAccount);
exit;
else:
dol_print_error($db);
@ -75,12 +75,12 @@ if ($_GET["action"] == 'confirm_account_to_ndf' && $_GET["confirm"] == "yes"):
$sql.= " WHERE label LIKE '%".$expensereport->ref."%'";
$resql=$db->query($sql);
if ($resql > 0):
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport d";
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport as d";
$sql.= " SET integration_compta = 0, fk_bank_account = 0";
$sql.= " WHERE rowid = $idTrip";
$resql=$db->query($sql);
if($result):
Header("Location: synchro_compta.php?account=".$idAccount);
Header("Location: ".$_SERVER["PHP_SELF"]."?account=".$idAccount);
exit;
else:
dol_print_error($db);
@ -110,13 +110,13 @@ dol_fiche_head('');
if ($_GET["action"] == 'ndfTOaccount'):
$idTrip = $_GET['idTrip'];
$ret=$html->form_confirm("synchro_compta.php?idTrip=".$idTrip."&account=".$idAccount,$langs->trans("ndfToAccount"),$langs->trans("ConfirmNdfToAccount"),"confirm_ndf_to_account","","",1);
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?idTrip=".$idTrip."&account=".$idAccount,$langs->trans("ndfToAccount"),$langs->trans("ConfirmNdfToAccount"),"confirm_ndf_to_account","","",1);
if ($ret == 'html') print '<br />';
endif;
if ($_GET["action"] == 'accountTOndf'):
$idTrip = $_GET['idTrip'];
$ret=$html->form_confirm("synchro_compta.php?idTrip=".$idTrip."&account=".$idAccount,$langs->trans("AccountToNdf"),$langs->trans("ConfirmAccountToNdf"),"confirm_account_to_ndf","","",1);
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?idTrip=".$idTrip."&account=".$idAccount,$langs->trans("AccountToNdf"),$langs->trans("ConfirmAccountToNdf"),"confirm_account_to_ndf","","",1);
if ($ret == 'html') print '<br />';
endif;
@ -136,11 +136,11 @@ else:
print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("ViewAccountSynch").'">';
print "</form>";
$sql = "SELECT d.fk_bank_account, d.ref, d.rowid, d.date_valid, d.fk_user_author, d.total_ttc, d.integration_compta, d.fk_c_expensereport_statuts";
$sql = "SELECT d.fk_bank_account, d.ref, d.rowid, d.date_valid, d.fk_user_author, d.total_ttc, d.integration_compta, d.fk_statut";
$sql.= " ,CONCAT(u.firstname,' ',u.lastname) as declarant_NDF";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport d";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user u ON d.fk_user_author = u.rowid";
$sql.= " WHERE d.fk_c_expensereport_statuts = 6";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid";
$sql.= " WHERE d.fk_statut = 6";
$sql.= " ORDER BY d.date_valid DESC";
$resql=$db->query($sql);
@ -200,7 +200,7 @@ else:
print "</table>";
else:
print '<div class="error">'.$langs->trans("AucuneTripToSynch").'</div>';
print '<div class="error">'.$langs->trans("NoTripToSync").'</div>';
endif;
$db->free($resql);

View File

@ -106,6 +106,8 @@ class CommandeFournisseur extends CommonOrder
*/
function __construct($db)
{
global $conf;
$this->db = $db;
$this->products = array();
$this->lines = array();
@ -114,7 +116,8 @@ class CommandeFournisseur extends CommonOrder
$this->statuts[0] = 'StatusOrderDraft';
$this->statuts[1] = 'StatusOrderValidated';
$this->statuts[2] = 'StatusOrderApproved';
$this->statuts[3] = 'StatusOrderOnProcess';
if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusOrderOnProcess';
else $this->statuts[3] = 'StatusOrderOnProcessWithValidation';
$this->statuts[4] = 'StatusOrderReceivedPartially';
$this->statuts[5] = 'StatusOrderReceivedAll';
$this->statuts[6] = 'StatusOrderCanceled'; // Approved->Canceled
@ -1618,19 +1621,65 @@ class CommandeFournisseur extends CommonOrder
}
}
/**
* Return array of dispathed lines waiting to be approved for this order
*
* @param int $status Filter on stats (-1 = no filter, 0 = lines draft to be approved, 1 = approved lines)
* @return array Array of lines
*/
function getDispachedLines($status=-1)
{
$ret = array();
// List of already dispatched lines
$sql = "SELECT p.ref, p.label,";
$sql.= " e.rowid as warehouse_id, e.label as entrepot,";
$sql.= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p,";
$sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid";
$sql.= " WHERE cfd.fk_commande = ".$this->id;
$sql.= " AND cfd.fk_product = p.rowid";
if ($status >= 0) $sql.=" AND cfd.status = ".$status;
$sql.= " ORDER BY cfd.rowid ASC";
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($resql);
if ($objp) $ret[]=array('id'=>$objp->dispatchedlineid, 'productid'=>$objp->fk_product, 'warehouseid'=>$objp->warehouse_id);
$i++;
}
}
else dol_print_error($this->db, 'Failed to execute request to get dispatched lines');
return $ret;
}
/**
* Set a delivery in database for this supplier order
*
* @param User $user User that input data
* @param date $date Date of reception
* @param string $type Type of receipt
* @param string $type Type of receipt ('tot' = total/done, 'par' = partial, 'nev' = never, 'can' = cancel)
* @param string $comment Comment
* @return int <0 if KO, >0 if OK
*/
function Livraison($user, $date, $type, $comment)
{
global $conf;
$result = 0;
$error = 0;
dol_syslog(get_class($this)."::Livraison");
if ($user->rights->fournisseur->commande->receptionner)
@ -1640,7 +1689,27 @@ class CommandeFournisseur extends CommonOrder
if ($type == 'nev') $statut = 7;
if ($type == 'can') $statut = 7;
if ($statut == 4 or $statut == 5 or $statut == 7)
if (! $error && ! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && ($type == 'tot'))
{
// If option SUPPLIER_ORDER_USE_DISPATCH_STATUS is on, we check all reception are approved to allow status "total/done"
$dispatchedlinearray=$this->getDispachedLines(0);
if (count($dispatchedlinearray) > 0)
{
$result=-1;
$error++;
$this->errors[]='ErrorCantSetReceptionToTotalDoneWithReceptionToApprove';
dol_syslog('ErrorCantSetReceptionToTotalDoneWithReceptionToApprove', LOG_DEBUG);
}
}
if (! $error && ! ($statut == 4 or $statut == 5 or $statut == 7))
{
$error++;
dol_syslog(get_class($this)."::Livraison Error -2", LOG_ERR);
$result = -2;
}
if (! $error)
{
$this->db->begin();
@ -1665,11 +1734,6 @@ class CommandeFournisseur extends CommonOrder
$result = -1;
}
}
else
{
dol_syslog(get_class($this)."::Livraison Error -2", LOG_ERR);
$result = -2;
}
}
else
{

View File

@ -17,7 +17,7 @@
*/
/**
* \file dev/skeletons/commandefournisseurdispatch.class.php
* \file fourn/class/fournisseur.commande.dispatch.class.php
* \ingroup fournisseur stock
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* Initialy built by build_class_from_table on 2015-02-24 10:38
@ -70,10 +70,10 @@ class CommandeFournisseurDispatch extends CommonObject
// List of language codes for status
$this->statuts[0] = 'Received';
$this->statuts[1] = 'Approved';
$this->statuts[1] = 'Verified';
$this->statuts[2] = 'Denied';
$this->statutshort[0] = 'Received';
$this->statutshort[1] = 'Approved';
$this->statutshort[1] = 'Verified';
$this->statutshort[2] = 'Denied';
return 1;
@ -494,23 +494,17 @@ class CommandeFournisseurDispatch extends CommonObject
if ($mode == 3)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut5');
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4');
}
if ($mode == 4)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut3').' '.$langs->trans($this->statuts[$statut]);
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut5').' '.$langs->trans($this->statuts[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
}
if ($mode == 5)
{
if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==3) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut5');
if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut4');
}
}

Some files were not shown because too many files have changed in this diff Show More