diff --git a/ChangeLog b/ChangeLog index f7eedaf236996a92cbe0085718be55982970b1be..66e4a8cfd8907836423c367ba85a0bfa1d835319 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.4 compared to 3.3 ***** For users: +- New: Add a tab "consumption" on thirdparties to list products bought/sells. - New: Some performance enhancements. - New: Can attach files onto trip and expenses modules. - New: Add option MAIN_PDF_TITLE_BACKGROUND_COLOR. diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 25767e8f5b2ebf04ddd859705c4bb301ae49880c..279669497ec80dd4dbf66453f78835d696b6a28a 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -660,6 +660,7 @@ if ($rowid) { $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe,"; $sql.= " c.rowid as crowid, c.cotisation,"; + $sql.= " c.datec,"; $sql.= " c.dateadh,"; $sql.= " c.datef,"; $sql.= " c.fk_bank,"; @@ -683,7 +684,8 @@ if ($rowid) print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Ref").'</td>'; - print '<td align="center">'.$langs->trans("DateSubscription").'</td>'; + print '<td align="center">'.$langs->trans("DateCreation").'</td>'; + print '<td align="center">'.$langs->trans("DateStart").'</td>'; print '<td align="center">'.$langs->trans("DateEnd").'</td>'; print '<td align="right">'.$langs->trans("Amount").'</td>'; if (! empty($conf->banque->enabled)) @@ -701,6 +703,7 @@ if ($rowid) $cotisationstatic->ref=$objp->crowid; $cotisationstatic->id=$objp->crowid; print '<td>'.$cotisationstatic->getNomUrl(1).'</td>'; + print '<td align="center">'.dol_print_date($db->jdate($objp->datec),'dayhour')."</td>\n"; print '<td align="center">'.dol_print_date($db->jdate($objp->dateadh),'day')."</td>\n"; print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n"; print '<td align="right">'.price($objp->cotisation).'</td>'; @@ -899,16 +902,18 @@ if ($rowid) // Title payments //print '<tr><td colspan="2"><b>'.$langs->trans("Payment").'</b></td></tr>'; - // Define a way to write payment + // No more action print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('MoreActions'); print '</td>'; print '<td>'; print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice)?' checked="checked"':'').'> '.$langs->trans("None").'<br>'; + // Add entry into bank accoun if (! empty($conf->banque->enabled)) { print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(! empty($bankdirect)?' checked="checked"':''); print '> '.$langs->trans("MoreActionBankDirect").'<br>'; } + // Add invoice with no payments if (! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) { print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(! empty($invoiceonly)?' checked="checked"':''); @@ -916,14 +921,16 @@ if ($rowid) print '> '.$langs->trans("MoreActionInvoiceOnly"); if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; else - { + { print ' ('.$langs->trans("NoThirdPartyAssociatedToMember"); print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">'; print $langs->trans("CreateDolibarrThirdParty"); print '</a>)'; } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0).'.'; print '<br>'; } + // Add invoice with payments if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) { print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(! empty($bankviainvoice)?' checked="checked"':''); @@ -931,12 +938,13 @@ if ($rowid) print '> '.$langs->trans("MoreActionBankViaInvoice"); if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; else - { + { print ' ('.$langs->trans("NoThirdPartyAssociatedToMember"); print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">'; print $langs->trans("CreateDolibarrThirdParty"); print '</a>)'; } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0).'.'; print '<br>'; } print '</td></tr>'; @@ -1029,4 +1037,4 @@ else llxFooter(); $db->close(); -?> +?> \ No newline at end of file diff --git a/htdocs/compta/bank/admin/bank.php b/htdocs/admin/bank.php similarity index 93% rename from htdocs/compta/bank/admin/bank.php rename to htdocs/admin/bank.php index a45fa29c912408e057e5f8349f63601a0aae3229..98a08708dff788326d3a1b7908f045856928af32 100644 --- a/htdocs/compta/bank/admin/bank.php +++ b/htdocs/admin/bank.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.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 @@ -18,12 +19,12 @@ /** - * \file htdocs/compta/bank/admin/bank.php + * \file htdocs/admin/bank.php * \ingroup bank * \brief Page to setup the bank module */ -require '../../../main.inc.php'; +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -87,6 +88,16 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM print_fiche_titre($langs->trans("BankSetupModule"),$linkback,'setup'); print '<br>'; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/bank.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Parameters").'</td>'; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 7dda6ded0e472804eb6968c845ebb49d5b8c1717..2a225234af63b35919b2662e65acec49b9276d7b 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -7,7 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com> + * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.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 @@ -66,7 +66,7 @@ if ($action == 'updateMask') } } -if ($action == 'specimen') +else if ($action == 'specimen') { $modele=GETPOST('module','alpha'); @@ -111,74 +111,36 @@ if ($action == 'specimen') } } -if ($action == 'set') +// Activate a model +else if ($action == 'set') { - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $type='order'; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; - if ($db->query($sql)) - { - - } + $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') +else if ($action == 'del') { - $type='order'; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql.= " WHERE nom = '".$db->escape($value)."'"; - $sql.= " AND type = '".$type."'"; - $sql.= " AND entity = ".$conf->entity; - - if ($db->query($sql)) + $ret = delDocumentModel($value, $type); + if ($ret > 0) { if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF',$conf->entity); } } -if ($action == 'setdoc') +// Set default model +else if ($action == 'setdoc') { - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $db->begin(); - if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent $conf->global->COMMANDE_ADDON_PDF = $value; } // On active le modele - $type='order'; - - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql_del.= " WHERE nom = '".$db->escape($value)."'"; - $sql_del.= " AND type = '".$type."'"; - $sql_del.= " AND entity = ".$conf->entity; - dol_syslog("Delete from model table ".$sql_del); - $result1=$db->query($sql_del); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$value."', '".$type."', ".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$scandir."'":"null"); - $sql.= ")"; - dol_syslog("Insert into model table ".$sql); - $result2=$db->query($sql); - if ($result1 && $result2) - { - $db->commit(); - } - else + $ret = delDocumentModel($value, $type); + if ($ret > 0) { - dol_syslog("Error ".$db->lasterror(), LOG_ERR); - $db->rollback(); + $ret = addDocumentModel($value, $type, $label, $scandir); } } @@ -240,10 +202,18 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM print_fiche_titre($langs->trans("OrdersSetup"),$linkback,'setup'); print '<br>'; +$h = 0; +$head[$h][0] = DOL_URL_ROOT."/admin/commande.php"; +$head[$h][1] = $langs->trans("Orders"); +$head[$h][2] = 'Order'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); /* - * Numbering module + * Orders Numbering model */ print_titre($langs->trans("OrdersNumberingModules")); @@ -276,22 +246,22 @@ foreach ($dirmodels as $reldir) { $file = substr($file, 0, dol_strlen($file)-4); - require_once DOL_DOCUMENT_ROOT ."/core/modules/commande/".$file.'.php'; + require_once $dir.$file.'.php'; $module = new $file; - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - if ($module->isEnabled()) { + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + $var=!$var; print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n"; print $module->info(); print '</td>'; - // Show example of numbering module + // Show example of numbering model print '<td nowrap="nowrap">'; $tmp=$module->getExample(); if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; @@ -508,11 +478,14 @@ foreach ($dirmodels as $reldir) } print '</table>'; - -//Autres Options print "<br>"; -print_titre($langs->trans("OtherOptions")); +/* + * Other options + * + */ + +print_titre($langs->trans("OtherOptions")); print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Parameter").'</td>'; diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index e45a316858fcb6495590b933082f17bea3ec9b10..a5213413d546a925a226bfe435670eae17bbc5e1 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -2,7 +2,8 @@ /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.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 @@ -35,6 +36,10 @@ accessforbidden(); $action = GETPOST('action','alpha'); +/* + * Actions + */ + $compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES'; if ($action == 'setcomptamode') @@ -87,7 +92,7 @@ if ($action == 'update' || $action == 'add') }*/ /* - * Affichage page + * View */ llxHeader(); @@ -97,9 +102,18 @@ $form=new Form($db); $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup'); - print '<br>'; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/compta.php"; +$head[$h][1] = $langs->trans("Compta"); +$head[$h][2] = 'Compta'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + print '<table class="noborder" width="100%">'; // Cas du parametre COMPTA_MODE diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 80e1547b33fbc22321b5c470937c658d75a08186..5e32dd097d08167bc4e036b49ba37da0c9ddd26a 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -1,5 +1,6 @@ <?php /* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.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 @@ -27,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $langs->load("admin"); $langs->load("errors"); +$langs->load("contracts"); if (!$user->admin) accessforbidden(); @@ -88,6 +90,20 @@ print_fiche_titre($langs->trans("ContractsSetup"),$linkback,'setup'); print "<br>"; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/contract.php"; +$head[$h][1] = $langs->trans("Contracts"); +$head[$h][2] = 'Contract'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + +/* + * Contracts Numbering model + */ + print_titre($langs->trans("ContractsNumberingModules")); print '<table class="noborder" width="100%">'; @@ -129,7 +145,7 @@ if (is_resource($handle)) print $module->info(); print '</td>'; - // Show example of numbering module + // Show example of numbering model print '<td nowrap="nowrap">'; $tmp=$module->getExample(); if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; } diff --git a/htdocs/admin/dons.php b/htdocs/admin/dons.php index 21c2b3a1a599e645b9b37d3dccce82b96bda13ee..0176436c928374d239eaa1a91124ac77f7cce2da 100644 --- a/htdocs/admin/dons.php +++ b/htdocs/admin/dons.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.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 @@ -47,7 +48,7 @@ if ($action == 'specimen') $don = new Don($db); $don->initAsSpecimen(); - // Charge le modele + // Search template files $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/"; $file = $modele.".modules.php"; if (file_exists($dir.$file)) @@ -75,67 +76,39 @@ if ($action == 'specimen') } } -if ($action == 'setdoc') +// Set default model +else if ($action == 'setdoc') { - $value = GETPOST('value','alpha'); - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $db->begin(); - - if (dolibarr_set_const($db, "DON_ADDON_MODEL",$value,'chaine',0,'',$conf->entity)) - { - $conf->global->DON_ADDON_MODEL = $value; - } - - // On active le modele - $type='donation'; - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql_del.= " WHERE nom = '".$db->escape($value)."' AND type = '".$type."'"; - $result1=$db->query($sql_del); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; - $result2=$db->query($sql); - if ($result1 && $result2) - { - $db->commit(); - } - else - { - $db->rollback(); - } + if (dolibarr_set_const($db, "DON_ADDON_MODEL",$value,'chaine',0,'',$conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->DON_ADDON_MODEL = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } } -if ($action == 'set') +// Activate a model +else if ($action == 'set') { - $value = GETPOST('value','alpha'); - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $type='donation'; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; - $resql=$db->query($sql); + $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') +else if ($action == 'del') { - $value = GETPOST('value','alpha'); - - $type='donation'; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql .= " WHERE nom = '".$value."' AND type = '".$type."'"; - $resql=$db->query($sql); + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->DON_ADDON_MODEL == "$value") dolibarr_del_const($db, 'DON_ADDON_MODEL',$conf->entity); + } } - /* * View */ @@ -147,6 +120,17 @@ llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration'); $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup'); +print '<br>'; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/dons.php"; +$head[$h][1] = $langs->trans("Donations"); +$head[$h][2] = 'Donation'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); // Document templates diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 908b36dbabb3bdac9e83cc96c5ece4757d899cab..45a142d81902ab26f811a7ff77280f1c3e0f68bb 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -70,6 +70,17 @@ llxHeader('',$langs->trans("ECMSetup"),$help_url); $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; print_fiche_titre($langs->trans("ECMSetup"),$linkback,'setup'); +print '<br>'; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/ecm.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 708acf6bc86eb1f75fa8a217dd07a30acb8d0d4d..023593ea2a7f2bd1b97b01fe5ef448b3365f941c 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> + * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.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 @@ -67,42 +67,7 @@ if ($action == 'updateMask') } } -if ($action == 'set_FICHINTER_FREE_TEXT') -{ - $freetext= GETPOST('FICHINTER_FREE_TEXT','alpha'); - $res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); - - if (! $res > 0) $error++; - - if (! $error) - { - $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; - } - else - { - $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; - } -} - -if ($action == 'set_FICHINTER_DRAFT_WATERMARK') -{ - $draft= GETPOST('FICHINTER_DRAFT_WATERMARK','alpha'); - - $res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); - - if (! $res > 0) $error++; - - if (! $error) - { - $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; - } - else - { - $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; - } -} - -if ($action == 'specimen') +else if ($action == 'specimen') // For fiche inter { $modele= GETPOST('module','alpha'); @@ -147,12 +112,13 @@ if ($action == 'specimen') } } -if ($action == 'set') +// Activate a model +else if ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') +else if ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) @@ -161,7 +127,8 @@ if ($action == 'del') } } -if ($action == 'setdoc') +// Set default model +else if ($action == 'setdoc') { if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { @@ -178,7 +145,7 @@ if ($action == 'setdoc') } } -if ($action == 'setmod') +else if ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated @@ -186,6 +153,41 @@ if ($action == 'setmod') dolibarr_set_const($db, "FICHEINTER_ADDON",$value,'chaine',0,'',$conf->entity); } +else if ($action == 'set_FICHINTER_FREE_TEXT') +{ + $freetext= GETPOST('FICHINTER_FREE_TEXT','alpha'); + $res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; + } + else + { + $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; + } +} + +else if ($action == 'set_FICHINTER_DRAFT_WATERMARK') +{ + $draft= GETPOST('FICHINTER_DRAFT_WATERMARK','alpha'); + + $res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; + } + else + { + $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; + } +} + /* * View @@ -202,6 +204,17 @@ print_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'setup'); print "<br>"; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php"; +$head[$h][1] = $langs->trans("Interventions"); +$head[$h][2] = 'Ficheinter'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + +// Interventions numbering model print_titre($langs->trans("FicheinterNumberingModules")); @@ -234,22 +247,22 @@ foreach ($dirmodels as $reldir) $file = $reg[1]; $classname = substr($file,4); - require_once DOL_DOCUMENT_ROOT ."/core/modules/fichinter/".$file.'.php'; + require_once $dir.$file.'.php'; $module = new $file; - - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - + if ($module->isEnabled()) { + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + $var=!$var; print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n"; print $module->info(); print '</td>'; - // Show example of numbering module + // Show example of numbering model print '<td nowrap="nowrap">'; $tmp=$module->getExample(); if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; @@ -295,6 +308,9 @@ foreach ($dirmodels as $reldir) print '</table><br>'; +/* + * Documents models for Interventions + */ print_titre($langs->trans("TemplatePDFInterventions")); @@ -377,7 +393,7 @@ foreach ($dirmodels as $reldir) print "</td>"; } - // Defaut + // Default print "<td align=\"center\">"; if ($conf->global->FICHEINTER_ADDON_PDF == "$name") { @@ -413,11 +429,14 @@ foreach ($dirmodels as $reldir) } print '</table>'; - -//Autres Options print "<br>"; -print_titre($langs->trans("OtherOptions")); +/* + * Other options + * + */ + +print_titre($langs->trans("OtherOptions")); print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Parameter").'</td>'; diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index ea5c9b7bbb41f600cb1842ba488b372a42f6ba46..87252252d65b72324f5c9959791b6320c381c4b3 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -103,6 +103,16 @@ llxHeader('',$langs->trans("MailingSetup")); $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; print_fiche_titre($langs->trans("MailingSetup"),$linkback,'setup'); +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/mailing.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + dol_htmloutput_mesg($mesg); diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 2734bacea2aa4f3d0dcecdb65c26cb2bc6844c73..5617ecc1dfbecdb634b55522bd54708da05fa12f 100755 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2012-2103 Juanjo Menent <jmenent@2byte.es> * * 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 @@ -57,12 +57,12 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'',$conf->entity); - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { +// if ($conf->global->MAIN_FEATURES_LEVEL > 1) +// { dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity); - } +// } header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -224,8 +224,8 @@ if ($action == 'edit') // Edit print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0,1); print '</td></tr>'; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { +// if ($conf->global->MAIN_FEATURES_LEVEL > 1) +// { //Desc $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>'; @@ -243,7 +243,7 @@ if ($action == 'edit') // Edit print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>'; print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0,1); print '</td></tr>'; - } +// } print '</table>'; @@ -418,8 +418,8 @@ else // Show print "</td>"; print '</tr>'; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { +// if ($conf->global->MAIN_FEATURES_LEVEL > 1) +// { //Desc $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td colspan="2">'; @@ -437,7 +437,7 @@ else // Show print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td colspan="2">'; print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1); print '</td></tr>'; - } +// } print '</table>'; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index f5dfb2bc8fb00f1cf86b21cf8fc7fabcaa55fc5a..2e21c3cfb4c2e5751e2a712f97aea56b214675b1 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -117,6 +117,17 @@ llxHeader('',$langs->trans("WithdrawalsSetup")); $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; print_fiche_titre($langs->trans("WithdrawalsSetup"),$linkback,'setup'); +print '<br>'; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/prelevement.php"; +$head[$h][1] = $langs->trans("Withdrawals"); +$head[$h][2] = 'Withdrawal'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); print '<form method="post" action="prelevement.php?action=set">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; diff --git a/htdocs/admin/project.php b/htdocs/admin/project.php index 8ea4910541ce1b6d1dda792c1bfbdcbd457e2382..f2f216d7b5257bea7e0d7cff60d80de458124048 100644 --- a/htdocs/admin/project.php +++ b/htdocs/admin/project.php @@ -2,7 +2,7 @@ /* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> + * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.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 @@ -66,7 +66,7 @@ if ($action == 'updateMask') } } -if ($action == 'specimen') +else if ($action == 'specimen') { $modele=GETPOST('module','alpha'); @@ -111,12 +111,13 @@ if ($action == 'specimen') } } -if ($action == 'set') +// Activate a model +else if ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') +else if ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) @@ -125,7 +126,8 @@ if ($action == 'del') } } -if ($action == 'setdoc') +// Set default model +else if ($action == 'setdoc') { if (dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { @@ -142,7 +144,7 @@ if ($action == 'setdoc') } } -if ($action == 'setmod') +else if ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated @@ -156,7 +158,7 @@ if ($action == 'setmod') $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); -llxHeader(); +llxHeader("",$langs->trans("ProjectsSetup")); $form=new Form($db); @@ -165,8 +167,20 @@ print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup'); print "<br>"; +$h = 0; -// Project numbering module +$head[$h][0] = DOL_URL_ROOT."/admin/project.php"; +$head[$h][1] = $langs->trans("Projects"); +$head[$h][2] = 'Project'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + +/* + * Projects Numbering model + */ + print_titre($langs->trans("ProjectsNumberingModules")); print '<table class="noborder" width="100%">'; @@ -198,7 +212,7 @@ foreach ($dirmodels as $reldir) $file = $reg[1]; $classname = substr($file,4); - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/".$file.'.php'; + require_once $dir.$file.'.php'; $module = new $file; @@ -213,7 +227,7 @@ foreach ($dirmodels as $reldir) print $module->info(); print '</td>'; - // Show example of numbering module + // Show example of numbering model print '<td nowrap="nowrap">'; $tmp=$module->getExample(); if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>'; @@ -269,7 +283,7 @@ print '</table><br>'; /* - * Modeles documents for projects + * Document templates generators */ print_titre($langs->trans("ProjectsModelModule")); @@ -352,7 +366,7 @@ foreach ($dirmodels as $reldir) print "</td>"; } - // Defaut + // Default print "<td align=\"center\">"; if ($conf->global->PROJECT_ADDON_PDF == "$name") { diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 1f40461ca0f621348d8464318121d511a66e7086..ba28ea15635c6f0fa2efd1ac8daf91ae03ff4402 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -3,6 +3,7 @@ * Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.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 @@ -97,6 +98,16 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM print_fiche_titre($langs->trans("StockSetup"),$linkback,'setup'); print '<br>'; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/stock.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + $form=new Form($db); $var=true; print '<table class="noborder" width="100%">'; @@ -124,9 +135,12 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">' print '</form>'; print "</td>\n"; print "</tr>\n"; - +print '<br>'; +print '</table>'; +print '<br>'; // Title rule for stock decrease +print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print " <td>".$langs->trans("RuleForStockManagementDecrease")."</td>\n"; print " <td align=\"right\" width=\"160\"> </td>\n"; @@ -174,9 +188,11 @@ if (! empty($conf->expedition->enabled)) print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print "</form>\n</td>\n</tr>\n"; } - +print '</table>'; +print '<br>'; // Title rule for stock increase +print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print " <td>".$langs->trans("RuleForStockManagementIncrease")."</td>\n"; print " <td align=\"right\" width=\"160\"> </td>\n"; diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index bf5e0db26a668097cc7cc92124ca2702b1dd2311..8e547bd4e211f4ffb66e69ef29ad3d33c460cc18 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -121,6 +121,17 @@ $form=new Form($db); $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; print_fiche_titre($langs->trans('TaxSetup'),$linkback,'setup'); +print '<br>'; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/taxes.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); print '<br>'; diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index c7ac95111b1cd43d049f848f8524d30604228c63..07a6647f4bb5d73f9e008ea7a6f86eea1903b150 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -575,7 +575,7 @@ if ($action == 'create') $numproject=select_projects((! empty($societe->id)?$societe->id:0),GETPOST("projectid")?GETPOST("projectid"):'','projectid'); if ($numproject==0) { - print ' <a href="'.DOL_DOCUMENT_ROOT.'/projet/fiche.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>'; + print ' <a href="'.DOL_URL_ROOT.'/projet/fiche.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>'; } print '</td></tr>'; } diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index eb4278cb528589b49c5d28a0a7091cf214d8e898..b74ebd119380e51548ab6023e94d7498e08d25cf 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1,747 +1,747 @@ -<?php -/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> - * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> - * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> - * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com> - * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> -* - * 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/>. - */ - -/** - * \file htdocs/comm/propal.php - * \ingroup propale - * \brief Page of commercial proposals card and list - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->projet->enabled)) -{ - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; -} - -$langs->load('companies'); -$langs->load('propal'); -$langs->load('compta'); -$langs->load('bills'); -$langs->load('orders'); -$langs->load('products'); -$langs->load("deliveries"); -if (! empty($conf->margin->enabled)) - $langs->load('margins'); - -$error=0; - -$id=GETPOST('id','int'); -$ref=GETPOST('ref','alpha'); -$socid=GETPOST('socid','int'); -$action=GETPOST('action','alpha'); -$origin=GETPOST('origin','alpha'); -$originid=GETPOST('originid','int'); -$confirm=GETPOST('confirm','alpha'); -$lineid=GETPOST('lineid','int'); - -//PDF -$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); - -// Nombre de ligne pour choix de produit/service predefinis -$NBLINES=4; - -// Security check -if (! empty($user->societe_id)) $socid=$user->societe_id; -$result = restrictedArea($user, 'propal', $id); - -$object = new Propal($db); -$extrafields = new ExtraFields($db); - -// Load object -if ($id > 0 || ! empty($ref)) -{ - $ret=$object->fetch($id, $ref); - if ($ret > 0) $ret=$object->fetch_thirdparty(); - if ($ret < 0) dol_print_error('',$object->error); -} - -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('propalcard')); - - - -/* - * Actions - */ - -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') -{ - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) - { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); - } - else - { - if ($object->id > 0) - { - $result=$object->createFromClone($socid); - if ($result > 0) - { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); - exit; - } - else - { - setEventMessage($object->error, 'errors'); - $action=''; - } - } - } -} - -// Suppression de la propale -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) -{ - $result=$object->delete($user); - if ($result > 0) - { - header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); - exit; - } - else - { - $langs->load("errors"); - setEventMessage($langs->trans($object->error), 'errors'); - } -} - -// Remove line -else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) -{ - $result = $object->deleteline($lineid); - // reorder lines - if ($result) $object->line_order(true); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; -} - -// Validation -else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) -{ - $result=$object->valid($user); - if ($result >= 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - else - { - $langs->load("errors"); - setEventMessage($langs->trans($object->error), 'errors'); - } -} - -else if ($action == 'setdate' && $user->rights->propal->creer) -{ - $datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - - if (empty($datep)) - { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); - } - - if (! $error) - { - $result=$object->set_date($user,$datep); - if ($result < 0) dol_print_error($db,$object->error); - } -} -else if ($action == 'setecheance' && $user->rights->propal->creer) -{ - $result=$object->set_echeance($user,dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); - if ($result < 0) dol_print_error($db,$object->error); -} -else if ($action == 'setdate_livraison' && $user->rights->propal->creer) -{ - $result=$object->set_date_livraison($user,dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); - if ($result < 0) dol_print_error($db,$object->error); -} - -// Positionne ref client -else if ($action == 'set_ref_client' && $user->rights->propal->creer) -{ - $object->set_ref_client($user, $_POST['ref_client']); -} - -else if ($action == 'setnote_public' && $user->rights->propal->creer) -{ - $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote' && $user->rights->propal->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} - -// Create proposal -else if ($action == 'add' && $user->rights->propal->creer) -{ - $object->socid=$socid; - $object->fetch_thirdparty(); - - $datep=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $date_delivery=dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - $duration=GETPOST('duree_validite'); - - if (empty($datep)) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); - $action='create'; - $error++; - } - if (empty($duration)) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); - $action='create'; - $error++; - } - - if ($socid<1) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors'); - $action='create'; - $error++; - } - - if (! $error) - { - $db->begin(); - - // Si on a selectionne une propal a copier, on realise la copie - if (GETPOST('createmode')=='copy' && GETPOST('copie_propal')) - { - if ($object->fetch(GETPOST('copie_propal')) > 0) - { - $object->ref = GETPOST('ref'); - $object->datep = $datep; - $object->date_livraison = $date_delivery; - $object->availability_id = GETPOST('availability_id'); - $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->fk_delivery_address = GETPOST('fk_address'); - $object->duree_validite = $duration; - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $object->remise_percent = GETPOST('remise_percent'); - $object->remise_absolue = GETPOST('remise_absolue'); - $object->socid = GETPOST('socid'); - $object->contactid = GETPOST('contactidp'); - $object->fk_project = GETPOST('projectid'); - $object->modelpdf = GETPOST('model'); - $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); - $object->statut = 0; - - $id = $object->create_from($user); - } - else - { - setEventMessage($langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')), 'errors'); - } - } - else - { - $object->ref = GETPOST('ref'); - $object->ref_client = GETPOST('ref_client'); - $object->datep = $datep; - $object->date_livraison = $date_delivery; - $object->availability_id = GETPOST('availability_id'); - $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->fk_delivery_address = GETPOST('fk_address'); - $object->duree_validite = GETPOST('duree_validite'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); - - $object->contactid = GETPOST('contactidp'); - $object->fk_project = GETPOST('projectid'); - $object->modelpdf = GETPOST('model'); - $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); - - $object->origin = GETPOST('origin'); - $object->origin_id = GETPOST('originid'); - - for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) - { - if ($_POST['idprod'.$i]) - { - $xid = 'idprod'.$i; - $xqty = 'qty'.$i; - $xremise = 'remise'.$i; - $object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); - } - } - - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $object->array_options[$key]=GETPOST($key); - } - } - - $id = $object->create($user); - } - - if ($id > 0) - { - // Insertion contact par defaut si defini - if (GETPOST('contactidp')) - { - $result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external'); - if ($result < 0) - { - $error++; - setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); - } - } - - if (! $error) - { - $db->commit(); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } - else - { - $db->rollback(); - } - } - else - { - dol_print_error($db,$object->error); - $db->rollback(); - exit; - } - } -} - -// Classify billed -else if ($action == 'classifybilled' && $user->rights->propal->cloturer) -{ - $object->cloture($user, 4, ''); -} - -// Reopen proposal -else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) -{ - // prevent browser refresh from reopening proposal several times - if ($object->statut==2 || $object->statut==3) - { - $object->setStatut(1); - } -} - -// Close proposal -else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) -{ - if (! GETPOST('statut')) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")), 'errors'); - $action='statut'; - } - else - { - // prevent browser refresh from closing proposal several times - if ($object->statut==1) - { - $object->cloture($user, GETPOST('statut'), GETPOST('note')); - } - } -} - -/* - * Add file in email form - */ -if (GETPOST('addfile')) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - dol_add_file_process($upload_dir_tmp,0,0); - $action='presend'; -} - -/* - * Remove file in email form - */ -if (GETPOST('removedfile')) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process($_POST['removedfile'],0); - $action='presend'; -} - -/* - * Send mail - */ -if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) -{ - $langs->load('mails'); - - if ($object->id > 0) - { - if ($_POST['sendto']) - { - // Le destinataire a ete fourni via le champ libre - $sendto = $_POST['sendto']; - $sendtoid = 0; - } - elseif ($_POST['receiver'] != '-1') - { - // Recipient was provided from combo list - if ($_POST['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); - $sendtoid = $_POST['receiver']; - } - } - - if (dol_strlen($sendto)) - { - $langs->load("commercial"); - - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; - $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; - $message = $_POST['message']; - $sendtocc = $_POST['sendtocc']; - $deliveryreceipt = $_POST['deliveryreceipt']; - - if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; - else $subject = $langs->transnoentities('Propal').' '.$object->ref; - $actiontypecode='AC_PROP'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; - if ($message) - { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; - } - $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $attachedfiles=$formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - // Envoi de la propal - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); - if ($mailfile->error) - { - setEventMessage($mailfile->error, 'errors'); - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2 = $actionmsg2; - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PROPAL_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers - - if (! $error) - { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); - setEventMessage($mesg); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - dol_print_error($db); - } - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $mesg.='<br>'.$mailfile->error; - } - else - { - $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - setEventMessage($mesg, 'errors'); - } - } - } - else - { - $langs->load("other"); - setEventMessage($langs->trans('ErrorMailRecipientIsEmpty').'!', 'errors'); - dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); - } - } - else - { - $langs->load("other"); - setEventMessage($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")), 'errors'); - dol_syslog($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal"))); - } -} - -// Go back to draft -if ($action == 'modif' && $user->rights->propal->creer) -{ - $object->set_draft($user); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } -} - -else if ($action == "setabsolutediscount" && $user->rights->propal->creer) -{ - if ($_POST["remise_id"]) - { - if ($object->id > 0) - { - $result=$object->insert_discount($_POST["remise_id"]); - if ($result < 0) - { - setEventMessage($object->error, 'errors'); - } - } - } -} - -//Ajout d'une ligne produit dans la propale -else if ($action == "addline" && $user->rights->propal->creer) -{ - $idprod=GETPOST('idprod', 'int'); - $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); - $price_ht = GETPOST('price_ht'); - $tva_tx = (GETPOST('tva_tx')?GETPOST('tva_tx'):0); - - if (empty($idprod) && GETPOST('type') < 0) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); - $error++; - } - if ((empty($idprod) || GETPOST('usenewaddlineform')) && (!($price_ht != 0) || $price_ht == '')) // Unit price can be 0 but not ''. Also price can be negative for proposal. - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error++; - } - if (empty($idprod) && empty($product_desc)) - { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); - $error++; - } - - if (! $error && (GETPOST('qty') >= 0) && (! empty($product_desc) || ! empty($idprod))) - { - $pu_ht=0; - $pu_ttc=0; - $price_min=0; - $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - if (! empty($idprod)) - { - $prod = new Product($db); - $prod->fetch($idprod); - - $label = ((GETPOST('product_label') && GETPOST('product_label')!=$prod->label)?GETPOST('product_label'):''); - - // If prices fields are update - if (GETPOST('usenewaddlineform')) - { - $pu_ht=price2num($price_ht, 'MU'); - $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr=(preg_match('/\*/', $tva_tx)?1:0); - $tva_tx=str_replace('*','', $tva_tx); - $desc = $product_desc; - } - else - { - $tva_tx = get_default_tva($mysoc,$object->client,$prod->id); - $tva_npr = get_default_npr($mysoc,$object->client,$prod->id); - - // On defini prix unitaire - if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) - { - $pu_ht = $prod->multiprices[$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; - $price_min = $prod->multiprices_min[$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) - { - if ($price_base_type != 'HT') - { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); - } - else - { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); - } - } - - $desc=''; - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) - { - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if (empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; - } - else - { - $desc = $prod->description; - } - - $desc=dol_concatdesc($desc,$product_desc); - +<?php +/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> + * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> + * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> + * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com> + * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> +* + * 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/>. + */ + +/** + * \file htdocs/comm/propal.php + * \ingroup propale + * \brief Page of commercial proposals card and list + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (! empty($conf->projet->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +} + +$langs->load('companies'); +$langs->load('propal'); +$langs->load('compta'); +$langs->load('bills'); +$langs->load('orders'); +$langs->load('products'); +$langs->load("deliveries"); +if (! empty($conf->margin->enabled)) + $langs->load('margins'); + +$error=0; + +$id=GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); +$origin=GETPOST('origin','alpha'); +$originid=GETPOST('originid','int'); +$confirm=GETPOST('confirm','alpha'); +$lineid=GETPOST('lineid','int'); + +//PDF +$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); + +// Nombre de ligne pour choix de produit/service predefinis +$NBLINES=4; + +// Security check +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result = restrictedArea($user, 'propal', $id); + +$object = new Propal($db); +$extrafields = new ExtraFields($db); + +// Load object +if ($id > 0 || ! empty($ref)) +{ + $ret=$object->fetch($id, $ref); + if ($ret > 0) $ret=$object->fetch_thirdparty(); + if ($ret < 0) dol_print_error('',$object->error); +} + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('propalcard')); + + + +/* + * Actions + */ + +$parameters=array('socid'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + +// Action clone object +if ($action == 'confirm_clone' && $confirm == 'yes') +{ + if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + { + setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + } + else + { + if ($object->id > 0) + { + $result=$object->createFromClone($socid); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + setEventMessage($object->error, 'errors'); + $action=''; + } + } + } +} + +// Suppression de la propale +else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) +{ + $result=$object->delete($user); + if ($result > 0) + { + header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); + exit; + } + else + { + $langs->load("errors"); + setEventMessage($langs->trans($object->error), 'errors'); + } +} + +// Remove line +else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) +{ + $result = $object->deleteline($lineid); + // reorder lines + if ($result) $object->line_order(true); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; +} + +// Validation +else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) +{ + $result=$object->valid($user); + if ($result >= 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + $langs->load("errors"); + setEventMessage($langs->trans($object->error), 'errors'); + } +} + +else if ($action == 'setdate' && $user->rights->propal->creer) +{ + $datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + + if (empty($datep)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); + } + + if (! $error) + { + $result=$object->set_date($user,$datep); + if ($result < 0) dol_print_error($db,$object->error); + } +} +else if ($action == 'setecheance' && $user->rights->propal->creer) +{ + $result=$object->set_echeance($user,dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); + if ($result < 0) dol_print_error($db,$object->error); +} +else if ($action == 'setdate_livraison' && $user->rights->propal->creer) +{ + $result=$object->set_date_livraison($user,dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); + if ($result < 0) dol_print_error($db,$object->error); +} + +// Positionne ref client +else if ($action == 'set_ref_client' && $user->rights->propal->creer) +{ + $object->set_ref_client($user, $_POST['ref_client']); +} + +else if ($action == 'setnote_public' && $user->rights->propal->creer) +{ + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->propal->creer) +{ + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +// Create proposal +else if ($action == 'add' && $user->rights->propal->creer) +{ + $object->socid=$socid; + $object->fetch_thirdparty(); + + $datep=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $date_delivery=dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $duration=GETPOST('duree_validite'); + + if (empty($datep)) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); + $action='create'; + $error++; + } + if (empty($duration)) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); + $action='create'; + $error++; + } + + if ($socid<1) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors'); + $action='create'; + $error++; + } + + if (! $error) + { + $db->begin(); + + // Si on a selectionne une propal a copier, on realise la copie + if (GETPOST('createmode')=='copy' && GETPOST('copie_propal')) + { + if ($object->fetch(GETPOST('copie_propal')) > 0) + { + $object->ref = GETPOST('ref'); + $object->datep = $datep; + $object->date_livraison = $date_delivery; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->duree_validite = $duration; + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = GETPOST('remise_absolue'); + $object->socid = GETPOST('socid'); + $object->contactid = GETPOST('contactidp'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); + $object->author = $user->id; // deprecated + $object->note = GETPOST('note'); + $object->statut = 0; + + $id = $object->create_from($user); + } + else + { + setEventMessage($langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')), 'errors'); + } + } + else + { + $object->ref = GETPOST('ref'); + $object->ref_client = GETPOST('ref_client'); + $object->datep = $datep; + $object->date_livraison = $date_delivery; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->duree_validite = GETPOST('duree_validite'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + + $object->contactid = GETPOST('contactidp'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); + $object->author = $user->id; // deprecated + $object->note = GETPOST('note'); + + $object->origin = GETPOST('origin'); + $object->origin_id = GETPOST('originid'); + + for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) + { + if ($_POST['idprod'.$i]) + { + $xid = 'idprod'.$i; + $xqty = 'qty'.$i; + $xremise = 'remise'.$i; + $object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); + } + } + + // Get extra fields + foreach($_POST as $key => $value) + { + if (preg_match("/^options_/",$key)) + { + $object->array_options[$key]=GETPOST($key); + } + } + + $id = $object->create($user); + } + + if ($id > 0) + { + // Insertion contact par defaut si defini + if (GETPOST('contactidp')) + { + $result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external'); + if ($result < 0) + { + $error++; + setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + } + } + + if (! $error) + { + $db->commit(); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db,$object->error); + $db->rollback(); + exit; + } + } +} + +// Classify billed +else if ($action == 'classifybilled' && $user->rights->propal->cloturer) +{ + $object->cloture($user, 4, ''); +} + +// Reopen proposal +else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) +{ + // prevent browser refresh from reopening proposal several times + if ($object->statut==2 || $object->statut==3) + { + $object->setStatut(1); + } +} + +// Close proposal +else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) +{ + if (! GETPOST('statut')) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")), 'errors'); + $action='statut'; + } + else + { + // prevent browser refresh from closing proposal several times + if ($object->statut==1) + { + $object->cloture($user, GETPOST('statut'), GETPOST('note')); + } + } +} + +/* + * Add file in email form + */ +if (GETPOST('addfile')) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + dol_add_file_process($upload_dir_tmp,0,0); + $action='presend'; +} + +/* + * Remove file in email form + */ +if (GETPOST('removedfile')) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + // TODO Delete only files that was uploaded from email form + dol_remove_file_process($_POST['removedfile'],0); + $action='presend'; +} + +/* + * Send mail + */ +if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) +{ + $langs->load('mails'); + + if ($object->id > 0) + { + if ($_POST['sendto']) + { + // Le destinataire a ete fourni via le champ libre + $sendto = $_POST['sendto']; + $sendtoid = 0; + } + elseif ($_POST['receiver'] != '-1') + { + // Recipient was provided from combo list + if ($_POST['receiver'] == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } + else // Id du contact + { + $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); + $sendtoid = $_POST['receiver']; + } + } + + if (dol_strlen($sendto)) + { + $langs->load("commercial"); + + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; + $message = $_POST['message']; + $sendtocc = $_POST['sendtocc']; + $deliveryreceipt = $_POST['deliveryreceipt']; + + if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; + else $subject = $langs->transnoentities('Propal').' '.$object->ref; + $actiontypecode='AC_PROP'; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + if ($message) + { + $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; + $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; + $actionmsg.=$message; + } + $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + + // Envoi de la propal + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); + if ($mailfile->error) + { + setEventMessage($mailfile->error, 'errors'); + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('PROPAL_SENTBYMAIL',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + + if (! $error) + { + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); + setEventMessage($mesg); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + dol_print_error($db); + } + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='<br>'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + setEventMessage($mesg, 'errors'); + } + } + } + else + { + $langs->load("other"); + setEventMessage($langs->trans('ErrorMailRecipientIsEmpty').'!', 'errors'); + dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); + } + } + else + { + $langs->load("other"); + setEventMessage($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")), 'errors'); + dol_syslog($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal"))); + } +} + +// Go back to draft +if ($action == 'modif' && $user->rights->propal->creer) +{ + $object->set_draft($user); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } +} + +else if ($action == "setabsolutediscount" && $user->rights->propal->creer) +{ + if ($_POST["remise_id"]) + { + if ($object->id > 0) + { + $result=$object->insert_discount($_POST["remise_id"]); + if ($result < 0) + { + setEventMessage($object->error, 'errors'); + } + } + } +} + +//Ajout d'une ligne produit dans la propale +else if ($action == "addline" && $user->rights->propal->creer) +{ + $idprod=GETPOST('idprod', 'int'); + $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); + $price_ht = GETPOST('price_ht'); + $tva_tx = (GETPOST('tva_tx')?GETPOST('tva_tx'):0); + + if (empty($idprod) && GETPOST('type') < 0) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); + $error++; + } + if ((empty($idprod) || GETPOST('usenewaddlineform')) && (!($price_ht != 0) || $price_ht == '')) // Unit price can be 0 but not ''. Also price can be negative for proposal. + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error++; + } + if (empty($idprod) && empty($product_desc)) + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); + $error++; + } + + if (! $error && (GETPOST('qty') >= 0) && (! empty($product_desc) || ! empty($idprod))) + { + $pu_ht=0; + $pu_ttc=0; + $price_min=0; + $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + if (! empty($idprod)) + { + $prod = new Product($db); + $prod->fetch($idprod); + + $label = ((GETPOST('product_label') && GETPOST('product_label')!=$prod->label)?GETPOST('product_label'):''); + + // If prices fields are update + if (GETPOST('usenewaddlineform')) + { + $pu_ht=price2num($price_ht, 'MU'); + $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr=(preg_match('/\*/', $tva_tx)?1:0); + $tva_tx=str_replace('*','', $tva_tx); + $desc = $product_desc; + } + else + { + $tva_tx = get_default_tva($mysoc,$object->client,$prod->id); + $tva_npr = get_default_npr($mysoc,$object->client,$prod->id); + + // On defini prix unitaire + if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) + { + $pu_ht = $prod->multiprices[$object->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; + $price_min = $prod->multiprices_min[$object->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; + } + else + { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + if ($tva_tx != $prod->tva_tx) + { + if ($price_base_type != 'HT') + { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); + } + else + { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + } + } + + $desc=''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } + + $desc=dol_concatdesc($desc,$product_desc); + // Add custom code and origin country into description if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { @@ -752,1501 +752,1512 @@ else if ($action == "addline" && $user->rights->propal->creer) $tmptxt.=')'; $desc= dol_concatdesc($desc, $tmptxt); } - } - - $type = $prod->type; - } - else - { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx)?1:0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label')?GETPOST('product_label'):''); - $desc = $product_desc; - $type = GETPOST('type'); - } - - // Margin - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); - - // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $object->client); - $localtax2_tx= get_localtax($tva_tx, 2, $object->client); - - $info_bits=0; - if ($tva_npr) $info_bits |= 0x01; - - if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) - { - $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').$langs->getCurrencySymbol($conf->currency)); - setEventMessage($mesg, 'errors'); - } - else - { - // Insert line - $result=$object->addline( - $id, - $desc, - $pu_ht, - GETPOST('qty'), - $tva_tx, - $localtax1_tx, - $localtax2_tx, - $idprod, - GETPOST('remise_percent'), - $price_base_type, - $pu_ttc, - $info_bits, - $type, - -1, - 0, - GETPOST('fk_parent_line'), - $fournprice, - $buyingprice, - $label - ); - - if ($result > 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['idprod']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - - // old method - unset($_POST['np_desc']); - unset($_POST['dp_desc']); - } - else - { - setEventMessage($object->error, 'errors'); - } - } - } -} - -// Mise a jour d'une ligne dans la propale -else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save') == $langs->trans("Save")) -{ - // Define info_bits - $info_bits=0; - if (preg_match('/\*/', GETPOST('tva_tx'))) $info_bits |= 0x01; - - // Clean parameters - $description=dol_htmlcleanlastbr(GETPOST('product_desc')); - - // Define vat_rate - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); - $vat_rate=str_replace('*','',$vat_rate); - $localtax1_rate=get_localtax($vat_rate,1,$object->client); - $localtax2_rate=get_localtax($vat_rate,2,$object->client); - $pu_ht=GETPOST('price_ht'); - - // Add buying price - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); - - // Define special_code for special lines - $special_code=0; - if (! GETPOST('qty')) $special_code=3; - - // Check minimum price - $productid = GETPOST('productid', 'int'); - if (! empty($productid)) - { - $product = new Product($db); - $res=$product->fetch($productid); - - $type=$product->type; - - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - $price_min = $product->multiprices_min[$object->client->price_level]; - - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):''); - - if ($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) - { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).$langs->getCurrencySymbol($conf->currency), 'errors'); - $error++; - } - } - else - { - $type = GETPOST('type'); - $label = (GETPOST('product_label') ? GETPOST('product_label'):''); - - // Check parameters - if (GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); - $error++; - } - } - - if (! $error) - { - $result = $object->updateline( - GETPOST('lineid'), - $pu_ht, - GETPOST('qty'), - GETPOST('remise_percent'), - $vat_rate, - $localtax1_rate, - $localtax2_rate, - $description, - 'HT', - $info_bits, - $special_code, - GETPOST('fk_parent_line'), - 0, - $fournprice, - $buyingprice, - $label, - $type - ); - - if ($result >= 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['productid']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - } - else - { - setEventMessage($object->error, 'errors'); - } - } -} - -else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) -{ - header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition - exit; -} - -// Generation doc (depuis lien ou depuis cartouche doc) -else if ($action == 'builddoc' && $user->rights->propal->creer) -{ - if (GETPOST('model')) - { - $object->setDocModel($user, GETPOST('model')); - } - - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - else - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); - exit; - } -} - -// Remove file in doc form -else if ($action == 'remove_file' && $user->rights->propal->creer) -{ - if ($object->id > 0) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $conf->propal->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); - } -} - -// Set project -else if ($action == 'classin' && $user->rights->propal->creer) -{ - $object->setProject($_POST['projectid']); -} - -// Delai de livraison -else if ($action == 'setavailability' && $user->rights->propal->creer) -{ - $result = $object->availability($_POST['availability_id']); -} - -// Origine de la propale -else if ($action == 'setdemandreason' && $user->rights->propal->creer) -{ - $result = $object->demand_reason($_POST['demand_reason_id']); -} - -// Conditions de reglement -else if ($action == 'setconditions' && $user->rights->propal->creer) -{ - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int')); -} - -else if ($action == 'setremisepercent' && $user->rights->propal->creer) -{ - $result = $object->set_remise_percent($user, $_POST['remise_percent']); -} - -else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) -{ - $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); -} - -// Mode de reglement -else if ($action == 'setmode' && $user->rights->propal->creer) -{ - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); -} - -/* - * Ordonnancement des lignes - */ - -else if ($action == 'up' && $user->rights->propal->creer) -{ - $object->line_up(GETPOST('rowid')); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); - exit; -} - -else if ($action == 'down' && $user->rights->propal->creer) -{ - $object->line_down(GETPOST('rowid')); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); - exit; -} -else if ($action == 'update_extras') -{ - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $object->array_options[$key]=$_POST[$key]; - } - } - // Actions on extra fields (by external module or standard code) - // FIXME le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('propaldao')); - $parameters=array('id'=>$object->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$object->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - else if ($reshook < 0) $error++; - -} - -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) -{ - if ($action == 'addcontact') - { - if ($object->id > 0) - { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); - } - else - { - setEventMessage($object->error, 'errors'); - } - } - } - - // Bascule du statut d'un contact - else if ($action == 'swapstatut') - { - if ($object->fetch($id) > 0) - { - $result=$object->swapContactStatus(GETPOST('ligne')); - } - else - { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact') - { - $object->fetch($id); - $result = $object->delete_contact($lineid); - - if ($result >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - dol_print_error($db); - } - } -} - - -/* - * View - */ - -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); - -$form = new Form($db); -$formother = new FormOther($db); -$formfile = new FormFile($db); -$formpropal = new FormPropal($db); -$companystatic=new Societe($db); - -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('propal'); - -$now=dol_now(); - -// Add new proposal -if ($action == 'create') -{ - print_fiche_titre($langs->trans("NewProp")); - - $soc = new Societe($db); - if ($socid>0) $res=$soc->fetch($socid); - - $object = new Propal($db); - - print '<form name="addprop" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="add">'; - - if ($origin != 'project' && $originid) - { - print '<input type="hidden" name="origin" value="'.$origin.'">'; - print '<input type="hidden" name="originid" value="'.$originid.'">'; - } - - print '<table class="border" width="100%">'; - - // Reference - print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>'; - - // Ref customer - print '<tr><td>'.$langs->trans('RefCustomer').'</td><td colspan="2">'; - print '<input type="text" name="ref_client" value=""></td>'; - print '</tr>'; - - // Third party - print '<tr>'; - print '<td class="fieldrequired">'.$langs->trans('Customer').'</td>'; - if($socid>0) - { - print '<td colspan="2">'; - print $soc->getNomUrl(1); - print '<input type="hidden" name="socid" value="'.$soc->id.'">'; - print '</td>'; - } - else - { - print '<td colspan="2">'; - print $form->select_company('','socid','s.client = 1 OR s.client = 2 OR s.client = 3',1); - print '</td>'; - } - print '</tr>'."\n"; - - // Contacts - if($socid>0) - { - print "<tr><td>".$langs->trans("DefaultContact").'</td><td colspan="2">'; - $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); - print '</td></tr>'; - - // Ligne info remises tiers - print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">'; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount=$soc->getAvailableDiscounts(); - print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '</td></tr>'; - } - - // Date - print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">'; - $form->select_date('','','','','',"addprop"); - print '</td></tr>'; - - // Validaty duration - print '<tr><td class="fieldrequired">'.$langs->trans("ValidityDuration").'</td><td colspan="2"><input name="duree_validite" size="5" value="'.$conf->global->PROPALE_VALIDITY_DURATION.'"> '.$langs->trans("days").'</td></tr>'; - - // Terms of payment - print '<tr><td nowrap="nowrap" class="fieldrequired">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; - $form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); - print '</td></tr>'; - - // Mode of payment - print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; - $form->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); - print '</td></tr>'; - - // What trigger creation - print '<tr><td>'.$langs->trans('Source').'</td><td>'; - $form->select_demand_reason('','demand_reason_id',"SRC_PROP",1); - print '</td></tr>'; - - // Delivery delay - print '<tr><td>'.$langs->trans('AvailabilityPeriod').'</td><td colspan="2">'; - $form->select_availability('','availability_id','',1); - print '</td></tr>'; - - // Delivery date (or manufacturing) - print '<tr><td>'.$langs->trans("DeliveryDate").'</td>'; - print '<td colspan="2">'; - if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") - { - $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); - $syear = date("Y", $tmpdte); - $smonth = date("m", $tmpdte); - $sday = date("d", $tmpdte); - $form->select_date($syear."-".$smonth."-".$sday,'liv_','','','',"addprop"); - } - else - { - $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - $form->select_date($datepropal,'liv_','','','',"addprop"); - } - print '</td></tr>'; - - // Model - print '<tr>'; - print '<td>'.$langs->trans("DefaultModel").'</td>'; - print '<td colspan="2">'; - $liste=ModelePDFPropales::liste_modeles($db); - print $form->selectarray('model',$liste,$conf->global->PROPALE_ADDON_PDF); - print "</td></tr>"; - - // Project - if (! empty($conf->projet->enabled) && $socid>0) - { - $projectid = 0; - if ($origin == 'project') $projectid = ($originid?$originid:0); - - print '<tr>'; - print '<td valign="top">'.$langs->trans("Project").'</td><td colspan="2">'; - - $numprojet=select_projects($soc->id,$projectid); - if ($numprojet==0) - { - print ' <a href="../projet/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>'; - } - print '</td>'; - print '</tr>'; - } - - // Other attributes - $parameters=array('colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - - // Show separator only - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print '<tr><td'; - if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.'</td><td colspan="3">'; - print $extrafields->showInputField($key,$value); - print '</td></tr>'."\n"; - } - } - } - - print "</table>"; - print '<br>'; - - /* - * Combobox pour la fonction de copie - */ - - if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) - { - print '<input type="hidden" name="createmode" value="empty">'; - } - - print '<table>'; - if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) - { - // For backward compatibility - print '<tr>'; - print '<td><input type="radio" name="createmode" value="copy"></td>'; - print '<td>'.$langs->trans("CopyPropalFrom").' </td>'; - print '<td>'; - $liste_propal = array(); - $liste_propal[0] = ''; - - $sql ="SELECT p.rowid as id, p.ref, s.nom"; - $sql.=" FROM ".MAIN_DB_PREFIX."propal p"; - $sql.= ", ".MAIN_DB_PREFIX."societe s"; - $sql.= " WHERE s.rowid = p.fk_soc"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND p.fk_statut <> 0"; - $sql.= " ORDER BY Id"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); - $propalRefAndSocName = $row[1]." - ".$row[2]; - $liste_propal[$row[0]]=$propalRefAndSocName; - $i++; - } - print $form->selectarray("copie_propal",$liste_propal, 0); - } - else - { - dol_print_error($db); - } - print '</td></tr>'; - - if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '<tr><td colspan="3"> </td></tr>'; - - print '<tr><td valign="top"><input type="radio" name="createmode" value="empty" checked="checked"></td>'; - print '<td valign="top" colspan="2">'.$langs->trans("CreateEmptyPropal").'</td></tr>'; - } - - if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) - { - print '<tr><td colspan="3">'; - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) - { - $lib=$langs->trans("ProductsAndServices"); - - print '<table class="border" width="100%">'; - print '<tr>'; - print '<td>'.$lib.'</td>'; - print '<td>'.$langs->trans("Qty").'</td>'; - print '<td>'.$langs->trans("ReductionShort").'</td>'; - print '</tr>'; - for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) - { - print '<tr><td>'; - // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) - $form->select_produits('',"idprod".$i,'',$conf->product->limit_size,$soc->price_level); - else - $form->select_produits('',"idprod".$i,'',$conf->product->limit_size); - print '</td>'; - print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td>'; - print '<td><input type="text" size="2" name="remise'.$i.'" value="'.$soc->remise_client.'">%</td>'; - print '</tr>'; - } - - print "</table>"; - - } - print '</td></tr>'; - } - print '</table>'; - print '<br>'; - - $langs->load("bills"); - print '<center>'; - print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">'; - print ' <input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; - print '</center>'; - - print "</form>"; -} -else -{ - /* - * Show object in view mode - */ - - $soc = new Societe($db); - $soc->fetch($object->socid); - - $head = propal_prepare_head($object); - dol_fiche_head($head, 'comm', $langs->trans('Proposal'), 0, 'propal'); - - $formconfirm=''; - - // Clone confirmation - if ($action == 'clone') - { - // Create an array for form - $formquestion=array( - //'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid','int'),'socid','(s.client=1 OR s.client=2 OR s.client=3)')) - ); - // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1); - } - - // Confirm delete - else if ($action == 'delete') - { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp',$object->ref), 'confirm_delete','',0,1); - } - - // Confirm reopen - else if ($action == 'reopen') - { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp',$object->ref), 'confirm_reopen','',0,1); - } - - // Confirmation delete product/service line - else if ($action == 'ask_deleteline') - { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1); - } - - // Confirm validate proposal - else if ($action == 'validate') - { - $error=0; - - // on verifie si l'objet est en numerotation provisoire - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') - { - $numref = $object->getNextNumRef($soc); - if (empty($numref)) - { - $error++; - dol_htmloutput_errors($object->error); - } - } - else - { - $numref = $object->ref; - } - - $text=$langs->trans('ConfirmValidateProp',$numref); - if (! empty($conf->notification->enabled)) - { - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; - $notify=new Notify($db); - $text.='<br>'; - $text.=$notify->confirmMessage('NOTIFY_VAL_PROPAL',$object->socid); - } - - if (! $error) $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1); - } - - if (! $formconfirm) - { - $parameters=array('lineid'=>$lineid); - $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - } - - // Print form confirm - print $formconfirm; - - - print '<table class="border" width="100%">'; - - $linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; - - // Ref - print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="5">'; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); - print '</td></tr>'; - - // Ref client - print '<tr><td>'; - print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">'; - print $langs->trans('RefCustomer').'</td><td align="left">'; - print '</td>'; - if ($action != 'refclient' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="5">'; - if ($user->rights->propal->creer && $action == 'refclient') - { - print '<form action="propal.php?id='.$object->id.'" method="post">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="set_ref_client">'; - print '<input type="text" class="flat" size="20" name="ref_client" value="'.$object->ref_client.'">'; - print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">'; - print '</form>'; - } - else - { - print $object->ref_client; - } - print '</td>'; - print '</tr>'; - - // Company - print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$soc->getNomUrl(1).'</td>'; - print '</tr>'; - - // Ligne info remises tiers - print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">'; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - print '. '; - $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL'); - $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL'); - $absolute_discount=price2num($absolute_discount,'MT'); - $absolute_creditnote=price2num($absolute_creditnote,'MT'); - if ($absolute_discount) - { - if ($object->statut > 0) - { - print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); - } - else - { - // Remise dispo de type non avoir - $filter='fk_facture_source IS NULL'; - print '<br>'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter); - } - } - if ($absolute_creditnote) - { - print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'. '; - } - if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; - print '</td></tr>'; - - // Date of proposal - print '<tr>'; - print '<td>'; - print '<table class="nobordernopadding" width="100%"><tr><td>'; - print $langs->trans('Date'); - print '</td>'; - if ($action != 'editdate' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&id='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - if (! empty($object->brouillon) && $action == 'editdate') - { - print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="setdate">'; - $form->select_date($object->date,'re','','',0,"editdate"); - print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; - print '</form>'; - } - else - { - if ($object->date) - { - print dol_print_date($object->date,'daytext'); - } - else - { - print ' '; - } - } - print '</td>'; - - // Date end proposal - print '<tr>'; - print '<td>'; - print '<table class="nobordernopadding" width="100%"><tr><td>'; - print $langs->trans('DateEndPropal'); - print '</td>'; - if ($action != 'editecheance' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editecheance&id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - if (! empty($object->brouillon) && $action == 'editecheance') - { - print '<form name="editecheance" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="setecheance">'; - $form->select_date($object->fin_validite,'ech','','','',"editecheance"); - print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; - print '</form>'; - } - else - { - if (! empty($object->fin_validite)) - { - print dol_print_date($object->fin_validite,'daytext'); - if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); - } - else - { - print ' '; - } - } - print '</td>'; - print '</tr>'; - - // Payment term - print '<tr><td>'; - print '<table class="nobordernopadding" width="100%"><tr><td>'; - print $langs->trans('PaymentConditionsShort'); - print '</td>'; - if ($action != 'editconditions' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'),1).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - if ($action == 'editconditions') - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id'); - } - else - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none'); - } - print '</td>'; - print '</tr>'; - - // Delivery date - $langs->load('deliveries'); - print '<tr><td>'; - print '<table class="nobordernopadding" width="100%"><tr><td>'; - print $langs->trans('DeliveryDate'); - print '</td>'; - if ($action != 'editdate_livraison' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'),1).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - if ($action == 'editdate_livraison') - { - print '<form name="editdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="setdate_livraison">'; - $form->select_date($object->date_livraison,'liv_','','','',"editdate_livraison"); - print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; - print '</form>'; - } - else - { - print dol_print_date($object->date_livraison,'daytext'); - } - print '</td>'; - print '</tr>'; - - // Delivery delay - print '<tr><td>'; - print '<table class="nobordernopadding" width="100%"><tr><td>'; - print $langs->trans('AvailabilityPeriod'); - if (! empty($conf->commande->enabled)) print ' ('.$langs->trans('AfterOrder').')'; - print '</td>'; - if ($action != 'editavailability' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editavailability&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'),1).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - if ($action == 'editavailability') - { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'availability_id',1); - } - else - { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'none',1); - } - - print '</td>'; - print '</tr>'; - - // Origin of demand - print '<tr><td>'; - print '<table class="nobordernopadding" width="100%"><tr><td>'; - print $langs->trans('Source'); - print '</td>'; - if ($action != 'editdemandreason' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'),1).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - //print $object->demand_reason_id; - if ($action == 'editdemandreason') - { - $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id',1); - } - else - { - $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'none'); - } - - print '</td>'; - print '</tr>'; - - // Payment mode - print '<tr>'; - print '<td width="25%">'; - print '<table class="nobordernopadding" width="100%"><tr><td>'; - print $langs->trans('PaymentMode'); - print '</td>'; - if ($action != 'editmode' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'),1).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - if ($action == 'editmode') - { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); - } - else - { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); - } - print '</td></tr>'; - - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - print '<tr><td>'; - print '<table class="nobordernopadding" width="100%"><tr><td>'; - print $langs->trans('Project').'</td>'; - if ($user->rights->propal->creer) - { - if ($action != 'classify') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - if ($action == 'classify') - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid'); - } - else - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none'); - } - print '</td></tr>'; - } - else - { - print '</td></tr></table>'; - if (! empty($object->fk_project)) - { - print '<td colspan="3">'; - $proj = new Project($db); - $proj->fetch($object->fk_project); - print '<a href="../projet/fiche.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; - print $proj->ref; - print '</a>'; - print '</td>'; - } - else { - print '<td colspan="3"> </td>'; - } - } - print '</tr>'; - } - - // Other attributes - $res=$object->fetch_optionals($object->id,$extralabels); - $parameters=array('colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - - if ($action == 'edit_extras') - { - print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">'; - print '<input type="hidden" name="action" value="update_extras">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="id" value="'.$object->id.'">'; - } - - - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print '<tr><td'; - if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.'</td><td colspan="3">'; - if ($action == 'edit_extras' && $user->rights->propal->creer) - { - print $extrafields->showInputField($key,$value); - } - else - { - print $extrafields->showOutputField($key,$value); - } - print '</td></tr>'."\n"; - } - } - - if(count($extrafields->attribute_label) > 0) { - - if ($action == 'edit_extras' && $user->rights->propal->creer) - { - print '<tr><td></td><td>'; - print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; - print '</form>'; - print '</td></tr>'; - - } - else { - if ($object->statut == 0 && $user->rights->propal->creer) - { - print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>'; - } - } - } - } - - // Amount HT - print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>'; - print '<td align="right" nowrap><b>'.price($object->total_ht).'</b></td>'; - print '<td>'.$langs->trans("Currency".$conf->currency).'</td>'; - - // Margin Infos - if (! empty($conf->margin->enabled)) { - print '<td valign="top" width="50%" rowspan="4">'; - $object->displayMarginInfos(); - print '</td>'; - } - print '</tr>'; - - // Amount VAT - print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td>'; - print '<td align="right" nowrap>'.price($object->total_tva).'</td>'; - print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; - - // Amount Local Taxes - if ($mysoc->localtax1_assuj=="1") //Localtax1 - { - print '<tr><td height="10">'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>'; - print '<td align="right" nowrap>'.price($object->total_localtax1).'</td>'; - print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; - } - if ($mysoc->localtax2_assuj=="1") //Localtax2 - { - print '<tr><td height="10">'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>'; - print '<td align="right" nowrap>'.price($object->total_localtax2).'</td>'; - print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; - } - - - // Amount TTC - print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td>'; - print '<td align="right" nowrap>'.price($object->total_ttc).'</td>'; - print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; - - // Statut - print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="2">'.$object->getLibStatut(4).'</td></tr>'; - - print '</table><br>'; - - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - /* - * Lines - */ - - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) - { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '<table id="tablelines" class="noborder" width="100%">'; - - // Show object lines - $result = $object->getLinesArray(); - if (! empty($object->lines)) - $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid); - - // Form to add new line - if ($object->statut == 0 && $user->rights->propal->creer) - { - if ($action != 'editline') - { - $var=true; - - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { - // Add free or predefined products/services - $object->formAddObjectLine(0,$mysoc,$soc); - } - else - { - // Add free products/services - $object->formAddFreeProduct(0,$mysoc,$soc); - - // Add predefined products/services - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) - { - $var=!$var; - $object->formAddPredefinedProduct(0,$mysoc,$soc); - } - } - - $parameters=array(); - $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - } - } - - print '</table>'; - - print '</div>'; - print "\n"; - - if ($action == 'statut') - { - /* - * Formulaire cloture (signe ou non) - */ - $form_close = '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; - $form_close.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - $form_close.= '<table class="border" width="100%">'; - $form_close.= '<tr><td width="150" align="left">'.$langs->trans("CloseAs").'</td><td align="left">'; - $form_close.= '<input type="hidden" name="action" value="setstatut">'; - $form_close.= '<select id="statut" name="statut" class="flat">'; - $form_close.= '<option value="0"> </option>'; - $form_close.= '<option value="2">'.$object->labelstatut[2].'</option>'; - $form_close.= '<option value="3">'.$object->labelstatut[3].'</option>'; - $form_close.= '</select>'; - $form_close.= '</td></tr>'; - $form_close.= '<tr><td width="150" align="left">'.$langs->trans('Note').'</td><td align="left"><textarea cols="70" rows="'.ROWS_3.'" wrap="soft" name="note">'; - $form_close.= $object->note; - $form_close.= '</textarea></td></tr>'; - $form_close.= '<tr><td align="center" colspan="2">'; - $form_close.= '<input type="submit" class="button" name="validate" value="'.$langs->trans('Validate').'">'; - $form_close.= ' <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'; - $form_close.= '<a name="close"> </a>'; - $form_close.= '</td>'; - $form_close.= '</tr></table></form>'; - - print $form_close; - } - - - /* - * Boutons Actions - */ - if ($action != 'presend') - { - print '<div class="tabsAction">'; - - if ($action != 'statut' && $action <> 'editline') - { - // Validate - if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && $user->rights->propal->valider) - { - if (count($object->lines) > 0) print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=validate">'.$langs->trans('Validate').'</a>'; - //else print '<a class="butActionRefused" href="#">'.$langs->trans('Validate').'</a>'; - } - - // Edit - if ($object->statut == 1 && $user->rights->propal->creer) - { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=modif">'.$langs->trans('Modify').'</a>'; - } - - // ReOpen - if (($object->statut == 2 || $object->statut == 3) && $user->rights->propal->cloturer) - { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#reopen').'"'; - print '>'.$langs->trans('ReOpen').'</a>'; - } - - // Send - if ($object->statut == 1 || $object->statut == 2) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) - { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>'; - } - else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>'; - } - - // Create an order - if (! empty($conf->commande->enabled) && $object->statut == 2 && $user->societe_id == 0) - { - if ($user->rights->commande->creer) - { - print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a>'; - } - } - - // Create an invoice and classify billed - if ($object->statut == 2 && $user->societe_id == 0) - { - if (! empty($conf->facture->enabled) && $user->rights->facture->creer) - { - print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddBill").'</a>'; - } - - $arraypropal=$object->getInvoiceArrayList(); - if (is_array($arraypropal) && count($arraypropal) > 0) - { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled&socid='.$object->socid.'">'.$langs->trans("ClassifyBilled").'</a>'; - } - } - - // Close - if ($object->statut == 1 && $user->rights->propal->cloturer) - { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=statut'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#close').'"'; - print '>'.$langs->trans('Close').'</a>'; - } - - // Clone - if ($user->rights->propal->creer) - { - print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object='.$object->element.'">'.$langs->trans("ToClone").'</a>'; - } - - // Delete - if ($user->rights->propal->supprimer) - { - print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete"'; - print '>'.$langs->trans('Delete').'</a>'; - } - - } - - print '</div>'; - print "<br>\n"; - } - - if ($action != 'presend') - { - print '<table width="100%"><tr><td width="50%" valign="top">'; - print '<a name="builddoc"></a>'; // ancre - - - /* - * Documents generes - */ - $filename=dol_sanitizeFileName($object->ref); - $filedir=$conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->propal->creer; - $delallowed=$user->rights->propal->supprimer; - - $var=true; - - $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang); - - - /* - * Linked object block - */ - $somethingshown=$object->showLinkedObjectBlock(); - - print '</td><td valign="top" width="50%">'; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'propal',$socid); - - print '</td></tr></table>'; - } - - - /* - * Action presend - * - */ - if ($action == 'presend') - { - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); - $file=$fileparams['fullname']; - - // Build document if it not exists - if (! $file || ! is_readable($file)) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); - $file=$fileparams['fullname']; - } - - print '<br>'; - print_titre($langs->trans('SendPropalByMail')); - - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - $formmail->withfrom=1; + } + + $type = $prod->type; + } + else + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx)?1:0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label')?GETPOST('product_label'):''); + $desc = $product_desc; + $type = GETPOST('type'); + } + + // Margin + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + + // Local Taxes + $localtax1_tx= get_localtax($tva_tx, 1, $object->client); + $localtax2_tx= get_localtax($tva_tx, 2, $object->client); + + $info_bits=0; + if ($tva_npr) $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) + { + $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').$langs->getCurrencySymbol($conf->currency)); + setEventMessage($mesg, 'errors'); + } + else + { + // Insert line + $result=$object->addline( + $id, + $desc, + $pu_ht, + GETPOST('qty'), + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $idprod, + GETPOST('remise_percent'), + $price_base_type, + $pu_ttc, + $info_bits, + $type, + -1, + 0, + GETPOST('fk_parent_line'), + $fournprice, + $buyingprice, + $label + ); + + if ($result > 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprod']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + + // old method + unset($_POST['np_desc']); + unset($_POST['dp_desc']); + } + else + { + setEventMessage($object->error, 'errors'); + } + } + } +} + +// Mise a jour d'une ligne dans la propale +else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save') == $langs->trans("Save")) +{ + // Define info_bits + $info_bits=0; + if (preg_match('/\*/', GETPOST('tva_tx'))) $info_bits |= 0x01; + + // Clean parameters + $description=dol_htmlcleanlastbr(GETPOST('product_desc')); + + // Define vat_rate + $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $vat_rate=str_replace('*','',$vat_rate); + $localtax1_rate=get_localtax($vat_rate,1,$object->client); + $localtax2_rate=get_localtax($vat_rate,2,$object->client); + $pu_ht=GETPOST('price_ht'); + + // Add buying price + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + + // Define special_code for special lines + $special_code=0; + if (! GETPOST('qty')) $special_code=3; + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (! empty($productid)) + { + $product = new Product($db); + $res=$product->fetch($productid); + + $type=$product->type; + + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + $price_min = $product->multiprices_min[$object->client->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):''); + + if ($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) + { + setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).$langs->getCurrencySymbol($conf->currency), 'errors'); + $error++; + } + } + else + { + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label'):''); + + // Check parameters + if (GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); + $error++; + } + } + + if (! $error) + { + $result = $object->updateline( + GETPOST('lineid'), + $pu_ht, + GETPOST('qty'), + GETPOST('remise_percent'), + $vat_rate, + $localtax1_rate, + $localtax2_rate, + $description, + 'HT', + $info_bits, + $special_code, + GETPOST('fk_parent_line'), + 0, + $fournprice, + $buyingprice, + $label, + $type + ); + + if ($result >= 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + } + else + { + setEventMessage($object->error, 'errors'); + } + } +} + +else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) +{ + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition + exit; +} + +// Generation doc (depuis lien ou depuis cartouche doc) +else if ($action == 'builddoc' && $user->rights->propal->creer) +{ + if (GETPOST('model')) + { + $object->setDocModel($user, GETPOST('model')); + } + + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + exit; + } +} + +// Remove file in doc form +else if ($action == 'remove_file' && $user->rights->propal->creer) +{ + if ($object->id > 0) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $langs->load("other"); + $upload_dir = $conf->propal->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + } +} + +// Set project +else if ($action == 'classin' && $user->rights->propal->creer) +{ + $object->setProject($_POST['projectid']); +} + +// Delai de livraison +else if ($action == 'setavailability' && $user->rights->propal->creer) +{ + $result = $object->availability($_POST['availability_id']); +} + +// Origine de la propale +else if ($action == 'setdemandreason' && $user->rights->propal->creer) +{ + $result = $object->demand_reason($_POST['demand_reason_id']); +} + +// Conditions de reglement +else if ($action == 'setconditions' && $user->rights->propal->creer) +{ + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int')); +} + +else if ($action == 'setremisepercent' && $user->rights->propal->creer) +{ + $result = $object->set_remise_percent($user, $_POST['remise_percent']); +} + +else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) +{ + $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); +} + +// Mode de reglement +else if ($action == 'setmode' && $user->rights->propal->creer) +{ + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); +} + +/* + * Ordonnancement des lignes + */ + +else if ($action == 'up' && $user->rights->propal->creer) +{ + $object->line_up(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); + exit; +} + +else if ($action == 'down' && $user->rights->propal->creer) +{ + $object->line_down(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); + exit; +} +else if ($action == 'update_extras') +{ + // Get extra fields + foreach($_POST as $key => $value) + { + if (preg_match("/^options_/",$key)) + { + $object->array_options[$key]=$_POST[$key]; + } + } + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('propaldao')); + $parameters=array('id'=>$object->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$object->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + +} + +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) +{ + if ($action == 'addcontact') + { + if ($object->id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + } + else + { + setEventMessage($object->error, 'errors'); + } + } + } + + // Bascule du statut d'un contact + else if ($action == 'swapstatut') + { + if ($object->fetch($id) > 0) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact') + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + dol_print_error($db); + } + } +} + + +/* + * View + */ + +llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); + +$form = new Form($db); +$formother = new FormOther($db); +$formfile = new FormFile($db); +$formpropal = new FormPropal($db); +$companystatic=new Societe($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('propal'); + +$now=dol_now(); + +// Add new proposal +if ($action == 'create') +{ + print_fiche_titre($langs->trans("NewProp")); + + $soc = new Societe($db); + if ($socid>0) $res=$soc->fetch($socid); + + $object = new Propal($db); + + print '<form name="addprop" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="add">'; + + if ($origin != 'project' && $originid) + { + print '<input type="hidden" name="origin" value="'.$origin.'">'; + print '<input type="hidden" name="originid" value="'.$originid.'">'; + } + + print '<table class="border" width="100%">'; + + // Reference + print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>'; + + // Ref customer + print '<tr><td>'.$langs->trans('RefCustomer').'</td><td colspan="2">'; + print '<input type="text" name="ref_client" value=""></td>'; + print '</tr>'; + + // Third party + print '<tr>'; + print '<td class="fieldrequired">'.$langs->trans('Customer').'</td>'; + if($socid>0) + { + print '<td colspan="2">'; + print $soc->getNomUrl(1); + print '<input type="hidden" name="socid" value="'.$soc->id.'">'; + print '</td>'; + } + else + { + print '<td colspan="2">'; + print $form->select_company('','socid','s.client = 1 OR s.client = 2 OR s.client = 3',1); + print '</td>'; + } + print '</tr>'."\n"; + + // Contacts + if($socid>0) + { + print "<tr><td>".$langs->trans("DefaultContact").'</td><td colspan="2">'; + $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); + print '</td></tr>'; + + // Ligne info remises tiers + print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">'; + if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + $absolute_discount=$soc->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '</td></tr>'; + } + + // Date + print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">'; + $form->select_date('','','','','',"addprop"); + print '</td></tr>'; + + // Validaty duration + print '<tr><td class="fieldrequired">'.$langs->trans("ValidityDuration").'</td><td colspan="2"><input name="duree_validite" size="5" value="'.$conf->global->PROPALE_VALIDITY_DURATION.'"> '.$langs->trans("days").'</td></tr>'; + + // Terms of payment + print '<tr><td nowrap="nowrap" class="fieldrequired">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; + $form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); + print '</td></tr>'; + + // Mode of payment + print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; + $form->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); + print '</td></tr>'; + + // What trigger creation + print '<tr><td>'.$langs->trans('Source').'</td><td>'; + $form->select_demand_reason('','demand_reason_id',"SRC_PROP",1); + print '</td></tr>'; + + // Delivery delay + print '<tr><td>'.$langs->trans('AvailabilityPeriod').'</td><td colspan="2">'; + $form->select_availability('','availability_id','',1); + print '</td></tr>'; + + // Delivery date (or manufacturing) + print '<tr><td>'.$langs->trans("DeliveryDate").'</td>'; + print '<td colspan="2">'; + if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") + { + $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); + $syear = date("Y", $tmpdte); + $smonth = date("m", $tmpdte); + $sday = date("d", $tmpdte); + $form->select_date($syear."-".$smonth."-".$sday,'liv_','','','',"addprop"); + } + else + { + $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $form->select_date($datepropal,'liv_','','','',"addprop"); + } + print '</td></tr>'; + + // Model + print '<tr>'; + print '<td>'.$langs->trans("DefaultModel").'</td>'; + print '<td colspan="2">'; + $liste=ModelePDFPropales::liste_modeles($db); + print $form->selectarray('model',$liste,$conf->global->PROPALE_ADDON_PDF); + print "</td></tr>"; + + // Project + if (! empty($conf->projet->enabled) && $socid>0) + { + $projectid = 0; + if ($origin == 'project') $projectid = ($originid?$originid:0); + + print '<tr>'; + print '<td valign="top">'.$langs->trans("Project").'</td><td colspan="2">'; + + $numprojet=select_projects($soc->id,$projectid); + if ($numprojet==0) + { + print ' <a href="../projet/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>'; + } + print '</td>'; + print '</tr>'; + } + + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + + // Show separator only + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print '<tr><td'; + if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.'</td><td colspan="3">'; + print $extrafields->showInputField($key,$value); + print '</td></tr>'."\n"; + } + } + } + + print "</table>"; + print '<br>'; + + /* + * Combobox pour la fonction de copie + */ + + if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) + { + print '<input type="hidden" name="createmode" value="empty">'; + } + + print '<table>'; + if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) + { + // For backward compatibility + print '<tr>'; + print '<td><input type="radio" name="createmode" value="copy"></td>'; + print '<td>'.$langs->trans("CopyPropalFrom").' </td>'; + print '<td>'; + $liste_propal = array(); + $liste_propal[0] = ''; + + $sql ="SELECT p.rowid as id, p.ref, s.nom"; + $sql.=" FROM ".MAIN_DB_PREFIX."propal p"; + $sql.= ", ".MAIN_DB_PREFIX."societe s"; + $sql.= " WHERE s.rowid = p.fk_soc"; + $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.fk_statut <> 0"; + $sql.= " ORDER BY Id"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $propalRefAndSocName = $row[1]." - ".$row[2]; + $liste_propal[$row[0]]=$propalRefAndSocName; + $i++; + } + print $form->selectarray("copie_propal",$liste_propal, 0); + } + else + { + dol_print_error($db); + } + print '</td></tr>'; + + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '<tr><td colspan="3"> </td></tr>'; + + print '<tr><td valign="top"><input type="radio" name="createmode" value="empty" checked="checked"></td>'; + print '<td valign="top" colspan="2">'.$langs->trans("CreateEmptyPropal").'</td></tr>'; + } + + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) + { + print '<tr><td colspan="3">'; + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + { + $lib=$langs->trans("ProductsAndServices"); + + print '<table class="border" width="100%">'; + print '<tr>'; + print '<td>'.$lib.'</td>'; + print '<td>'.$langs->trans("Qty").'</td>'; + print '<td>'.$langs->trans("ReductionShort").'</td>'; + print '</tr>'; + for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) + { + print '<tr><td>'; + // multiprix + if($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) + $form->select_produits('',"idprod".$i,'',$conf->product->limit_size,$soc->price_level); + else + $form->select_produits('',"idprod".$i,'',$conf->product->limit_size); + print '</td>'; + print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td>'; + print '<td><input type="text" size="2" name="remise'.$i.'" value="'.$soc->remise_client.'">%</td>'; + print '</tr>'; + } + + print "</table>"; + + } + print '</td></tr>'; + } + print '</table>'; + print '<br>'; + + $langs->load("bills"); + print '<center>'; + print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">'; + print ' <input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; + print '</center>'; + + print "</form>"; +} +else +{ + /* + * Show object in view mode + */ + + $soc = new Societe($db); + $soc->fetch($object->socid); + + $head = propal_prepare_head($object); + dol_fiche_head($head, 'comm', $langs->trans('Proposal'), 0, 'propal'); + + $formconfirm=''; + + // Clone confirmation + if ($action == 'clone') + { + // Create an array for form + $formquestion=array( + //'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid','int'),'socid','(s.client=1 OR s.client=2 OR s.client=3)')) + ); + // Paiement incomplet. On demande si motif = escompte ou autre + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1); + } + + // Confirm delete + else if ($action == 'delete') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp',$object->ref), 'confirm_delete','',0,1); + } + + // Confirm reopen + else if ($action == 'reopen') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp',$object->ref), 'confirm_reopen','',0,1); + } + + // Confirmation delete product/service line + else if ($action == 'ask_deleteline') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1); + } + + // Confirm validate proposal + else if ($action == 'validate') + { + $error=0; + + // on verifie si l'objet est en numerotation provisoire + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') + { + $numref = $object->getNextNumRef($soc); + if (empty($numref)) + { + $error++; + dol_htmloutput_errors($object->error); + } + } + else + { + $numref = $object->ref; + } + + $text=$langs->trans('ConfirmValidateProp',$numref); + if (! empty($conf->notification->enabled)) + { + require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; + $notify=new Notify($db); + $text.='<br>'; + $text.=$notify->confirmMessage('NOTIFY_VAL_PROPAL',$object->socid); + } + + if (! $error) $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1); + } + + if (! $formconfirm) + { + $parameters=array('lineid'=>$lineid); + $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + } + + // Print form confirm + print $formconfirm; + + + print '<table class="border" width="100%">'; + + $linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; + + // Ref + print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="5">'; + print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); + print '</td></tr>'; + + // Ref client + print '<tr><td>'; + print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">'; + print $langs->trans('RefCustomer').'</td><td align="left">'; + print '</td>'; + if ($action != 'refclient' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="5">'; + if ($user->rights->propal->creer && $action == 'refclient') + { + print '<form action="propal.php?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="set_ref_client">'; + print '<input type="text" class="flat" size="20" name="ref_client" value="'.$object->ref_client.'">'; + print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">'; + print '</form>'; + } + else + { + print $object->ref_client; + } + print '</td>'; + print '</tr>'; + + // Company + print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$soc->getNomUrl(1).'</td>'; + print '</tr>'; + + // Ligne info remises tiers + print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">'; + if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + print '. '; + $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL'); + $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL'); + $absolute_discount=price2num($absolute_discount,'MT'); + $absolute_creditnote=price2num($absolute_creditnote,'MT'); + if ($absolute_discount) + { + if ($object->statut > 0) + { + print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); + } + else + { + // Remise dispo de type non avoir + $filter='fk_facture_source IS NULL'; + print '<br>'; + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter); + } + } + if ($absolute_creditnote) + { + print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'. '; + } + if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; + print '</td></tr>'; + + // Date of proposal + print '<tr>'; + print '<td>'; + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('Date'); + print '</td>'; + if ($action != 'editdate' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&id='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + if (! empty($object->brouillon) && $action == 'editdate') + { + print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="setdate">'; + $form->select_date($object->date,'re','','',0,"editdate"); + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; + print '</form>'; + } + else + { + if ($object->date) + { + print dol_print_date($object->date,'daytext'); + } + else + { + print ' '; + } + } + print '</td>'; + + // Date end proposal + print '<tr>'; + print '<td>'; + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('DateEndPropal'); + print '</td>'; + if ($action != 'editecheance' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editecheance&id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + if (! empty($object->brouillon) && $action == 'editecheance') + { + print '<form name="editecheance" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="setecheance">'; + $form->select_date($object->fin_validite,'ech','','','',"editecheance"); + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; + print '</form>'; + } + else + { + if (! empty($object->fin_validite)) + { + print dol_print_date($object->fin_validite,'daytext'); + if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + } + else + { + print ' '; + } + } + print '</td>'; + print '</tr>'; + + // Payment term + print '<tr><td>'; + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('PaymentConditionsShort'); + print '</td>'; + if ($action != 'editconditions' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'),1).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + if ($action == 'editconditions') + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id'); + } + else + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none'); + } + print '</td>'; + print '</tr>'; + + // Delivery date + $langs->load('deliveries'); + print '<tr><td>'; + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('DeliveryDate'); + print '</td>'; + if ($action != 'editdate_livraison' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'),1).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + if ($action == 'editdate_livraison') + { + print '<form name="editdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="setdate_livraison">'; + $form->select_date($object->date_livraison,'liv_','','','',"editdate_livraison"); + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; + print '</form>'; + } + else + { + print dol_print_date($object->date_livraison,'daytext'); + } + print '</td>'; + print '</tr>'; + + // Delivery delay + print '<tr><td>'; + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('AvailabilityPeriod'); + if (! empty($conf->commande->enabled)) print ' ('.$langs->trans('AfterOrder').')'; + print '</td>'; + if ($action != 'editavailability' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editavailability&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'),1).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + if ($action == 'editavailability') + { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'availability_id',1); + } + else + { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'none',1); + } + + print '</td>'; + print '</tr>'; + + // Origin of demand + print '<tr><td>'; + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('Source'); + print '</td>'; + if ($action != 'editdemandreason' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'),1).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + //print $object->demand_reason_id; + if ($action == 'editdemandreason') + { + $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id',1); + } + else + { + $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'none'); + } + + print '</td>'; + print '</tr>'; + + // Payment mode + print '<tr>'; + print '<td width="25%">'; + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('PaymentMode'); + print '</td>'; + if ($action != 'editmode' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'),1).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + if ($action == 'editmode') + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); + } + else + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); + } + print '</td></tr>'; + + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + print '<tr><td>'; + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('Project').'</td>'; + if ($user->rights->propal->creer) + { + if ($action != 'classify') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + if ($action == 'classify') + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid'); + } + else + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none'); + } + print '</td></tr>'; + } + else + { + print '</td></tr></table>'; + if (! empty($object->fk_project)) + { + print '<td colspan="3">'; + $proj = new Project($db); + $proj->fetch($object->fk_project); + print '<a href="../projet/fiche.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; + print $proj->ref; + print '</a>'; + print '</td>'; + } + else { + print '<td colspan="3"> </td>'; + } + } + print '</tr>'; + } + + // Other attributes + $res=$object->fetch_optionals($object->id,$extralabels); + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + + if ($action == 'edit_extras') + { + print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">'; + print '<input type="hidden" name="action" value="update_extras">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="id" value="'.$object->id.'">'; + } + + + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print '<tr><td'; + if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.'</td><td colspan="3">'; + if ($action == 'edit_extras' && $user->rights->propal->creer) + { + print $extrafields->showInputField($key,$value); + } + else + { + print $extrafields->showOutputField($key,$value); + } + print '</td></tr>'."\n"; + } + } + + if(count($extrafields->attribute_label) > 0) { + + if ($action == 'edit_extras' && $user->rights->propal->creer) + { + print '<tr><td></td><td>'; + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; + print '</form>'; + print '</td></tr>'; + + } + else { + if ($object->statut == 0 && $user->rights->propal->creer) + { + print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>'; + } + } + } + } + + // Amount HT + print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>'; + print '<td align="right" nowrap><b>'.price($object->total_ht).'</b></td>'; + print '<td>'.$langs->trans("Currency".$conf->currency).'</td>'; + + // Margin Infos + if (! empty($conf->margin->enabled)) { + print '<td valign="top" width="50%" rowspan="4">'; + $object->displayMarginInfos(); + print '</td>'; + } + print '</tr>'; + + // Amount VAT + print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td>'; + print '<td align="right" nowrap>'.price($object->total_tva).'</td>'; + print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; + + // Amount Local Taxes + if ($mysoc->localtax1_assuj=="1") //Localtax1 + { + print '<tr><td height="10">'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>'; + print '<td align="right" nowrap>'.price($object->total_localtax1).'</td>'; + print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; + } + if ($mysoc->localtax2_assuj=="1") //Localtax2 + { + print '<tr><td height="10">'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>'; + print '<td align="right" nowrap>'.price($object->total_localtax2).'</td>'; + print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; + } + + + // Amount TTC + print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td>'; + print '<td align="right" nowrap>'.price($object->total_ttc).'</td>'; + print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; + + // Statut + print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="2">'.$object->getLibStatut(4).'</td></tr>'; + + print '</table><br>'; + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + /* + * Lines + */ + + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) + { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } + + print '<table id="tablelines" class="noborder" width="100%">'; + + // Show object lines + $result = $object->getLinesArray(); + if (! empty($object->lines)) + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid); + + // Form to add new line + if ($object->statut == 0 && $user->rights->propal->creer) + { + if ($action != 'editline') + { + $var=true; + + if ($conf->global->MAIN_FEATURES_LEVEL > 1) + { + // Add free or predefined products/services + $object->formAddObjectLine(0,$mysoc,$soc); + } + else + { + // Add free products/services + $object->formAddFreeProduct(0,$mysoc,$soc); + + // Add predefined products/services + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + { + $var=!$var; + $object->formAddPredefinedProduct(0,$mysoc,$soc); + } + } + + $parameters=array(); + $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + } + } + + print '</table>'; + + print '</div>'; + print "\n"; + + if ($action == 'statut') + { + /* + * Formulaire cloture (signe ou non) + */ + $form_close = '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + $form_close.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + $form_close.= '<table class="border" width="100%">'; + $form_close.= '<tr><td width="150" align="left">'.$langs->trans("CloseAs").'</td><td align="left">'; + $form_close.= '<input type="hidden" name="action" value="setstatut">'; + $form_close.= '<select id="statut" name="statut" class="flat">'; + $form_close.= '<option value="0"> </option>'; + $form_close.= '<option value="2">'.$object->labelstatut[2].'</option>'; + $form_close.= '<option value="3">'.$object->labelstatut[3].'</option>'; + $form_close.= '</select>'; + $form_close.= '</td></tr>'; + $form_close.= '<tr><td width="150" align="left">'.$langs->trans('Note').'</td><td align="left"><textarea cols="70" rows="'.ROWS_3.'" wrap="soft" name="note">'; + $form_close.= $object->note; + $form_close.= '</textarea></td></tr>'; + $form_close.= '<tr><td align="center" colspan="2">'; + $form_close.= '<input type="submit" class="button" name="validate" value="'.$langs->trans('Validate').'">'; + $form_close.= ' <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'; + $form_close.= '<a name="close"> </a>'; + $form_close.= '</td>'; + $form_close.= '</tr></table></form>'; + + print $form_close; + } + + + /* + * Boutons Actions + */ + if ($action != 'presend') + { + print '<div class="tabsAction">'; + + if ($action != 'statut' && $action <> 'editline') + { + // Validate + if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && $user->rights->propal->valider) + { + if (count($object->lines) > 0) print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=validate">'.$langs->trans('Validate').'</a>'; + //else print '<a class="butActionRefused" href="#">'.$langs->trans('Validate').'</a>'; + } + + // Edit + if ($object->statut == 1 && $user->rights->propal->creer) + { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=modif">'.$langs->trans('Modify').'</a>'; + } + + // ReOpen + if (($object->statut == 2 || $object->statut == 3) && $user->rights->propal->cloturer) + { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#reopen').'"'; + print '>'.$langs->trans('ReOpen').'</a>'; + } + + // Send + if ($object->statut == 1 || $object->statut == 2) + { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) + { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>'; + } + else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>'; + } + + // Create an order + if (! empty($conf->commande->enabled) && $object->statut == 2 && $user->societe_id == 0) + { + if ($user->rights->commande->creer) + { + print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a>'; + } + } + + // Create contract + if ($conf->contrat->enabled && $object->statut == 2 && $user->societe_id == 0) + { + $langs->load("contracts"); + + if ($user->rights->contrat->creer) + { + print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans('AddContract').'</a>'; + } + } + + // Create an invoice and classify billed + if ($object->statut == 2 && $user->societe_id == 0) + { + if (! empty($conf->facture->enabled) && $user->rights->facture->creer) + { + print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddBill").'</a>'; + } + + $arraypropal=$object->getInvoiceArrayList(); + if (is_array($arraypropal) && count($arraypropal) > 0) + { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled&socid='.$object->socid.'">'.$langs->trans("ClassifyBilled").'</a>'; + } + } + + // Close + if ($object->statut == 1 && $user->rights->propal->cloturer) + { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=statut'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#close').'"'; + print '>'.$langs->trans('Close').'</a>'; + } + + // Clone + if ($user->rights->propal->creer) + { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object='.$object->element.'">'.$langs->trans("ToClone").'</a>'; + } + + // Delete + if ($user->rights->propal->supprimer) + { + print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete"'; + print '>'.$langs->trans('Delete').'</a>'; + } + + } + + print '</div>'; + print "<br>\n"; + } + + if ($action != 'presend') + { + print '<table width="100%"><tr><td width="50%" valign="top">'; + print '<a name="builddoc"></a>'; // ancre + + + /* + * Documents generes + */ + $filename=dol_sanitizeFileName($object->ref); + $filedir=$conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed=$user->rights->propal->creer; + $delallowed=$user->rights->propal->supprimer; + + $var=true; + + $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang); + + + /* + * Linked object block + */ + $somethingshown=$object->showLinkedObjectBlock(); + + print '</td><td valign="top" width="50%">'; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'propal',$socid); + + print '</td></tr></table>'; + } + + + /* + * Action presend + * + */ + if ($action == 'presend') + { + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); + $file=$fileparams['fullname']; + + // Build document if it not exists + if (! $file || ! is_readable($file)) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); + $file=$fileparams['fullname']; + } + + print '<br>'; + print_titre($langs->trans('SendPropalByMail')); + + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom=1; $liste=array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; - $formmail->withto=GETPOST("sendto")?GETPOST("sendto"):$liste; - $formmail->withtocc=$liste; - $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false); - $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); - $formmail->withfile=2; - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - - // Tableau des substitutions - $formmail->substit['__PROPREF__']=$object->ref; - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__PERSONALIZED__']=''; - // Tableau des parametres complementaires - $formmail->param['action']='send'; - $formmail->param['models']='propal_send'; - $formmail->param['id']=$object->id; - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - // Init list of files - if (GETPOST("mode")=='init') - { - $formmail->clear_attached_files(); - $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); - } - - $formmail->show_form(); - - print '<br>'; - } -} - -// End of page -llxFooter(); -$db->close(); -?> + $formmail->withto=GETPOST("sendto")?GETPOST("sendto"):$liste; + $formmail->withtocc=$liste; + $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false); + $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); + $formmail->withfile=2; + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; + + // Tableau des substitutions + $formmail->substit['__PROPREF__']=$object->ref; + $formmail->substit['__SIGNATURE__']=$user->signature; + $formmail->substit['__PERSONALIZED__']=''; + // Tableau des parametres complementaires + $formmail->param['action']='send'; + $formmail->param['models']='propal_send'; + $formmail->param['id']=$object->id; + $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + + // Init list of files + if (GETPOST("mode")=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); + } + + $formmail->show_form(); + + print '<br>'; + } +} + +// End of page +llxFooter(); +$db->close(); +?> diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 15a428410023c32cf1bd0eed412c1ff166c6360c..493f34c3962455e7a82a50b8a648c03a2d032e05 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -912,6 +912,12 @@ class Commande extends CommonOrder $line->special_code = $object->lines[$i]->special_code; $line->fk_parent_line = $object->lines[$i]->fk_parent_line; + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; + $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; + $this->lines[$i] = $line; } diff --git a/htdocs/commissions/admin/commissions.php b/htdocs/commissions/admin/commissions.php deleted file mode 100644 index 015cab308ff2dc16ed2f398af8bdef25c283df10..0000000000000000000000000000000000000000 --- a/htdocs/commissions/admin/commissions.php +++ /dev/null @@ -1,192 +0,0 @@ -<?php -/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> - * - * 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/>. - */ - -/** - * \file /htdocs/admin/commissions.php - * \ingroup commissions - * \brief Page to setup advanced commissions module - */ - -include '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/commissions/lib/commissions.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); -require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); - -$langs->load("admin"); -$langs->load("bills"); -$langs->load("commissions"); - -if (! $user->admin) accessforbidden(); - - -/* - * Action - */ -if (GETPOST('commissionBase')) -{ - if (dolibarr_set_const($db, 'COMMISSION_BASE', GETPOST('commissionBase'), 'string', 0, '', $conf->entity) > 0) - { - $conf->global->COMMISSION_BASE = GETPOST('commissionBase'); - setEventMessage($langs->trans("RecordModifiedSuccessfully")); - } - else - { - dol_print_error($db); - } -} - -if (GETPOST('productCommissionRate')) -{ - if (dolibarr_set_const($db, 'PRODUCT_COMMISSION_RATE', GETPOST('productCommissionRate'), 'rate', 0, '', $conf->entity) > 0) - { - } - else - { - dol_print_error($db); - } -} - -if (GETPOST('serviceCommissionRate')) -{ - if (dolibarr_set_const($db, 'SERVICE_COMMISSION_RATE', GETPOST('serviceCommissionRate'), 'rate', 0, '', $conf->entity) > 0) - { - } - else - { - dol_print_error($db); - } -} - -if (GETPOST('AGENT_CONTACT_TYPE')) -{ - if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', GETPOST('AGENT_CONTACT_TYPE'), 'chaine', 0, '', $conf->entity) > 0) - { - $conf->global->AGENT_CONTACT_TYPE = GETPOST('AGENT_CONTACT_TYPE'); - } - else - { - dol_print_error($db); - } -} - -/* - * View - */ - -llxHeader('',$langs->trans("CommissionsSetup")); - - -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; -print_fiche_titre($langs->trans("commissionsSetup"),$linkback,'setup'); - - -$head = commissions_admin_prepare_head(); - -dol_fiche_head($head, 'parameters', $langs->trans("Commissions"), 0, 'commissions'); - -print "<br>"; - - -print_fiche_titre($langs->trans("MemberMainOptions"),'',''); -print '<table class="noborder" width="100%">'; -print '<tr class="liste_titre">'; -print '<td>'.$langs->trans("Description").'</td>'; -print '<td align="left">'.$langs->trans("Value").'</td>'."\n"; -print '<td align="left">'.$langs->trans("Details").'</td>'."\n"; -print '</tr>'; - -$var=true; -$form = new Form($db); - -print '<form method="post">'; - -// COMMISSION BASE (TURNOVER / MARGIN) -$var=!$var; -print '<tr '.$bc[$var].'>'; -print '<td>'.$langs->trans("CommissionBase").'</td>'; -print '<td align="left">'; -print '<input type="radio" name="commissionBase" value="TURNOVER" '; -if (isset($conf->global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "TURNOVER") - print 'checked'; -print ' />'; -print $langs->trans("CommissionBasedOnTurnover"); -print '<br/>'; -print '<input type="radio" name="commissionBase" value="MARGIN" '; -if (empty($conf->margin->enabled)) - print 'disabled'; -elseif (isset($conf->global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "MARGIN") - print 'checked'; -print ' />'; -print $langs->trans("CommissionBasedOnMargins"); -print '</td>'; -print '<td>'.$langs->trans('CommissionBaseDetails'); -print '<br/>'; -print $langs->trans('CommissionBasedOnMarginsDetails'); -print '</td>'; -print '</tr>'; - -// PRODUCT COMMISSION RATE -$var=!$var; -print '<tr '.$bc[$var].'>'; -print '<td>'.$langs->trans("ProductCommissionRate").'</td>'; -print '<td align="left">'; -print '<input type="text" name="productCommissionRate" value="'.(! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:'').'" size=6 /> %'; -print '</td>'; -print '<td>'.$langs->trans('ProductCommissionRateDetails').'</td>'; -print '</tr>'; - -// SERVICE COMMISSION RATE -$var=!$var; -print '<tr '.$bc[$var].'>'; -print '<td>'.$langs->trans("ServiceCommissionRate").'</td>'; -print '<td align="left">'; -print '<input type="text" name="serviceCommissionRate" value="'.(! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:'').'" size=6 /> %'; -print '</td>'; -print '<td>'.$langs->trans('ServiceCommissionRateDetails').'</td>'; -print '</tr>'; - -// INTERNAL CONTACT TYPE USED AS COMMERCIAL AGENT -$var=!$var; -print '<tr '.$bc[$var].'>'; -print '<td>'.$langs->trans("AgentContactType").'</td>'; -print '<td align="left">'; -$formcompany = new FormCompany($db); -$facture = new Facture($db); -print $formcompany->selectTypeContact($facture, $conf->global->AGENT_CONTACT_TYPE, "AGENT_CONTACT_TYPE","internal","code",1); -print '</td>'; -print '<td>'.$langs->trans('AgentContactTypeDetails').'</td>'; -print '</tr>'; - -$var=!$var; -print '<tr '.$bc[$var].'>'; -print '<td align="center" colspan="3">'; -print '<input type="submit" class="button" />'; -print '</td>'; -print '</tr>'; - -print '</table>'; - -print '</form>'; - -dol_fiche_end(); - -print '<br>'; - -llxFooter(); -$db->close(); -?> diff --git a/htdocs/commissions/index.php b/htdocs/commissions/index.php deleted file mode 100644 index cdc6329d858d02b2ede7899d25f7bb85198312a2..0000000000000000000000000000000000000000 --- a/htdocs/commissions/index.php +++ /dev/null @@ -1,329 +0,0 @@ -<?php -/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> - * - * 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/>. - */ - -/** - * \file htdocs/commissions/index.php - * \ingroup commissions - * \brief Page des commissions par agent commercial - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->margin->enabled)) - require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; - -$langs->load("companies"); -$langs->load("bills"); -$langs->load("products"); -$langs->load("commissions"); -if (! empty($conf->margin->enabled)) - $langs->load("margins"); - -// Security check -$agentid = GETPOST('agentid','int'); - -$mesg = ''; - -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -$startdate=$enddate=''; - -if (!empty($_POST['startdatemonth'])) - $startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear'])); -if (!empty($_POST['enddatemonth'])) - $enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear'])); - -/* - * View - */ - -$userstatic = new User($db); -$companystatic = new Societe($db); -$invoicestatic=new Facture($db); - -$form = new Form($db); - -llxHeader('',$langs->trans("Commissions")); - -$text=$langs->trans("Commissions"); -print_fiche_titre($text); - -print '<form method="post" name="sel">'; -print '<table class="border" width="100%">'; - -if ($agentid > 0) { - - print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>'; - print '<td colspan="4">'; - print $form->select_dolusers($agentid,'agentid',1,'',0,'',''); - print '</td></tr>'; - - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="s.nom"; -} -else { - print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>'; - print '<td colspan="4">'; - print $form->select_dolusers('','agentid',1,'',0,'',''); - print '</td></tr>'; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="u.login"; -} - -// Start date -print '<td>'.$langs->trans('StartDate').'</td>'; -print '<td width="20%">'; -$form->select_date($startdate,'startdate','','',1,"sel",1,1); -print '</td>'; -print '<td width="20%">'.$langs->trans('EndDate').'</td>'; -print '<td width="20%">'; -$form->select_date($enddate,'enddate','','',1,"sel",1,1); -print '</td>'; -print '<td style="text-align: center;">'; -print '<input type="submit" value="'.$langs->trans('Launch').'" />'; -print '</td></tr>'; - -// Include unpayed invoices -print '<tr><td>'.$langs->trans("IncludeUnpayedInvoices").'</td><td colspan="4">'; -print '<input id="selIncluded" type="checkbox" name="unpayed" '; -if (GETPOST('unpayed') == 'on') - print 'checked '; -print '/>'; -print '</td></tr>'; - - -// Total Margin -if ($conf->global->COMMISSION_BASE == "MARGIN") { - print '<tr style="font-weight: bold"><td>'.$langs->trans("TotalMargin").'</td><td colspan="4">'; - print '<span id="totalBase"></span>'; // set by jquery (see below) - print '</td></tr>'; -} -elseif ($conf->global->COMMISSION_BASE == "TURNOVER") { - print '<tr style="font-weight: bold"><td>'.$langs->trans("TurnoverTotal").'</td><td colspan="4">'; - print '<span id="totalBase"></span>'; // set by jquery (see below) - print '</td></tr>'; -} - -// Total Commission -print '<tr style="font-weight: bold"><td>'.$langs->trans("TotalCommission").'</td><td colspan="4">'; -print '<span id="totalCommission"></span>'; // set by jquery (see below) -print '</td></tr>'; - -print "</table>"; -print '</form>'; - -$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,"; -$sql.= " u.login,"; -if ($conf->global->COMMISSION_BASE == "MARGIN") { - $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ; - $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase" ; -} -elseif ($conf->global->COMMISSION_BASE == "TURNOVER") { - $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) end) as productBase," ; - $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase" ; -} -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."facture as f"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE); -$sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; -$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ", ".MAIN_DB_PREFIX."user as u"; -$sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= " AND sc.fk_soc = f.fk_soc"; -if (! empty($conf->global->AGENT_CONTACT_TYPE)) - $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))"; -else - $sql .= " AND sc.fk_user = u.rowid"; -if (GETPOST('unpayed') == 'on') - $sql.= " AND f.fk_statut > 0"; -else - $sql.= " AND f.fk_statut > 1"; -$sql.= " AND s.entity = ".$conf->entity; -$sql.= " AND d.fk_facture = f.rowid"; -if ($agentid > 0) { - if (! empty($conf->global->AGENT_CONTACT_TYPE)) - $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))"; - else - $sql .= " AND sc.fk_user = ".$agentid; -} -if (!empty($startdate)) - $sql.= " AND f.datef >= '".$startdate."'"; -if (!empty($enddate)) - $sql.= " AND f.datef <= '".$enddate."'"; -if ($conf->global->COMMISSION_BASE == "MARGIN") - $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (($conf->global->COMMISSION_BASE == "MARGIN") && isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) - $sql .= " AND d.buy_price_ht <> 0"; -if ($agentid > 0) - $sql.= " GROUP BY s.rowid"; -else - $sql.= " GROUP BY u.rowid"; -$sql.= " ORDER BY $sortfield $sortorder "; -//$sql.= $db->plimit($conf->liste_limit +1, $offset); - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - - print '<br>'; - print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); - - $i = 0; - print "<table class=\"noborder\" width=\"100%\">"; - - print '<tr class="liste_titre">'; - if ($agentid > 0) - print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); - else - print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); - - // product commission - if ($conf->global->COMMISSION_BASE == "MARGIN") - print_liste_field_titre($langs->trans("ProductMargin"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - elseif ($conf->global->COMMISSION_BASE == "TURNOVER") - print_liste_field_titre($langs->trans("ProductTurnover"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ProductCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - // service commission - if ($conf->global->COMMISSION_BASE == "MARGIN") - print_liste_field_titre($langs->trans("ServiceMargin"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - elseif ($conf->global->COMMISSION_BASE == "TURNOVER") - print_liste_field_titre($langs->trans("ServiceTurnover"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ServiceCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - // total commission - print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - print "</tr>\n"; - - $cumul_base_produit = 0; - $cumul_base_service = 0; - $cumul_commission_produit = 0; - $cumul_commission_service = 0; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); - if ($num > 0) - { - $var=True; - while ($i < $num && $i < $conf->liste_limit) - { - $objp = $db->fetch_object($result); - - $var=!$var; - - print "<tr $bc[$var]>"; - if ($agentid > 0) { - $companystatic->id=$objp->socid; - $companystatic->nom=$objp->nom; - $companystatic->client=$objp->client; - print "<td>".$companystatic->getNomUrl(1,'customer')."</td>\n"; - } - else { - $userstatic->id=$objp->agent; - $userstatic->login=$objp->login; - print "<td>".$userstatic->getLoginUrl(1)."</td>\n"; - } - - // product commission - $productCommissionRate=(! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0); - $productBase=(! empty($objp->productBase)?$objp->productBase:0); - $productCommission = (! empty($productBase)?($productCommissionRate * $productBase / 100):0); - print "<td align=\"right\">".price($productBase)."</td>\n"; - print "<td align=\"right\">".price($productCommissionRate)."</td>\n"; - print "<td align=\"right\">".price($productCommission)."</td>\n"; - - // service commission - $serviceCommissionRate=(! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0); - $serviceBase=(! empty($objp->serviceBase)?$objp->serviceBase:0); - $serviceCommission = (! empty($serviceBase)?($serviceCommissionRate * $serviceBase / 100):0); - print "<td align=\"right\">".price($serviceBase)."</td>\n"; - print "<td align=\"right\">".price($serviceCommissionRate)."</td>\n"; - print "<td align=\"right\">".price($serviceCommission)."</td>\n"; - - // total commission - print "<td align=\"right\">".price($productCommission + $serviceCommission)."</td>\n"; - print "</tr>\n"; - - $i++; - - $cumul_base_produit += round($productBase, $rounding); - $cumul_base_service += round($serviceBase, $rounding); - $cumul_commission_produit += round($productCommission, $rounding); - $cumul_commission_service += round($serviceCommission, $rounding); - } - } - - // affichage totaux commission - $var=!$var; - print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">'; - print '<td>'; - print $langs->trans('Total'); - print "</td>"; - // product commission - print "<td align=\"right\">".price($cumul_base_produit)."</td>\n"; - print "<td align=\"right\">".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."</td>\n"; - print "<td align=\"right\">".price($cumul_commission_produit)."</td>\n"; - // service commission - print "<td align=\"right\">".price($cumul_base_service)."</td>\n"; - print "<td align=\"right\">".price((! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0))."</td>\n"; - print "<td align=\"right\">".price($cumul_commission_service)."</td>\n"; - // total commission - print "<td align=\"right\">".price($cumul_commission_produit + $cumul_commission_service)."</td>\n"; - - print "</tr>\n"; - - print "</td>"; - print "</table>"; -} -else -{ - dol_print_error($db); -} -$db->free($result); - - -llxFooter(); -$db->close(); -?> -<script type="text/javascript"> -$(document).ready(function() { - - $("#agentid").change(function() { - $("div.fiche form").submit(); - }); - - $("#selIncluded").change(function() { - $("div.fiche form").submit(); - }); - - $("#totalBase").html("<?php echo price($cumul_base_produit + $cumul_base_service); ?>"); - $("#totalCommission").html("<?php echo price($cumul_commission_produit + $cumul_commission_service); ?>"); - -}); -</script> \ No newline at end of file diff --git a/htdocs/commissions/lib/commissions.lib.php b/htdocs/commissions/lib/commissions.lib.php deleted file mode 100644 index aa87720968c7c7253916bfeed9a590e069e6b396..0000000000000000000000000000000000000000 --- a/htdocs/commissions/lib/commissions.lib.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> - * - * 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/>. - */ - -/** - * \file /htdocs/commissions/lib/commissions.lib.php - * \ingroup commissions - * \brief Library for common commissions functions - */ - -/** - * Define head array for tabs of marges tools setup pages - * - * @return Array of head - */ -function commissions_admin_prepare_head() -{ - global $langs, $conf; - - $h = 0; - $head = array(); - - $head[$h][0] = DOL_URL_ROOT.'/commissions/admin/commissions.php'; - $head[$h][1] = $langs->trans("Parameters"); - $head[$h][2] = 'parameters'; - $h++; - - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin'); - - complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin','remove'); - - return $head; -} - -?> diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index b41fa735e7c72ff640af702a3931207dd7ab7ae1..4e168d0645f5c5c83563fa940f62c9414c58d6b5 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -336,7 +336,6 @@ class FactureRec extends Facture $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; $line->total_ttc = $objp->total_ttc; - $line->export_compta = $objp->fk_export_compta; $line->code_ventilation = $objp->fk_code_ventilation; $line->rang = $objp->rang; $line->special_code = $objp->special_code; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ace5e15312c56c770a1807e7ad8e5fd81edd50f3..f3427ee5d4bcd80014b3eb035bd34306b372fcbb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -455,7 +455,7 @@ class Facture extends CommonInvoice } } else if ($reshook < 0) $error++; - + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); @@ -866,7 +866,7 @@ class Facture extends CommonInvoice $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; - + // Retreive all extrafield for invoice // fetch optionals attributes and labels if(!class_exists('Extrafields')) @@ -925,7 +925,7 @@ class Facture extends CommonInvoice $sql.= ' l.localtax1_tx, l.localtax2_tx, l.remise, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' l.rang, l.special_code,'; $sql.= ' l.date_start as date_start, l.date_end as date_end,'; - $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_export_compta, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; + $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; @@ -970,7 +970,6 @@ class Facture extends CommonInvoice $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; - $line->export_compta = $objp->fk_export_compta; $line->code_ventilation = $objp->fk_code_ventilation; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); @@ -1860,7 +1859,7 @@ class Facture extends CommonInvoice } } } - + if ($error == 0) { $old_statut=$this->statut; @@ -1870,8 +1869,8 @@ class Facture extends CommonInvoice include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); $result=$interface->run_triggers('BILL_UNVALIDATE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; + if ($result < 0) { + $error++; $this->errors=$interface->errors; $this->statut=$old_statut; $this->brouillon=0; @@ -1881,7 +1880,7 @@ class Facture extends CommonInvoice $this->db->rollback(); return -1; } - + if ($error == 0) { $this->db->commit(); @@ -3196,7 +3195,6 @@ class FactureLigne var $total_ttc; var $fk_code_ventilation = 0; - var $fk_export_compta = 0; var $date_start; var $date_end; @@ -3237,7 +3235,7 @@ class FactureLigne $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; $sql.= ' fd.info_bits, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; - $sql.= ' fd.fk_code_ventilation, fd.fk_export_compta,'; + $sql.= ' fd.fk_code_ventilation,'; $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; @@ -3271,7 +3269,6 @@ class FactureLigne $this->total_localtax2 = $objp->total_localtax2; $this->total_ttc = $objp->total_ttc; $this->fk_code_ventilation = $objp->fk_code_ventilation; - $this->fk_export_compta = $objp->fk_export_compta; $this->rang = $objp->rang; $this->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); @@ -3338,7 +3335,7 @@ class FactureLigne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; $sql.= ' (fk_facture, fk_parent_line, label, description, qty, tva_tx, localtax1_tx, localtax2_tx,'; $sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; - $sql.= ' date_start, date_end, fk_code_ventilation, fk_export_compta, '; + $sql.= ' date_start, date_end, fk_code_ventilation, '; $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2)'; $sql.= " VALUES (".$this->fk_facture.","; @@ -3357,7 +3354,6 @@ class FactureLigne $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").","; $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").","; $sql.= ' '.$this->fk_code_ventilation.','; - $sql.= ' '.$this->fk_export_compta.','; $sql.= ' '.$this->rang.','; $sql.= ' '.$this->special_code.','; $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").','; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 553262a3b4b0b2ec82191eab55842387da2826e5..bc89cf7de7ed735bfc037a699c5d1e7d1bc5c683 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -43,6 +43,8 @@ if ($user->societe_id > 0) * View */ +$userstatic=new User($db); + llxHeader(); if ($socid > 0) @@ -135,7 +137,7 @@ if ($socid > 0) $var=!$var; print "<tr ".$bc[$var].">"; - print "<td align=\"center\">".dol_print_date($fac->date)."</td>\n"; + print "<td align=\"center\">".dol_print_date($fac->date,'day')."</td>\n"; print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id.'">'.img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."</a></td>\n"; print '<td aling="left">'.$fac->getLibStatut(2,$totalpaye).'</td>'; @@ -146,8 +148,12 @@ if ($socid > 0) print '<td align="right"> </td>'; print '<td align="right">'.price($solde)."</td>\n"; - // Auteur - print '<td nowrap="nowrap" width="50"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objf->userid.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objf->login.'</a></td>'; + // Author + $userstatic->id=$objf->userid; + $userstatic->login=$objf->login; + print '<td nowrap="nowrap" align="right">'; + print $userstatic->getLoginUrl(1); + print '</td>'; print "</tr>\n"; @@ -172,7 +178,7 @@ if ($socid > 0) $objp = $db->fetch_object($resqlp); //$var=!$var; print "<tr $bc[$var]>"; - print '<td align="center">'.dol_print_date($db->jdate($objp->dp))."</td>\n"; + print '<td align="center">'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n"; print '<td>'; print ' '; // Decalage print '<a href="paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$langs->trans("Payment").' '.$objp->rowid.'</td>'; @@ -182,8 +188,12 @@ if ($socid > 0) $solde = $solde - $objp->amount; print '<td align="right">'.price($solde)."</td>\n"; - // Auteur - print '<td nowrap="nowrap" width="50"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->userid.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>'; + // Author + $userstatic->id=$objp->userid; + $userstatic->login=$objp->login; + print '<td nowrap="nowrap" align="right">'; + print $userstatic->getLoginUrl(1); + print '</td>'; print '</tr>'; @@ -214,5 +224,4 @@ else llxFooter(); $db->close(); - ?> diff --git a/htdocs/compta/ventilation/fournisseur/index.php b/htdocs/compta/ventilation/fournisseur/index.php index c10bb23a05659739f35631284fb7f038079a9a4c..636891e7c180d0b6c157f6d8e5890f4065369c1f 100644 --- a/htdocs/compta/ventilation/fournisseur/index.php +++ b/htdocs/compta/ventilation/fournisseur/index.php @@ -39,7 +39,7 @@ print '<tr><td valign="top" width="30%">'; $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet"; -$sql .= " WHERE fk_export_compta = 0"; +$sql .= " WHERE fk_code_ventilation = 0"; $result = $db->query($sql); if ($result) { @@ -50,7 +50,7 @@ if ($result) } $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."paiement"; -$sql .= " WHERE fk_export_compta = 0"; +$sql .= " WHERE fk_code_ventilation = 0"; $result = $db->query($sql); if ($result) @@ -62,7 +62,7 @@ if ($result) } $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facture_fourn_det"; -$sql .= " WHERE fk_export_compta = 0"; +$sql .= " WHERE fk_code_ventilation = 0"; $result = $db->query($sql); if ($result) { @@ -73,7 +73,7 @@ if ($result) } /*$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."paiementfourn"; -$sql .= " WHERE fk_export_compta = 0"; +$sql .= " WHERE fk_code_ventilation = 0"; $result = $db->query($sql); if ($result) diff --git a/htdocs/compta/ventilation/lignes.php b/htdocs/compta/ventilation/lignes.php index e5cf6bc8edd05eb77b7b9e0e89cde855871e8fd2..c938e9774c4287f5fb4979dc731f02b3465ae7e5 100644 --- a/htdocs/compta/ventilation/lignes.php +++ b/htdocs/compta/ventilation/lignes.php @@ -48,7 +48,7 @@ if ($page < 0) $page = 0; $limit = $conf->liste_limit; $offset = $limit * $page ; -$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.fk_code_ventilation, c.intitule, c.numero,"; +$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, f.total_ttc as price, l.qty, l.rowid, l.tva_tx, l.fk_code_ventilation, c.intitule, c.numero,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c"; @@ -72,7 +72,7 @@ if ($result) $num_lignes = $db->num_rows($result); $i = 0; - print_barre_liste("Lignes de facture ventil�es",$page,"lignes.php","",$sortfield,$sortorder,'',$num_lignes); + print_barre_liste($langs->trans("InvoiceDispatched"),$page,"lignes.php","",$sortfield,$sortorder,'',$num_lignes); print '<form method="GET" action="lignes.php">'; print '<table class="noborder" width="100%">'; @@ -136,7 +136,7 @@ else print "</table></form>"; -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/compta/ventilation/liste.php b/htdocs/compta/ventilation/liste.php index 70679d3a38126704e2ca9950091fe6a1df5b7de1..81613640541ac4043406105c488c5879bf731bd9 100644 --- a/htdocs/compta/ventilation/liste.php +++ b/htdocs/compta/ventilation/liste.php @@ -54,7 +54,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; $limit = $conf->liste_limit; -$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price, l.rowid, l.fk_code_ventilation,"; +$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, f.total as price, l.rowid, l.fk_code_ventilation,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " , ".MAIN_DB_PREFIX."facturedet as l"; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index d005396d829f4b305993c2c3040ecd779f19dd05..398f30dd100a2ea2195b77e31fed99919f30d191 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -649,14 +649,16 @@ class Contrat extends CommonObject // Insert contract $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat,"; $sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; - $sql.= " ref, entity)"; + $sql.= " ref, entity, note, note_public)"; $sql.= " VALUES (".$this->db->idate($now).",".$this->socid.",".$user->id; $sql.= ",".$this->db->idate($this->date_contrat); $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); $sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL"); - $sql.= ",".($this->fk_projet>0?$this->fk_projet:"NULL"); + $sql.= ",".($this->fk_project>0?$this->fk_project:"NULL"); $sql.= ", ".(dol_strlen($this->ref)<=0 ? "null" : "'".$this->ref."'"); $sql.= ", ".$conf->entity; + $sql.= ", ".(!empty($this->note)?("'".$this->db->escape($this->note)."'"):"NULL"); + $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); $sql.= ")"; $resql=$this->db->query($sql); if ($resql) @@ -694,6 +696,12 @@ class Contrat extends CommonObject if (! $error) { + // Add linked object + if (! $error && $this->origin && $this->origin_id) + { + $ret = $this->add_object_linked(); + if (! $ret) dol_print_error($this->db); + } $this->db->commit(); return $this->id; } diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index ac56afab3cad8ea6a1731e0f26ff036299ce82cc..902dde79f17d59f2fe70b461ab4542fe5e3e370f 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -176,27 +176,158 @@ if ($action == 'add' && $user->rights->contrat->creer) if (! $error) { - $object->socid = $socid; + $object->socid = $socid; $object->date_contrat = $datecontrat; $object->commercial_suivi_id = GETPOST('commercial_suivi_id','int'); $object->commercial_signature_id = GETPOST('commercial_signature_id','int'); $object->note = GETPOST('note','alpha'); + $object->note_public = GETPOST('note_public','alpha'); $object->fk_project = GETPOST('projectid','int'); $object->remise_percent = GETPOST('remise_percent','alpha'); $object->ref = GETPOST('ref','alpha'); - $result = $object->create($user,$langs,$conf); - if ($result > 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else { - $mesg='<div class="error">'.$object->error.'</div>'; - } - $action='create'; + // If creation from another object of another module (Example: origin=propal, originid=1) + if ($_POST['origin'] && $_POST['originid']) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $_POST['origin']; + if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + + // For compatibility + if ($element == 'order') { $element = $subelement = 'commande'; } + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + + $object->origin = $_POST['origin']; + $object->origin_id = $_POST['originid']; + + // Possibility to add external linked objects with hooks + $object->linked_objects[$object->origin] = $object->origin_id; + if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) + { + $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + } + + $id = $object->create($user); + if ($id < 0) { + $mesg='<div class="error">'.$object->error.'</div>'; + } + + if ($id > 0) + { + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); + $result=$srcobject->fetch($object->origin_id); + if ($result > 0) + { + $srcobject->fetch_thirdparty(); + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); + + $fk_parent_line=0; + $num=count($lines); + + for ($i=0;$i<$num;$i++) + { + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + + if ($product_type == 1) { //only services + // service prédéfini + if ($lines[$i]->fk_product > 0) + { + $product_static = new Product($db); + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $prod = new Product($db, $lines[$i]->fk_product); + + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$srcobject->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; + } + else + { + $label = $lines[$i]->product_label; + } + + if ($conf->global->PRODUIT_DESC_IN_FORM) + $desc .= ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):''; + } + else { + $desc = dol_htmlentitiesbr($lines[$i]->desc); + } + + $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, + $date_start =0, + $date_end =0, + 'HT', + 0, + $lines[$i]->info_bits, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht + ); + + if ($result < 0) + { + $error++; + break; + } + + } + } + + } + else + { + $mesg=$srcobject->error; + $error++; + } + } + else + { + $mesg=$object->error; + $error++; + } + } + else + { + $result = $object->create($user,$langs,$conf); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + $mesg='<div class="error">'.$object->error.'</div>'; + } + $action='create'; + } } } @@ -622,6 +753,51 @@ if ($action == 'create') $soc = new Societe($db); if ($socid>0) $soc->fetch($socid); + if (GETPOST('origin') && GETPOST('originid')) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = GETPOST('origin'); + if (preg_match('/^([^_]+)_([^_]+)/i',GETPOST('origin'),$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + + if ($element == 'project') + { + $projectid=GETPOST('originid'); + } + else + { + // For compatibility + if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); + + $classname = ucfirst($subelement); + $objectsrc = new $classname($db); + $objectsrc->fetch(GETPOST('originid')); + if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines(); + $objectsrc->fetch_thirdparty(); + + $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + + $soc = $objectsrc->client; + + $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); + $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); + + // Object source contacts list + $srccontactslist = $objectsrc->liste_contact(-1,'external',1); + } + } + else { + $projectid = GETPOST('projectid','int'); + $note_private = GETPOST("note"); + $note_public = GETPOST("note_public"); + } + $object->date_contrat = dol_now(); $numct = $object->getNextNumRef($soc); @@ -687,18 +863,18 @@ if ($action == 'create') if (! empty($conf->projet->enabled)) { print '<tr><td>'.$langs->trans("Project").'</td><td>'; - select_projects($soc->id,GETPOST("projectid"),"projectid"); + select_projects($soc->id,$projectid,"projectid"); print "</td></tr>"; } print '<tr><td>'.$langs->trans("NotePublic").'</td><td valign="top">'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note_public', GETPOST('note_public'), '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, 70); + $doleditor=new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, 70); print $doleditor->Create(1); /* print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">'; - print GETPOST("note_public"); + print $note_public; print '</textarea></td></tr>'; */ @@ -706,11 +882,11 @@ if ($action == 'create') { print '<tr><td>'.$langs->trans("NotePrivate").'</td><td valign="top">'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', GETPOST('note'), '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, 70); + $doleditor=new DolEditor('note', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, 70); print $doleditor->Create(1); /* print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'; - print GETPOST("note"); + print $note_private; print '</textarea>';*/ print '</td></tr>'; } @@ -721,6 +897,12 @@ if ($action == 'create') print "</table>\n"; + if (is_object($objectsrc)) + { + print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; + print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; + } + print '<br><center><input type="submit" class="button" value="'.$langs->trans("Create").'"></center>'; print "</form>\n"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 26b8a0c58263007f71cc805117a3eb3e442123dd..9058350747fa3e7337e6e89a14af51a073382b79 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2141,7 +2141,7 @@ abstract class CommonObject $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate - $sql.=",".$attributeKey; + $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; foreach($this->array_options as $key => $value) @@ -2695,7 +2695,8 @@ abstract class CommonObject global $form,$bc,$bcdd; $element=$this->element; - $text=''; + + $text=''; $description=''; $type=0; // Show product and description $type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type); @@ -2703,27 +2704,25 @@ abstract class CommonObject if (! empty($line->date_start)) $type=1; // deprecated if (! empty($line->date_end)) $type=1; // deprecated - if ($line->fk_product > 0) - { - $product_static = new Product($this->db); - - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $text=$product_static->getNomUrl(1); - } - // Ligne en mode visu if ($action != 'editline' || $selected != $line->id) { - // Produit + // Product if ($line->fk_product > 0) { - // Define output language + $product_static = new Product($this->db); + + $product_static->type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $text=$product_static->getNomUrl(1); + + // Define output language (TODO Does this works ?) if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $this->fetch_thirdparty(); $prod = new Product($this->db); + $prod->fetch($line->fk_product); $outputlangs = $langs; $newlang=''; diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php new file mode 100644 index 0000000000000000000000000000000000000000..2acb83e3f05803040cd605f94eeb05f9bbaa384e --- /dev/null +++ b/htdocs/core/class/html.formcron.class.php @@ -0,0 +1,93 @@ +<?php +/* + * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> +* +* 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 2 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/>. +*/ + +/** + * \file cron/class/html.formcron.class.php +* \brief Fichier de la classe des fonctions predefinie de composants html cron +*/ + + +/** + * Class to manage building of HTML components +*/ +class FormCron extends Form +{ + var $db; + var $error; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + return 1; + } + + + /** + * Display On Off selector + * + * @param string $htmlname Html control name + * @param string $selected selected value + * @param string $readonly Select is read only or not + * @return string HTML select field + */ + function select_typejob($htmlname,$selected=0,$readonly=0) + { + global $langs; + + $langs->load('cron@cron'); + if (!empty($readonly)) { + if ($selected=='command') { + $out= $langs->trans('CronType_command'); + $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; + $out.= '<OPTION value="command" selected=\"selected\">'.$langs->trans('CronType_command').'</OPTION>'; + $out.='</SELECT>'; + } elseif ($selected=='method') { + $out= $langs->trans('CronType_method'); + $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; + $out.= '<OPTION value="method" selected=\"selected\">'.$langs->trans('CronType_method').'</OPTION>'; + $out.='</SELECT>'; + } + }else { + + $out='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" />'; + + if ($selected=='command') { + $selected_attr=' selected=\"selected\" '; + } else { + $selected_attr=''; + } + $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; + + if ($selected=='method') { + $selected_attr=' selected=\"selected\" '; + } else { + $selected_attr=''; + } + $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; + + $out.='</SELECT>'; + } + + return $out; + } +} diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 8ba3a161712265207a612162192ebe7e4046a319..f06e8027e5f5eab8d1907af3ca6541eaf2430213 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -90,6 +90,11 @@ function societe_prepare_head($object) $head[$h][2] = 'note'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Referers"); + $head[$h][2] = 'consumption'; + $h++; + // Attached files $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id; $head[$h][1] = $langs->trans("Documents"); diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php new file mode 100644 index 0000000000000000000000000000000000000000..abd85131e297b544faac56575e566528e4afd460 --- /dev/null +++ b/htdocs/core/lib/cron.lib.php @@ -0,0 +1,71 @@ +<?php +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry <florian.henry@opn-concept.pro> + * + * 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/>. + */ +/** + * \file cron/lib/cron.lib.php + * \brief Ensemble de fonctions de base pour le module jobs + * \ingroup jobs + */ + +/** + * Return array of tabs to used on pages for third parties cards. + * + * @param Object $object Object company shown + * @return array Array of tabs + */ + +function cronadmin_prepare_head() +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath('/cron/admin/cron.php', 1); + $head[$h][1] = $langs->trans("CronSetup"); + $head[$h][2] = 'setup'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cronadmin'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cronadmin', 'remove'); + + + return $head; +} + +function cron_prepare_head($object) +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath('/cron/card.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("CronTask"); + $head[$h][2] = 'card'; + $h++; + + $head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("CronInfoPage"); + $head[$h][2] = 'info'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove'); + + return $head; +} diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c07360abd109cc093db6879a421d1ad8269a73ed..64f415ac085083552bbbc76798dffdb912ee69f7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -805,17 +805,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // Compta simple - if (! empty($conf->comptabilite->enabled) && ! empty($conf->global->FACTURE_VENTILATION)) + if (! empty($conf->comptabilite->enabled) && ($conf->global->MAIN_FEATURES_LEVEL >= 2)) { $newmenu->add("/compta/ventilation/index.php?leftmenu=ventil",$langs->trans("Dispatch"),0,$user->rights->compta->ventilation->lire, '', $mainmenu, 'ventil'); if ($leftmenu=="ventil") $newmenu->add("/compta/ventilation/liste.php",$langs->trans("ToDispatch"),1,$user->rights->compta->ventilation->lire); if ($leftmenu=="ventil") $newmenu->add("/compta/ventilation/lignes.php",$langs->trans("Dispatched"),1,$user->rights->compta->ventilation->lire); - if ($leftmenu=="ventil") $newmenu->add("/compta/param/",$langs->trans("Setup"),1,$user->rights->compta->ventilation->parametrer); - if ($leftmenu=="ventil") $newmenu->add("/compta/param/comptes/fiche.php?action=create",$langs->trans("New"),2,$user->rights->compta->ventilation->parametrer); - if ($leftmenu=="ventil") $newmenu->add("/compta/param/comptes/liste.php",$langs->trans("List"),2,$user->rights->compta->ventilation->parametrer); - if ($leftmenu=="ventil") $newmenu->add("/compta/export/",$langs->trans("Export"),1,$user->rights->compta->ventilation->lire); - if ($leftmenu=="ventil") $newmenu->add("/compta/export/index.php?action=export",$langs->trans("New"),2,$user->rights->compta->ventilation->lire); - if ($leftmenu=="ventil") $newmenu->add("/compta/export/liste.php",$langs->trans("List"),2,$user->rights->compta->ventilation->lire); } // Compta expert diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php index 56e0d90fdb3bccf220e48a5a59f6c388f2a544b9..39c70faab796d06c490a4353e5dfaa822b702520 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php @@ -546,10 +546,10 @@ class pdf_expedition_merou extends ModelePdfExpedition $object->GetUrlTrackingStatus($object->tracking_number); if (! empty($object->tracking_url)) { - if ($object->expedition_method_id > 0) + if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); + $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code'); $label=$outputlangs->trans("SendingMethod".strtoupper($code))." :"; } else diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php index 172966b89cfa10140833ff38893c44840b84fb3f..368527612f10c72bc929092fe5c034a016fa8ee8 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php @@ -189,10 +189,10 @@ class pdf_expedition_rouget extends ModelePdfExpedition $object->GetUrlTrackingStatus($object->tracking_number); if (! empty($object->tracking_url)) { - if ($object->expedition_method_id > 0) + if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); + $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code'); $label=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; $label.=$outputlangs->trans("SendingMethod".strtoupper($code))." :"; $pdf->SetFont('','B', $default_font_size - 2); diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 1bae9f6112925af9e2b1f2cb4580ed671918d1e8..832d96a194b71af2fe14d20009fac59e25bd12c1 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -65,7 +65,7 @@ class modBanque extends DolibarrModules // Config pages //------------- - $this->config_page_url = array("bank.php@compta/bank"); + $this->config_page_url = array("bank.php"); // Dependancies $this->depends = array(); diff --git a/htdocs/core/modules/modCommissions.class.php b/htdocs/core/modules/modCommissions.class.php deleted file mode 100644 index 64908f5248c1ca381f979959da2a1d4866055b04..0000000000000000000000000000000000000000 --- a/htdocs/core/modules/modCommissions.class.php +++ /dev/null @@ -1,169 +0,0 @@ -<?php -/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> - * Copyright (C) 2012 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/>. - */ - -/** - * \defgroup commissions Module commissions - * \brief Module commissions - * \file htdocs/core/modules/modCommissions.class.php - * \ingroup commissions - * \brief Description and activation file for module Commissions - */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; - - -/** - * Class to describe modude Commisions - */ -class modCommissions extends DolibarrModules -{ - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 60000; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'Commissions'; - - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "financial"; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i','',get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Commissions management"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'experimental'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=other) - $this->special = 2; - // Name of png file (without png) used for this module. - // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. - $this->picto='commissions'; - - // Data directories to create when module is enabled. - $this->dirs = array(); - - // Config pages. Put here list of php page names stored in admmin directory used to setup module. - $this->config_page_url = array("commissions.php@commissions"); - - // Dependencies - $this->depends = array("modFacture", "modMargin"); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(5,1); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3,2); // Minimum version of Dolibarr required by module - $this->langfiles = array("commissions"); - - // Constants - $this->const = array(0=>array('COMMISSION_BASE',"chaine","TURNOVER",'Default commission base',0)); // List of particular constants to add when module is enabled - - // New pages on tabs - $this->tabs = array(); - - // Boxes - $this->boxes = array(); // List of boxes - $r=0; - - // Permissions - $this->rights = array(); // Permission array used by this module - $r=0; - - // Add here list of permission defined by an id, a label, a boolean and two constant strings. - // Example: - // $this->rights[$r][0] = 2000; // Permission id (must not be already used) - // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $r++; - - - // Main menu entries - $this->menu = array(); // List of menus to add - $r = 0; - - // left menu entry - $this->menu[$r]=array( - 'fk_menu'=>'fk_mainmenu=accountancy', // Put 0 if this is a top menu - 'type'=>'left', // This is a Top menu entry - 'titre'=>'Commissions', - 'mainmenu'=>'accountancy', - 'leftmenu'=>'commissions', // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school). - 'url'=>'/commissions/index.php', - 'langs'=>'commissions', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>200, - 'enabled'=>'$conf->commissions->enabled', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - $r++; - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories. - * - * @return int 1 if OK, 0 if KO - */ - function init() - { - $sql = array(); - - $result=$this->load_tables(); - - return $this->_init($sql); - } - - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted. - * - * @return int 1 if OK, 0 if KO - */ - function remove() - { - $sql = array(); - - return $this->_remove($sql); - } - - - /** - * Create tables and keys required by module - * Files mymodule.sql and mymodule.key.sql with create table and create keys - * commands must be stored in directory /mymodule/sql/ - * This function is called by this->init. - * - * @return int <=0 if KO, >0 if OK - */ - function load_tables() - { - return; - } -} - -?> diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index fbc14945f0298f3d27f3bbfed4dba73a715f70a5..53d9afabf3036849b026f70c3abc32c3b7d0cf5f 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -1,5 +1,6 @@ <?php -/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * * 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 @@ -16,11 +17,11 @@ */ /** - * \defgroup webservices Module webservices - * \brief Module to enable the Dolibarr server of web services - * \file htdocs/core/modules/modCron.class.php - * \ingroup cron - * \brief File to describe cron module + * \defgroup cron Module cron + * \brief cron module descriptor. + * \file cron/core/modules/modCron.class.php + * \ingroup cron + * \brief Description and activation file for module Jobs */ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; @@ -65,11 +66,20 @@ class modCron extends DolibarrModules //------------- $this->depends = array(); $this->requiredby = array(); - $this->langfiles = array("cron"); + $this->langfiles = array("cron@cron"); // Constantes //----------- - $this->const = array(); + $this->const = array( + 0=>array( + 'MAIN_CRON_KEY', + 'chaine', + '', + 'CRON KEY', + 0, + 'main', + 0 + ),); // New pages on tabs // ----------------- @@ -79,25 +89,60 @@ class modCron extends DolibarrModules //------ $this->boxes = array(); - // Permissions - //------------ - $this->rights = array(); - $this->rights_class = 'cron'; - $r=0; + // Permissions + $this->rights = array(); // Permission array used by this module + $this->rights_class = 'cron'; + $r=0; + + $this->rights[$r][0] = 23001; + $this->rights[$r][1] = 'Read cron jobs'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'read'; + $r++; + + $this->rights[$r][0] = 23002; + $this->rights[$r][1] = 'Create cron Jobs'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'create'; + $r++; + + $this->rights[$r][0] = 23003; + $this->rights[$r][1] = 'Delete cron Jobs'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'delete'; + $r++; + + $this->rights[$r][0] = 23004; + $this->rights[$r][1] = 'Execute cron Jobs'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'execute'; + $r++; // Main menu entries $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry - 'titre'=>'CronJobs', - 'url'=>'/cron/index.php', - 'langs'=>'cron@cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100, + 'titre'=>'CronListActive', + 'url'=>'/cron/list.php?status=1', + 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>200, 'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->admin', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; + + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'CronListInactive', + 'url'=>'/cron/list.php?status=0', + 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>201, + 'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + $r++; } @@ -114,8 +159,6 @@ class modCron extends DolibarrModules // Prevent pb of modules not correctly disabled //$this->remove($options); - $sql = array(); - return $this->_init($sql,$options); } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index abaef7a191084ad2f47468f338ae72caaa22b70d..051f4f98071ea57236d576aa9fddc79d292c7561 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -16,6 +16,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * + * To use this template, the following var must be defined + * $type, $text, $description, $line */ ?> @@ -38,59 +40,59 @@ <?php if ($line->description) { - if ($line->description == '(CREDIT_NOTE)') - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); - } - elseif ($line->description == '(DEPOSIT)') - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); - // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; - } - else - { - echo ($txt?' - ':'').dol_htmlentitiesbr($line->description); - } + if ($line->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($line->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); + } + elseif ($line->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($line->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); + // Add date of deposit + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; + } + else + { + echo ($txt?' - ':'').dol_htmlentitiesbr($line->description); } } - else - { - if ($line->fk_product > 0) { + } + else + { + if ($line->fk_product > 0) { - echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); + echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); - // Show range - print_date_range($line->date_start, $line->date_end); + // Show range + echo get_date_range($line->date_start, $line->date_end); - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):''; - } - - } else { + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):''; + } - if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + } else { - if (! empty($line->label)) { - $text.= ' <strong>'.$line->label.'</strong>'; - echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); - } else { - echo $text.' '.dol_htmlentitiesbr($line->description); - } + if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); - // Show range - print_date_range($line->date_start,$line->date_end); + if (! empty($line->label)) { + $text.= ' <strong>'.$line->label.'</strong>'; + echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); + } else { + echo $text.' '.dol_htmlentitiesbr($line->description); } + + // Show range + echo get_date_range($line->date_start,$line->date_end); } - ?> + } + ?> </td> <td align="right" nowrap="nowrap"><?php echo vatrate($line->tva_tx,'%',$line->info_bits); ?></td> diff --git a/htdocs/cron/admin/cron.php b/htdocs/cron/admin/cron.php index fd77bcc68514381a10896ad55d083c961d412ae2..894e9dc44575c454c4d5577fd1376ec97ea0b9b2 100644 --- a/htdocs/cron/admin/cron.php +++ b/htdocs/cron/admin/cron.php @@ -1,34 +1,36 @@ <?php /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.org> - * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.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 - * 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/>. - */ +* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> +* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com> +* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> +* +* 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/>. +*/ /** - * \file htdocs/cron/admin/cron.php - * \ingroup cron - * \brief Page to setup cron module - */ + * \file cron/admin/cron.php +* \ingroup cron +*/ -require '../../main.inc.php'; +// Dolibarr environment +$res = @include("../../main.inc.php"); // From htdocs directory require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; -$langs->load("admin"); -$langs->load("cron"); +$langs->load("admin"); +$langs->load("cron"); if (! $user->admin) accessforbidden(); @@ -36,37 +38,40 @@ if (! $user->admin) $actionsave=GETPOST("save"); // Sauvegardes parametres -if ($actionsave) +if (!empty($actionsave)) { - $i=0; - - $db->begin(); - - $i+=dolibarr_set_const($db,'CRON_KEY',trim(GETPOST("CRON_KEY")),'chaine',0,'',$conf->entity); - - if ($i >= 1) - { - $db->commit(); - setEventMessage($langs->trans("SetupSaved")); - } - else - { - $db->rollback(); - setEventMessage($langs->trans("Error"), 'errors'); - } + $i=0; + + $db->begin(); + + $i+=dolibarr_set_const($db,'MAIN_CRON_KEY',trim(GETPOST("MAIN_CRON_KEY")),'chaine',0,'',0); + + if ($i >= 1) + { + $db->commit(); + setEventMessage($langs->trans("SetupSaved")); + } + else + { + $db->rollback(); + setEventMessage($langs->trans("Error"), 'errors'); + } } /* * View - */ +*/ llxHeader(); $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; print_fiche_titre($langs->trans("CronSetup"),$linkback,'setup'); -print $langs->trans("CronDesc")."<br>\n"; +// Configuration header +$head = cronadmin_prepare_head(); +dol_fiche_head($head,'setup',$langs->trans("Module2300Name"),0,'cron'); + print "<br>\n"; print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">'; @@ -76,13 +81,12 @@ print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print "<td>".$langs->trans("Parameter")."</td>"; print "<td>".$langs->trans("Value")."</td>"; -//print "<td>".$langs->trans("Examples")."</td>"; print "<td> </td>"; print "</tr>"; print '<tr class="impair">'; print '<td class="fieldrequired">'.$langs->trans("KeyForCronAccess").'</td>'; -print '<td><input type="text" class="flat" id="CRON_KEY" name="CRON_KEY" value="'. (GETPOST('CRON_KEY')?GETPOST('CRON_KEY'):(! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'')) . '" size="40">'; +print '<td><input type="text" class="flat" id="MAIN_CRON_KEY" name="MAIN_CRON_KEY" value="'. (GETPOST('MAIN_CRON_KEY')?GETPOST('MAIN_CRON_KEY'):(! empty($conf->global->MAIN_CRON_KEY)?$conf->global->MAIN_CRON_KEY:'')) . '" size="40">'; if (! empty($conf->use_javascript_ajax)) print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); print '</td>'; @@ -102,12 +106,35 @@ print '<br><br>'; // Cron launch print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>'; -$url=DOL_MAIN_URL_ROOT.'/public/cron/cron_run_jobs.php'.(empty($conf->global->CRON_KEY)?'':'?securitykey='.$conf->global->CRON_KEY); +$url=dol_buildpath('/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>'; -$url=DOL_MAIN_URL_ROOT.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'id=cronjobid'; -print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; +$url=dol_buildpath('/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; +print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print '<br>'; +print '<br>'; + + +$linuxlike=1; +if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; +if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; + +if ($linuxlike) { + print $langs->trans("CronExplainHowToRunUnix"); +} else { + print $langs->trans("CronExplainHowToRunWin"); +} +print '<br>'; +print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>'; +$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->MAIN_CRON_KEY)?'securitykey':''.$conf->global->MAIN_CRON_KEY.'').' '.$user->login.' cronjobid(optionnal)'; +if ($linuxlike) { + print 'user@host:'.DOL_DOCUMENT_ROOT.'$ php ..'.$file."<br>\n"; +} else { + print DOL_DOCUMENT_ROOT.'> php ..'.$file."<br>\n"; +} +print '<br>'; + + print '<br>'; @@ -116,20 +143,18 @@ if (! empty($conf->use_javascript_ajax)) { print "\n".'<script type="text/javascript">'; print '$(document).ready(function () { - $("#generate_token").click(function() { - $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", { - action: \'getrandompassword\', - generic: true - }, - function(token) { - $("#CRON_KEY").val(token); - }); - }); - });'; + $("#generate_token").click(function() { + $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", { + action: \'getrandompassword\', + generic: true +}, + function(token) { + $("#MAIN_CRON_KEY").val(token); +}); +}); +});'; print '</script>'; } - llxFooter(); -$db->close(); -?> +$db->close(); \ No newline at end of file diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php new file mode 100644 index 0000000000000000000000000000000000000000..bd6ffb0e5c9ef3ccc2e0d1c53a0356ec96323bee --- /dev/null +++ b/htdocs/cron/card.php @@ -0,0 +1,596 @@ +<?php +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry <florian.henry@open-concpt.pro> + * +* 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/>. +*/ + +/** + * \file cron/card.php + * \ingroup cron + * \brief Cron Jobs Card + */ + +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + +// librairie jobs +require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formcron.class.php"; +require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; + + +$langs->load("admin"); +$langs->load("cron"); + +if (!$user->rights->cron->create) accessforbidden(); + +$id=GETPOST('id','int'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$cancel=GETPOST('cancel'); + +$object = new Cronjob($db); +if (!empty($id)) { + $result=$object->fetch($id); + if ($result < 0) { + setEventMessage($object->error,'errors'); + } +} + +if(!empty($cancel)) { + if (!empty($id)) { + $action=''; + }else { + Header ( "Location: ".dol_buildpath('/cron/cron/list.php',1).'?status=1'); + } + +} + +// Delete jobs +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete){ + + + $result = $object->delete($user); + + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='edit'; + }else { + Header ( "Location: ".dol_buildpath('/cron/cron/list.php',1).'?status=1'); + } +} + +// Execute jobs +if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute){ + + $result=$object->run_jobs($user->login); + + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action=''; + }else { + $action=''; + } + +} + + +if ($action=='add') { + + $object->jobtype=GETPOST('jobtype','alpha'); + $object->label=GETPOST('label','alpha'); + $object->command=GETPOST('command','alpha'); + $object->priority=GETPOST('priority','int'); + $object->classesname=GETPOST('classesname','alpha'); + $object->objectname=GETPOST('objectname','alpha'); + $object->methodename=GETPOST('methodename','alpha'); + $object->params=GETPOST('params'); + $object->md5params=GETPOST('md5params'); + $object->module_name=GETPOST('module_name','alpha'); + $object->note=GETPOST('note'); + $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); + $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); + $object->unitfrequency=GETPOST('unitfrequency','int'); + $object->frequency=$object->unitfrequency * GETPOST('nbfrequency','int'); + + //Ajout de la tache cron + $result = $object->create($user); + + // test du Resultat de la requete + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='create'; + } + else { + setEventMessage($langs->trans('CronSaveSucess'),'mesgs'); + $action=''; + } +} + +// Save parameters +if ($action=='update') { + $object->id=$id; + $object->jobtype=GETPOST('jobtype','alpha'); + $object->label=GETPOST('label','alpha'); + $object->command=GETPOST('command','alpha'); + $object->classesname=GETPOST('classesname','alpha'); + $object->priority=GETPOST('priority','int'); + $object->objectname=GETPOST('objectname','alpha'); + $object->methodename=GETPOST('methodename','alpha'); + $object->params=GETPOST('params'); + $object->md5params=GETPOST('md5params'); + $object->module_name=GETPOST('module_name','alpha'); + $object->note=GETPOST('note'); + $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); + $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); + $object->unitfrequency=GETPOST('unitfrequency','int'); + $object->frequency=$object->unitfrequency * GETPOST('nbfrequency','int'); + + //Ajout de la tache cron + $result = $object->update($user); + + // test du Resultat de la requete + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='edit'; + } + else { + setEventMessage($langs->trans('CronSaveSucess'),'mesgs'); + $action=''; + } +} + +if ($action=='activate') { + $object->status=1; + + //Ajout de la tache cron + $result = $object->update($user); + + // test du Resultat de la requete + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='edit'; + } + else { + setEventMessage($langs->trans('CronSaveSucess'),'mesgs'); + $action=''; + } +} + +if ($action=='inactive') { + $object->status=0; + //Ajout de la tache cron + $result = $object->update($user); + + // test du Resultat de la requete + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='edit'; + } + else { + setEventMessage($langs->trans('CronSaveSucess'),'mesgs'); + $action=''; + } +} + + +/* + * View +*/ + +llxHeader('',$langs->trans("CronAdd")); + +if ($action=='edit' || empty($action) || $action=='delete' || $action=='execute') { + $head=cron_prepare_head($object); + dol_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'bill'); +} elseif ($action=='create') { + print_fiche_titre($langs->trans("CronTask"),'','setup'); +} + +if ($conf->use_javascript_ajax) +{ + print "\n".'<script type="text/javascript" language="javascript">'; + print 'jQuery(document).ready(function () { + function initfields() + { + if ($("#jobtype option:selected").val()==\'method\') { + $(".blockmethod").show(); + $(".blockcommand").hide(); + } + if ($("#jobtype option:selected").val()==\'command\') { + $(".blockmethod").hide(); + $(".blockcommand").show(); + } + } + initfields(); + jQuery("#jobtype").change(function() { + initfields(); + }); + })'; + print '</script>'."\n"; +} + +$form = new Form($db); +$formCron = new FormCron($db); + +if ($action == 'delete') +{ + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CronDelete"),$langs->trans("CronConfirmDelete"),"confirm_delete",'','',1); + if ($ret == 'html') print '<br>'; + $action=''; +} + +if ($action == 'execute'){ + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1); + if ($ret == 'html') print '<br>'; + $action=''; +} + + + +/* + * Create Template +*/ + +if (empty($object->status)) { + dol_htmloutput_mesg($langs->trans("CronTaskInactive"),'','warning',1); +} + +if (($action=="create") || ($action=="edit")) { + + print '<form name="cronform" action="'.$_SERVER["PHP_SELF"].'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n"; + if (!empty($object->id)) { + print '<input type="hidden" name="action" value="update">'."\n"; + print '<input type="hidden" name="id" value="'.$object->id.'">'."\n"; + } else { + print '<input type="hidden" name="action" value="add">'."\n"; + } + + print '<table class="border" width="100%">'; + + print '<tr><td width="30%">'; + print $langs->trans('CronLabel')."</td>"; + print "<td><input type=\"text\" size=\"20\" name=\"label\" value=\"".$object->label."\" /> "; + print "</td>"; + print "<td>"; + print "</td>"; + print "</tr>\n"; + + print "<tr><td>"; + print $langs->trans('CronType')."</td><td>"; + print $formCron->select_typejob('jobtype',$object->jobtype); + print "</td>"; + print "<td>"; + print "</td>"; + print "</tr>\n"; + + print "<tr><td>"; + print $langs->trans('CronHourStart')."</td><td>"; + if(!empty($object->datestart)){ + $form->select_date($object->datestart,'datestart',1,1,'',"cronform"); + } + else{ + $form->select_date(dol_now(),'datestart',1,1,'',"cronform"); + } + print "</td>"; + print "<td>"; + print "</td>"; + print "</tr>\n"; + + print "<tr><td>"; + print $langs->trans('CronDtEnd')."</td><td>"; + if(!empty($object->dateend)){ + $form->select_date($object->dateend,'dateend',1,1,'',"cronform"); + } + else{ + $form->select_date('','dateend',1,1,1,"cronform"); + } + print "</td>"; + print "<td>"; + print "</td>"; + print "</tr>\n"; + + print "<tr><td>"; + print $langs->trans('CronPriority')."</td>"; + $priority=0; + if (!empty($object->priority)) { + $priority=$object->priority; + } + print "<td><input type=\"text\" size=\"2\" name=\"priority\" value=\"".$priority."\" /> "; + print "</td>"; + print "<td>"; + print "</td>"; + print "</tr>\n"; + + print "<tr><td>"; + print $langs->trans('CronEvery')."</td>"; + print "<td><select name=\"nbfrequency\">"; + for($i=1; $i<=60; $i++){ + if(($object->frequency/$object->unitfrequency) == $i){ + print "<option value='".$i."' selected='selected'>".$i."</option>"; + } + else{ + print "<option value='".$i."'>".$i."</option>"; + } + } + $input = "<input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" "; + if($object->unitfrequency=="60"){ + $input .= ' checked="checked" />'; + } + else{ + $input .= ' />'; + } + $input .= "<label for=\"frequency_minute\">".$langs->trans('Minutes')."</label>"; + print $input; + + $input = "<input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" "; + if($object->unitfrequency=="3600"){ + $input .= ' checked="checked" />'; + } + else{ + $input .= ' />'; + } + $input .= "<label for=\"frequency_heures\">".$langs->trans('Hours')."</label>"; + print $input; + + $input = "<input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" "; + if($object->unitfrequency=="86400"){ + $input .= ' checked="checked" />'; + } + else{ + $input .= ' />'; + } + $input .= "<label for=\"frequency_jours\">".$langs->trans('Days')."</label>"; + print $input; + + $input = "<input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" "; + if($object->unitfrequency=="604800"){ + $input .= ' checked="checked" />'; + } + else{ + $input .= ' />'; + } + $input .= "<label for=\"frequency_semaine\">".$langs->trans('Weeks')."</label>"; + print $input; + print "</td>"; + print "<td>"; + print "</td>"; + print "</tr>\n"; + + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronModule')."</td><td>"; + print "<input type=\"text\" size=\"20\" name=\"module_name\" value=\"".$object->module_name."\" /> "; + print "</td>"; + print "<td>"; + print $form->textwithpicto('',$langs->trans("CronModuleHelp"),1,'help'); + print "</td>"; + print "</tr>\n"; + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronClassFile')."</td><td>"; + print "<input type=\"text\" size=\"20\" name=\"classesname\" value=\"".$object->classesname."\" /> "; + print "</td>"; + print "<td>"; + print $form->textwithpicto('',$langs->trans("CronClassFileHelp"),1,'help'); + print "</td>"; + print "</tr>\n"; + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronObject')."</td><td>"; + print "<input type=\"text\" size=\"20\" name=\"objectname\" value=\"".$object->objectname."\" /> "; + print "</td>"; + print "<td>"; + print $form->textwithpicto('',$langs->trans("CronObjectHelp"),1,'help'); + print "</td>"; + print "</tr>\n"; + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronMethod')."</td><td>"; + print "<input type=\"text\" size=\"20\" name=\"methodename\" value=\"".$object->methodename."\" /> "; + print "</td>"; + print "<td>"; + print $form->textwithpicto('',$langs->trans("CronMethodHelp"),1,'help'); + print "</td>"; + print "</tr>\n"; + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronArgs')."</td><td>"; + print "<input type=\"text\" size=\"20\" name=\"params\" value=\"".$object->params."\" /> "; + print "</td>"; + print "<td>"; + print $form->textwithpicto('',$langs->trans("CronArgsHelp"),1,'help'); + print "</td>"; + print "</tr>\n"; + + print '<tr class="blockcommand"><td>'; + print $langs->trans('CronCommand')."</td><td>"; + print "<input type=\"text\" size=\"50\" name=\"command\" value=\"".$object->command."\" /> "; + print "</td>"; + print "<td>"; + print $form->textwithpicto('',$langs->trans("CronCommandHelp"),1,'help'); + print "</td>"; + print "</tr>\n"; + + print '<tr><td>'; + print $langs->trans('CronNote')."</td><td>"; + $doleditor = new DolEditor('note', $object->note, '', 160, 'dolibarr_notes', 'In', true, false, 0, 4, 90); + $doleditor->Create(); + print "</td>"; + print "<td>"; + print "</td>"; + print "</tr>\n"; + + + print '<tr><td colspan="2" align="center">'; + print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">"; + print "<input type=\"submit\" name=\"cancel\" class=\"button\" value=\"".$langs->trans("Cancel")."\">"; + print "</td>"; + print "<td>"; + print "</td>"; + print "</tr>\n"; + + print '</table>'; + + print "</form>\n"; + +}else { + + /* + * view Template + */ + + // box add_jobs_box + print '<table class="border" width="100%">'; + + print '<tr><td width="30%">'; + print $langs->trans('CronId')."</td>"; + print "<td>".$form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'id'); + print "</td></tr>\n"; + + print '<tr><td>'; + print $langs->trans('CronLabel')."</td>"; + print "<td>".$object->label; + print "</td></tr>"; + + print "<tr><td>"; + print $langs->trans('CronType')."</td><td>"; + print $formCron->select_typejob('jobtype',$object->jobtype,1); + print "</td></tr>"; + + print "<tr><td>"; + print $langs->trans('CronHourStart')."</td><td>"; + if(!empty($object->datestart)) {print dol_print_date($object->datestart,'dayhourtext');} else {print $langs->trans('CronNone');} + print "</td></tr>"; + + print "<tr><td>"; + print $langs->trans('CronDtEnd')."</td><td>"; + if(!empty($object->dateend)) {print dol_print_date($object->dateend,'dayhourtext');} else {print $langs->trans('CronNone');} + print "</td></tr>"; + + print "<tr><td>"; + print $langs->trans('CronPriority')."</td>"; + print "<td>".$object->priority; + print "</td></tr>"; + + print "<tr><td>"; + print $langs->trans('CronNbRun')."</td>"; + print "<td>".$object->nbrun; + print "</td></tr>"; + + print "<tr><td>"; + print $langs->trans('CronEvery')."</td>"; + print "<td>"; + if($object->unitfrequency == "60") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Minutes'); + if($object->unitfrequency == "3600") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Hours'); + if($object->unitfrequency == "86400") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Days'); + if($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Weeks'); + print "</td></tr>"; + + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronModule')."</td><td>"; + print $object->module_name; + print "</td></tr>"; + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronClassFile')."</td><td>"; + print $object->classesname; + print "</td></tr>"; + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronObject')."</td><td>"; + print $object->objectname; + print "</td></tr>"; + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronMethod')."</td><td>"; + print $object->methodename; + print "</td></tr>"; + + print '<tr class="blockmethod"><td>'; + print $langs->trans('CronArgs')."</td><td>"; + print $object->params; + print "</td></tr>"; + + print '<tr class="blockcommand"><td>'; + print $langs->trans('CronCommand')."</td><td>"; + print $object->command; + print "</td></tr>"; + + print '<tr><td>'; + print $langs->trans('CronNote')."</td><td>"; + print $object->note; + print "</td></tr>"; + + print '<tr><td>'; + print $langs->trans('CronDtLastLaunch')."</td><td>"; + if(!empty($object->datelastrun)) {print dol_print_date($object->datelastrun,'dayhourtext');} else {print $langs->trans('CronNone');} + print "</td></tr>"; + + print '<tr><td>'; + print $langs->trans('CronDtNextLaunch')."</td><td>"; + if(!empty($object->datenextrun)) {print dol_print_date($object->datenextrun,'dayhourtext');} else {print $langs->trans('CronNone');} + print "</td></tr>"; + + print '<tr><td>'; + print $langs->trans('CronDtLastResult')."</td><td>"; + if(!empty($object->datelastresult)) {print dol_print_date($object->datelastresult,'dayhourtext');} else {print $langs->trans('CronNone');} + print "</td></tr>"; + + print '<tr><td>'; + print $langs->trans('CronLastResult')."</td><td>"; + print $object->lastresult; + print "</td></tr>"; + + print '<tr><td>'; + print $langs->trans('CronLastOutput')."</td><td>"; + print nl2br($object->lastoutput); + print "</td></tr>"; + + print '</table>'; + + print "\n\n<div class=\"tabsAction\">\n"; + if (! $user->rights->cron->create) { + print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Edit").'</a>'; + } else { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'">'.$langs->trans("Edit").'</a>'; + } + if (! $user->rights->cron->delete) { + print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Delete").'</a>'; + } else { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$object->id.'">'.$langs->trans("Delete").'</a>'; + } + if (! $user->rights->cron->create) { + print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("CronStatusActiveBtn").'/'.$langs->trans("CronStatusInactiveBtn").'</a>'; + } else { + if (empty($object->status)) { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=activate&id='.$object->id.'">'.$langs->trans("CronStatusActiveBtn").'</a>'; + } else { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=inactive&id='.$object->id.'">'.$langs->trans("CronStatusInactiveBtn").'</a>'; + } + } + if ((! $user->rights->cron->execute) || (empty($object->status))) { + print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("CronExecute").'</a>'; + } else { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=execute&id='.$object->id.'">'.$langs->trans("CronExecute").'</a>'; + } + print '<br><br></div>'; +} + +$db->close(); +llxFooter(); \ No newline at end of file diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index b2b5fcddd1ae1f6da2d376a9be8f4278881a8f32..b24055c6f3d3929e3733cc81940c91f510ed63fb 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * * 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 @@ -17,42 +17,58 @@ */ /** - * \file dev/skeletons/cronjob.class.php + * \file cron/class/cronjob.class.php * \ingroup cron - * \brief CRUD class file (Create/Read/Update/Delete) for cronjob table - * Initialy built by build_class_from_table on 2013-03-17 18:50 */ // Put here all includes required by your class file require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); -//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); -//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); /** - * Put here description of your class + * Crob Job class */ class Cronjob extends CommonObject { var $db; //!< To store db handler var $error; //!< To return error code (or message) var $errors=array(); //!< To return several error codes (or messages) - var $element='cronjob'; //!< Id that identify managed objects + var $element='cronjob'; //!< Id that identify managed objects var $table_element='cronjob'; //!< Name of table without prefix where object is stored var $id; - + + var $ref; //Use for prevnext_ref + var $jobtype; var $tms=''; var $datec=''; + var $label; var $command; + var $classesname; + var $objectname; + var $methodename; var $params; + var $md5params; + var $module_name; + var $priority; var $datelastrun=''; - var $lastresult=''; + var $datenextrun=''; + var $dateend=''; + var $datestart=''; + var $datelastresult=''; + var $lastresult; var $lastoutput; - var $fk_user; + var $unitfrequency; + var $frequency; + var $status; + var $fk_user_author; + var $fk_user_mod; var $note; + var $nbrun; + + var $lines; - + /** @@ -80,51 +96,128 @@ class Cronjob extends CommonObject $error=0; // Clean parameters - + + if (isset($this->label)) $this->label=trim($this->label); + if (isset($this->jobtype)) $this->jobtype=trim($this->jobtype); if (isset($this->command)) $this->command=trim($this->command); + if (isset($this->classesname)) $this->classesname=trim($this->classesname); + if (isset($this->objectname)) $this->objectname=trim($this->objectname); + if (isset($this->methodename)) $this->methodename=trim($this->methodename); if (isset($this->params)) $this->params=trim($this->params); + if (isset($this->md5params)) $this->md5params=trim($this->md5params); + if (isset($this->module_name)) $this->module_name=trim($this->module_name); + if (isset($this->priority)) $this->priority=trim($this->priority); if (isset($this->lastoutput)) $this->lastoutput=trim($this->lastoutput); - if (isset($this->fk_user)) $this->fk_user=trim($this->fk_user); + if (isset($this->lastresult)) $this->lastresult=trim($this->lastresult); + if (isset($this->unitfrequency)) $this->unitfrequency=trim($this->unitfrequency); + if (isset($this->frequency)) $this->frequency=trim($this->frequency); + if (isset($this->status)) $this->status=trim($this->status); if (isset($this->note)) $this->note=trim($this->note); - - + if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun); // Check parameters - // Put here code to add control on parameters values + // Put here code to add a control on parameters values + if (dol_strlen($this->datestart)==0) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronDtStart')); + $error++; + } + if (empty($this->label)) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLabel')); + $error++; + } + if ((dol_strlen($this->datestart)!=0) && (dol_strlen($this->dateend)!=0) && ($this->dateend<$this->datestart)) { + $this->errors[]=$langs->trans('CronErrEndDateStartDt'); + $error++; + } + if (empty($this->unitfrequency)) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronFrequency')); + $error++; + } + if (($this->jobtype=='command') && (empty($this->command))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronCommand')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->classesname))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronClass')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->methodename))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronMethod')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->objectname))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronObject')); + $error++; + } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob("; - + $sql.= "datec,"; + $sql.= "jobtype,"; + $sql.= "label,"; $sql.= "command,"; + $sql.= "classesname,"; + $sql.= "objectname,"; + $sql.= "methodename,"; $sql.= "params,"; + $sql.= "md5params,"; + $sql.= "module_name,"; + $sql.= "priority,"; $sql.= "datelastrun,"; + $sql.= "datenextrun,"; + $sql.= "dateend,"; + $sql.= "datestart,"; $sql.= "lastresult,"; + $sql.= "datelastresult,"; $sql.= "lastoutput,"; - $sql.= "fk_user,"; - $sql.= "note"; - - + $sql.= "unitfrequency,"; + $sql.= "frequency,"; + $sql.= "status,"; + $sql.= "fk_user_author,"; + $sql.= "fk_user_mod,"; + $sql.= "note,"; + $sql.= "nbrun"; + + $sql.= ") VALUES ("; - - $sql.= " ".(! isset($this->datec) || dol_strlen($this->datec)==0?'NULL':$this->db->idate($this->datec)).","; + + $sql.= " ".$this->db->idate(dol_now()).","; + $sql.= " ".(! isset($this->jobtype)?'NULL':"'".$this->db->escape($this->jobtype)."'").","; + $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; $sql.= " ".(! isset($this->command)?'NULL':"'".$this->db->escape($this->command)."'").","; + $sql.= " ".(! isset($this->classesname)?'NULL':"'".$this->db->escape($this->classesname)."'").","; + $sql.= " ".(! isset($this->objectname)?'NULL':"'".$this->db->escape($this->objectname)."'").","; + $sql.= " ".(! isset($this->methodename)?'NULL':"'".$this->db->escape($this->methodename)."'").","; $sql.= " ".(! isset($this->params)?'NULL':"'".$this->db->escape($this->params)."'").","; + $sql.= " ".(! isset($this->md5params)?'NULL':"'".$this->db->escape($this->md5params)."'").","; + $sql.= " ".(! isset($this->module_name)?'NULL':"'".$this->db->escape($this->module_name)."'").","; + $sql.= " ".(! isset($this->priority)?'NULL':"'".$this->priority."'").","; $sql.= " ".(! isset($this->datelastrun) || dol_strlen($this->datelastrun)==0?'NULL':$this->db->idate($this->datelastrun)).","; - $sql.= " ".(! isset($this->lastresult) || dol_strlen($this->lastresult)==0?'NULL':$this->db->idate($this->lastresult)).","; + $sql.= " ".(! isset($this->datenextrun) || dol_strlen($this->datenextrun)==0?'NULL':$this->db->idate($this->datenextrun)).","; + $sql.= " ".(! isset($this->dateend) || dol_strlen($this->dateend)==0?'NULL':$this->db->idate($this->dateend)).","; + $sql.= " ".(! isset($this->datestart) || dol_strlen($this->datestart)==0?'NULL':$this->db->idate($this->datestart)).","; + $sql.= " ".(! isset($this->lastresult)?'NULL':"'".$this->db->escape($this->lastresult)."'").","; + $sql.= " ".(! isset($this->datelastresult) || dol_strlen($this->datelastresult)==0?'NULL':$this->db->idate($this->datelastresult)).","; $sql.= " ".(! isset($this->lastoutput)?'NULL':"'".$this->db->escape($this->lastoutput)."'").","; - $sql.= " ".(! isset($this->fk_user)?'NULL':"'".$this->fk_user."'").","; - $sql.= " ".(! isset($this->note)?'NULL':"'".$this->db->escape($this->note)."'").""; - - + $sql.= " ".(! isset($this->unitfrequency)?'NULL':"'".$this->unitfrequency."'").","; + $sql.= " ".(! isset($this->frequency)?'NULL':"'".$this->frequency."'").","; + $sql.= " ".(! isset($this->status)?'0':"'".$this->status."'").","; + $sql.= " ".$user->id.","; + $sql.= " ".$user->id.","; + $sql.= " ".(! isset($this->note)?'NULL':"'".$this->db->escape($this->note)."'").","; + $sql.= " ".(! isset($this->nbrun)?'0':"'".$this->db->escape($this->nbrun)."'").""; + + $sql.= ")"; + $this->db->begin(); dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."cronjob"); @@ -173,18 +266,35 @@ class Cronjob extends CommonObject global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; - + $sql.= " t.tms,"; $sql.= " t.datec,"; + $sql.= " t.jobtype,"; + $sql.= " t.label,"; $sql.= " t.command,"; + $sql.= " t.classesname,"; + $sql.= " t.objectname,"; + $sql.= " t.methodename,"; $sql.= " t.params,"; + $sql.= " t.md5params,"; + $sql.= " t.module_name,"; + $sql.= " t.priority,"; $sql.= " t.datelastrun,"; + $sql.= " t.datenextrun,"; + $sql.= " t.dateend,"; + $sql.= " t.datestart,"; $sql.= " t.lastresult,"; + $sql.= " t.datelastresult,"; $sql.= " t.lastoutput,"; - $sql.= " t.fk_user,"; - $sql.= " t.note"; - - + $sql.= " t.unitfrequency,"; + $sql.= " t.frequency,"; + $sql.= " t.status,"; + $sql.= " t.fk_user_author,"; + $sql.= " t.fk_user_mod,"; + $sql.= " t.note,"; + $sql.= " t.nbrun"; + + $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; $sql.= " WHERE t.rowid = ".$id; @@ -197,18 +307,36 @@ class Cronjob extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); $this->datec = $this->db->jdate($obj->datec); + $this->label = $obj->label; + $this->jobtype = $obj->jobtype; $this->command = $obj->command; + $this->classesname = $obj->classesname; + $this->objectname = $obj->objectname; + $this->methodename = $obj->methodename; $this->params = $obj->params; + $this->md5params = $obj->md5params; + $this->module_name = $obj->module_name; + $this->priority = $obj->priority; $this->datelastrun = $this->db->jdate($obj->datelastrun); - $this->lastresult = $this->db->jdate($obj->lastresult); + $this->datenextrun = $this->db->jdate($obj->datenextrun); + $this->dateend = $this->db->jdate($obj->dateend); + $this->datestart = $this->db->jdate($obj->datestart); + $this->lastresult = $obj->lastresult; $this->lastoutput = $obj->lastoutput; - $this->fk_user = $obj->fk_user; + $this->datelastresult = $this->db->jdate($obj->datelastresult); + $this->unitfrequency = $obj->unitfrequency; + $this->frequency = $obj->frequency; + $this->status = $obj->status; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_mod = $obj->fk_user_mod; $this->note = $obj->note; + $this->nbrun = $obj->nbrun; - + } $this->db->free($resql); @@ -221,6 +349,141 @@ class Cronjob extends CommonObject return -1; } } + + /** + * Load object in memory from the database + * + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param int $status display active or not + * @param array $filter filter output + * @return int <0 if KO, >0 if OK + */ + function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='') + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.tms,"; + $sql.= " t.datec,"; + $sql.= " t.jobtype,"; + $sql.= " t.label,"; + $sql.= " t.command,"; + $sql.= " t.classesname,"; + $sql.= " t.objectname,"; + $sql.= " t.methodename,"; + $sql.= " t.params,"; + $sql.= " t.md5params,"; + $sql.= " t.module_name,"; + $sql.= " t.priority,"; + $sql.= " t.datelastrun,"; + $sql.= " t.datenextrun,"; + $sql.= " t.dateend,"; + $sql.= " t.datestart,"; + $sql.= " t.lastresult,"; + $sql.= " t.datelastresult,"; + $sql.= " t.lastoutput,"; + $sql.= " t.unitfrequency,"; + $sql.= " t.frequency,"; + $sql.= " t.status,"; + $sql.= " t.fk_user_author,"; + $sql.= " t.fk_user_mod,"; + $sql.= " t.note,"; + $sql.= " t.nbrun"; + + + $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; + $status = (empty($status))?'0':'1'; + $sql.= " WHERE t.status=".$status; + //Manage filter + if (is_array($filter) && count($filter)>0) { + foreach($filter as $key => $value) { + $sql.= ' AND '.$key.' LIKE \'%'.$value.'%\''; + } + } + + + $sql.= " ORDER BY $sortfield $sortorder "; + if (!empty($limit) && !empty($offset)) { + $sql.= $this->db->plimit( $limit + 1 ,$offset); + } + + $sqlwhere = array(); + + if (!empty($module_name)) { + $sqlwhere[]='(t.module_name='.$module_name.')'; + } + if (count($sqlwhere)>0) { + $sql.= " WHERE ".implode(' AND ',$sqlwhere); + } + + dol_syslog(get_class($this)."::fetch_all sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->num_rows($resql); + $i=0; + + if ($num) + { + $this->lines=array(); + + while ($i < $num) + { + + $line = new Cronjobline(); + + $obj = $this->db->fetch_object($resql); + + $line->id = $obj->rowid; + $line->ref = $obj->rowid; + + $line->tms = $this->db->jdate($obj->tms); + $line->datec = $this->db->jdate($obj->datec); + $line->label = $obj->label; + $line->jobtype = $obj->jobtype; + $line->command = $obj->command; + $line->classesname = $obj->classesname; + $line->objectname = $obj->objectname; + $line->methodename = $obj->methodename; + $line->params = $obj->params; + $line->md5params = $obj->md5params; + $line->module_name = $obj->module_name; + $line->priority = $obj->priority; + $line->datelastrun = $this->db->jdate($obj->datelastrun); + $line->datenextrun = $this->db->jdate($obj->datenextrun); + $line->dateend = $this->db->jdate($obj->dateend); + $line->datestart = $this->db->jdate($obj->datestart); + $line->lastresult = $obj->lastresult; + $line->datelastresult = $this->db->jdate($obj->datelastresult); + $line->lastoutput = $obj->lastoutput; + $line->unitfrequency = $obj->unitfrequency; + $line->frequency = $obj->frequency; + $line->status = $obj->status; + $line->fk_user_author = $obj->fk_user_author; + $line->fk_user_mod = $obj->fk_user_mod; + $line->note = $obj->note; + $line->nbrun = $obj->nbrun; + + $this->lines[]=$line; + + $i++; + + } + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } /** @@ -233,35 +496,98 @@ class Cronjob extends CommonObject function update($user=0, $notrigger=0) { global $conf, $langs; + + $langs->load('cron'); + $error=0; // Clean parameters - + + if (isset($this->label)) $this->label=trim($this->label); + if (isset($this->jobtype)) $this->jobtype=trim($this->jobtype); if (isset($this->command)) $this->command=trim($this->command); + if (isset($this->classesname)) $this->classesname=trim($this->classesname); + if (isset($this->objectname)) $this->objectname=trim($this->objectname); + if (isset($this->methodename)) $this->methodename=trim($this->methodename); if (isset($this->params)) $this->params=trim($this->params); + if (isset($this->md5params)) $this->md5params=trim($this->md5params); + if (isset($this->module_name)) $this->module_name=trim($this->module_name); + if (isset($this->priority)) $this->priority=trim($this->priority); if (isset($this->lastoutput)) $this->lastoutput=trim($this->lastoutput); - if (isset($this->fk_user)) $this->fk_user=trim($this->fk_user); + if (isset($this->lastresult)) $this->lastresult=trim($this->lastresult); + if (isset($this->unitfrequency)) $this->unitfrequency=trim($this->unitfrequency); + if (isset($this->frequency)) $this->frequency=trim($this->frequency); + if (isset($this->status)) $this->status=trim($this->status); if (isset($this->note)) $this->note=trim($this->note); - - + if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun); // Check parameters // Put here code to add a control on parameters values + if (empty($this->status)) { + $this->dateend=dol_now(); + } + if (dol_strlen($this->datestart)==0) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronDtStart')); + $error++; + } + if ((dol_strlen($this->datestart)!=0) && (dol_strlen($this->dateend)!=0) && ($this->dateend<$this->datestart)) { + $this->errors[]=$langs->trans('CronErrEndDateStartDt'); + $error++; + } + if (empty($this->label)) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLabel')); + $error++; + } + if (empty($this->unitfrequency)) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronFrequency')); + $error++; + } + if (($this->jobtype=='command') && (empty($this->command))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronCommand')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->classesname))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronClass')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->methodename))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronMethod')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->objectname))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronObject')); + $error++; + } + // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."cronjob SET"; - - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + + $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; + $sql.= " jobtype=".(isset($this->jobtype)?"'".$this->db->escape($this->jobtype)."'":"null").","; $sql.= " command=".(isset($this->command)?"'".$this->db->escape($this->command)."'":"null").","; + $sql.= " classesname=".(isset($this->classesname)?"'".$this->db->escape($this->classesname)."'":"null").","; + $sql.= " objectname=".(isset($this->objectname)?"'".$this->db->escape($this->objectname)."'":"null").","; + $sql.= " methodename=".(isset($this->methodename)?"'".$this->db->escape($this->methodename)."'":"null").","; $sql.= " params=".(isset($this->params)?"'".$this->db->escape($this->params)."'":"null").","; + $sql.= " md5params=".(isset($this->md5params)?"'".$this->db->escape($this->md5params)."'":"null").","; + $sql.= " module_name=".(isset($this->module_name)?"'".$this->db->escape($this->module_name)."'":"null").","; + $sql.= " priority=".(isset($this->priority)?$this->priority:"null").","; $sql.= " datelastrun=".(dol_strlen($this->datelastrun)!=0 ? "'".$this->db->idate($this->datelastrun)."'" : 'null').","; - $sql.= " lastresult=".(dol_strlen($this->lastresult)!=0 ? "'".$this->db->idate($this->lastresult)."'" : 'null').","; + $sql.= " datenextrun=".(dol_strlen($this->datenextrun)!=0 ? "'".$this->db->idate($this->datenextrun)."'" : 'null').","; + $sql.= " dateend=".(dol_strlen($this->dateend)!=0 ? "'".$this->db->idate($this->dateend)."'" : 'null').","; + $sql.= " datestart=".(dol_strlen($this->datestart)!=0 ? "'".$this->db->idate($this->datestart)."'" : 'null').","; + $sql.= " datelastresult=".(dol_strlen($this->datelastresult)!=0 ? "'".$this->db->idate($this->datelastresult)."'" : 'null').","; + $sql.= " lastresult=".(isset($this->lastresult)?"'".$this->db->escape($this->lastresult)."'":"null").","; $sql.= " lastoutput=".(isset($this->lastoutput)?"'".$this->db->escape($this->lastoutput)."'":"null").","; - $sql.= " fk_user=".(isset($this->fk_user)?$this->fk_user:"null").","; - $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").""; - - + $sql.= " unitfrequency=".(isset($this->unitfrequency)?$this->unitfrequency:"null").","; + $sql.= " frequency=".(isset($this->frequency)?$this->frequency:"null").","; + $sql.= " status=".(isset($this->status)?$this->status:"null").","; + $sql.= " fk_user_mod=".$user->id.","; + $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; + $sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null"); + + $sql.= " WHERE rowid=".$this->id; $this->db->begin(); @@ -269,7 +595,7 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - + if (! $error) { if (! $notrigger) @@ -377,7 +703,7 @@ class Cronjob extends CommonObject $error=0; - $object=new Cronjobs($this->db); + $object=new Cronjob($this->db); $this->db->begin(); @@ -428,19 +754,277 @@ class Cronjob extends CommonObject function initAsSpecimen() { $this->id=0; - + $this->ref=0; + $this->tms=''; $this->datec=''; + $this->label=''; + $this->jobtype=''; $this->command=''; + $this->classesname=''; + $this->objectname=''; + $this->methodename=''; $this->params=''; + $this->md5params=''; + $this->module_name=''; + $this->priority=''; $this->datelastrun=''; - $this->lastresult=''; + $this->datenextrun=''; + $this->dateend=''; + $this->datestart=''; + $this->datelastresult=''; $this->lastoutput=''; - $this->fk_user=''; - $this->note=''; - - + $this->lastresult=''; + $this->unitfrequency=''; + $this->frequency=''; + $this->status=''; + $this->fk_user_author=''; + $this->fk_user_mod=''; + $this->note=''; + $this->nbrun=''; + } + + /** + * Load object information + * + * @return void + */ + function info() + { + global $langs; + + $sql = "SELECT"; + $sql.= " f.rowid, f.datec, f.tms, f.fk_user_mod, f.fk_user_author"; + $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as f"; + $sql.= " WHERE f.rowid = ".$this->id; + + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + $this->id = $obj->rowid; + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->tms); + $this->user_modification = $obj->fk_user_mod; + $this->user_creation = $obj->fk_user_author; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } } + + /** + * Run a job + * + * @param string $userlogin User login + * @return int <0 if KO, >0 if OK + */ + function run_jobs($userlogin) + { + global $langs, $conf; + + $langs->load('cron'); + + if (empty($userlogin)) { + $this->error="User login is mandatory"; + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + return -1; + } + + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $user=new User($this->db); + $result=$user->fetch('',$userlogin); + if ($result<0) { + $this->error="User Error:".$user->error; + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + return -1; + }else { + if (empty($user->id)) { + $this->error=" User user login:".$userlogin." do not exists"; + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + return -1; + } + } + + dol_syslog(get_class($this)."::run_jobs userlogin:$userlogin", LOG_DEBUG); + + $error=0; + $now=dol_now(); + + $this->db->begin(); + + if ($this->jobtype=='method') { + // load classes + $ret=dol_include_once("/".$this->module_name."/class/".$this->classesname,$this->objectname); + if ($ret===false) { + $this->error=$langs->trans('CronCannotLoadClass',$file,$this->objectname); + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + return -1; + } + + // Load langs + $result=$langs->load($this->module_name.'@'.$this->module_name); + if ($result<0) { + dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR); + return -1; + } + + dol_syslog(get_class($this)."::run_jobs ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG); + + // Create Object for the call module + $object = new $this->objectname($this->db); + + $params_arr = array(); + $params_arr=explode(", ",$this->params); + if (!is_array($params_arr)) { + $result = call_user_func(array($object, $this->methodename), $this->params); + }else { + $result = call_user_func_array(array($object, $this->methodename), $params_arr); + } + + if ($result===false) { + dol_syslog(get_class($this)."::run_jobs ".$object->error, LOG_ERR); + return -1; + }else { + $this->lastoutput=var_export($result,true); + $this->lastresult=var_export($result,true); + } + + } elseif ($this->jobtype=='command') { + dol_syslog(get_class($this)."::run_jobs system:".$this->command, LOG_DEBUG); + $output_arr=array(); + + exec($this->command, $output_arr,$retval); + + dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG); + + $this->lastoutput=''; + if (is_array($output_arr) && count($output_arr)>0) { + foreach($output_arr as $val) { + $this->lastoutput.=$val."\n"; + } + } + $this->lastresult=$retval; + } + + $this->datelastresult=$now; + $this->datelastrun=$now; + $this->nbrun=$this->nbrun+1; + $result = $this->update($user); + if ($result<0) { + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; + }else { + $this->db->commit(); + return 1; + } + + + } + + /** + * Reprogram a job + * + * @param string $userlogin User login + * @return int <0 if KO, >0 if OK + * + */ + function reprogram_jobs($userlogin) + { + global $langs, $conf; + + dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG); + + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $user=new User($this->db); + $result=$user->fetch('',$userlogin); + if ($result<0) { + $this->error="User Error:".$user->error; + dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); + return -1; + }else { + if (empty($user->id)) { + $this->error=" User user login:".$userlogin." do not exists"; + dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); + return -1; + } + } + + dol_syslog(get_class($this)."::reprogram_jobs ", LOG_DEBUG); + + if (empty($this->datenextrun)) { + $this->datenextrun=dol_now()+$this->frequency; + } else { + if ($this->datenextrun<dol_now()) { + $this->datenextrun=dol_now()+$this->frequency; + } else { + $this->datenextrun=$this->datenextrun+$this->frequency; + } + } + $result = $this->update($user); + if ($result<0) { + dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); + return -1; + } + + return 1; + + } } -?> + + +/** + * Crob Job line class + */ +class Cronjobline{ + + var $id; + var $ref; + + var $tms=''; + var $datec=''; + var $label; + var $jobtype; + var $command; + var $classesname; + var $objectname; + var $methodename; + var $params; + var $md5params; + var $module_name; + var $priority; + var $datelastrun=''; + var $datenextrun=''; + var $dateend=''; + var $datestart=''; + var $lastresult=''; + var $lastoutput; + var $unitfrequency; + var $frequency; + var $status; + var $fk_user_author; + var $fk_user_mod; + var $note; + var $nbrun; + + /** + * Constructor + * + */ + function __construct() + { + return 1; + } +} \ No newline at end of file diff --git a/htdocs/cron/functions_cron.lib.php b/htdocs/cron/functions_cron.lib.php deleted file mode 100644 index 31cc8ebefad0da1ff8eb4c182b800e2c5f06fa3b..0000000000000000000000000000000000000000 --- a/htdocs/cron/functions_cron.lib.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2007-2009 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/>. - */ - -/** - * \file cron/functions_cron.lib.php - * \ingroup core - * \brief Functions for miscellaneous cron tasks - */ - - - -?> diff --git a/htdocs/cron/index.php b/htdocs/cron/index.php deleted file mode 100644 index 3d7ef46ad7700bd572b06fa05944a1b4244426dc..0000000000000000000000000000000000000000 --- a/htdocs/cron/index.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php -/* Copyright (C) 2007-2010 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/>. - */ - -/** - * \file dev/Cronjobss/Cronjobs_page.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example of a php page - * Initialy built by build_class_from_table on 2013-03-17 18:50 - */ - -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - -// Change this following line to use the correct relative path (../, ../../, etc) -$res=0; -if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; -if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; -if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php'; -if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res) die("Include of main fails"); -// Change this following line to use the correct relative path from htdocs -dol_include_once('/module/class/cronjob.class.php'); - -// Load traductions files requiredby by page -$langs->load("companies"); -$langs->load("other"); -$langs->load("cron"); - -// Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); -$myparam = GETPOST('myparam','alpha'); -$action='list'; - -// Protection if external user -if ($user->societe_id > 0) accessforbidden(); -if (! $user->admin) accessforbidden(); - - -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ - -if ($action == 'add') -{ - $object=new Cronjobs($db); - $object->prop1=$_POST["field1"]; - $object->prop2=$_POST["field2"]; - $result=$object->create($user); - if ($result > 0) - { - // Creation OK - } - { - // Creation KO - $mesg=$object->error; - } -} - - - - - -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ - -llxHeader('','MyPageName',''); - -$form=new Form($db); - - -//print '<table border="0" width="100%" class="notopnoleftnoright">'; -//print '<tr><td valign="top" width="30%" class="notopnoleft">'; -print '<div class="fichecenter"><div class="fichethirdleft">'; - - - - - -//print '</td><td valign="top" width="70%" class="notopnoleftnoright">'; -print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; - - - -// Example 1 : Adding jquery code -print '<script type="text/javascript" language="javascript"> -jQuery(document).ready(function() { - function init_myfunc() - { - jQuery("#myid").removeAttr(\'disabled\'); - jQuery("#myid").attr(\'disabled\',\'disabled\'); - } - init_myfunc(); - jQuery("#mybutton").click(function() { - init_needroot(); - }); -}); -</script>'; - - -// Example 2 : Adding links to objects -// The class must extends CommonObject class to have this method available -//$somethingshown=$object->showLinkedObjectBlock(); - - -// Example 3 : List of data -if ($action == 'list') -{ - $sql = "SELECT"; - $sql.= " t.rowid,"; - - $sql.= " t.tms,"; - $sql.= " t.datec,"; - $sql.= " t.command,"; - $sql.= " t.params,"; - $sql.= " t.datelastrun,"; - $sql.= " t.lastresult,"; - $sql.= " t.lastoutput,"; - $sql.= " t.fk_user,"; - $sql.= " t.note"; - - - $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; - //$sql.= " WHERE field3 = 'xxx'"; - //$sql.= " ORDER BY field1 ASC"; - - - print_fiche_titre($langs->trans("ListOfCronJobs"),'','').'<br>'; - - - print '<table class="noborder">'."\n"; - print '<tr class="liste_titre">'; - print_liste_field_titre($langs->trans('Id'),$_SERVER['PHP_SELF'],'t.rowid','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Command'),$_SERVER['PHP_SELF'],'t.command','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('DateCreation'),$_SERVER['PHP_SELF'],'t.datec','align="center"',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('LastOutput'),$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('DateLastRun'),$_SERVER['PHP_SELF'],'t.datelastrun','align="center"',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('LastResult'),$_SERVER['PHP_SELF'],'t.lastresult','align="right"',$param,'',$sortfield,$sortorder); - print '</tr>'; - - dol_syslog($script_file." sql=".$sql, LOG_DEBUG); - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - // You can use here results - print '<tr><td>'; - print $obj->rowid; - print '</td><td>'; - print $obj->command; - print '</td><td align="center">'; - print $db->jdate($obj->datec); - print '</td><td>'; - print ''; - print '</td><td align="center">'; - print $db->jdate($obj->datelastrun); - print '</td><td align="right">'; - print $obj->lastresult; - print '</td></tr>'; - } - $i++; - } - } - } - else - { - $error++; - dol_print_error($db); - } - - print '</table>'."\n"; -} - - -//print '</td></tr></table>'; -print '<div></div></div>'; - - -// End of page -llxFooter(); -$db->close(); -?> diff --git a/htdocs/cron/info.php b/htdocs/cron/info.php new file mode 100644 index 0000000000000000000000000000000000000000..55c294d54ed470359f0f2993369b71d52cf6a238 --- /dev/null +++ b/htdocs/cron/info.php @@ -0,0 +1,59 @@ +<?php +/* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> +* +* 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, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/** + * \file /cron/cron/info.php + * \brief Page fiche d'une operation + */ + +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php"; +require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + + +// Security check +if (!$user->rights->cron->read) accessforbidden(); + +$id=GETPOST('id','int'); + +$mesg = ''; + +/* + * View +*/ + +llxHeader('',$langs->trans("CronInfo")); + +$object = new Cronjob($db); +$object->fetch($id); +$object->info($id); + +$head = cron_prepare_head($object); + +dol_fiche_head($head, 'info', $langs->trans("CronTask"), 0, 'bill'); + +print '<table width="100%"><tr><td>'; +dol_print_object_info($object); +print '</td></tr></table>'; +print '</div>'; + + +$db->close(); +llxFooter(); \ No newline at end of file diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php new file mode 100644 index 0000000000000000000000000000000000000000..5e972f0e55b47c5872b83c67e309048124b2d27c --- /dev/null +++ b/htdocs/cron/list.php @@ -0,0 +1,295 @@ +<?php +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> + * + * 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/>. + */ + +/** + * \file cron/cron/list.php + * \ingroup cron + * \brief Lists Jobs + */ + + +require '../main.inc.php'; +require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); + +// librairie jobs +require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php"; +require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; + +$langs->load("admin"); +$langs->load("cron"); + +if (!$user->rights->cron->read) accessforbidden(); + +/* + * Actions + */ +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$id=GETPOST('id','int'); + +$sortorder=GETPOST('sortorder','alpha'); +$sortfield=GETPOST('sortfield','alpha'); +$page=GETPOST('page','int'); +$status=GETPOST('status','int'); + +//Search criteria +$search_label=GETPOST("search_label",'alpha'); + +if (empty($sortorder)) $sortorder="DESC"; +if (empty($sortfield)) $sortfield="t.datenextrun"; +if (empty($arch)) $arch = 0; + +if ($page == -1) { + $page = 0 ; +} + +$limit = $conf->global->MAIN_SIZE_LISTE_LIMIT; +$offset = $limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +// Do we click on purge search criteria ? +if (GETPOST("button_removefilter_x")) +{ + $search_label=''; +} + +$filter=array(); +if (!empty($search_label)) { + $filter['t.label']=$search_label; +} + +// Delete jobs +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete){ + + //Delete de la tache cron + $object = new Cronjob($db); + $object->id=$id; + $result = $object->delete($user); + + if ($result < 0) { + setEventMessage($object->error,'errors'); + } +} + +// Execute jobs +if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute){ + + //Execute jobs + $object = new Cronjob($db); + $job = $object->fetch($id); + + $result = $object->run_jobs($user->login); + if ($result < 0) { + setEventMessage($object->error,'errors'); + } + +} + + +/* + * View + */ +if (!empty($status)) { + $pagetitle=$langs->trans("CronListActive"); +}else { + $pagetitle=$langs->trans("CronListInactive"); +} + +llxHeader('',$pagetitle); + + +// Form object for popup +$form = new Form($db); + +if ($action == 'delete') +{ + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronDelete"),$langs->trans("CronConfirmDelete"),"confirm_delete",'','',1); + if ($ret == 'html') print '<br>'; +} + +if ($action == 'execute'){ + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1); + if ($ret == 'html') print '<br>'; +} + + +print_fiche_titre($pagetitle,'','setup'); + +print $langs->trans('CronInfo'); + +// liste des jobs creer +$object = new Cronjob($db); +$result=$object->fetch_all($sortorder, $sortfield, $limit, $offset, $status, $filter); +if ($result < 0) { + setEventMessage($object->error,'errors'); +} + + +print "<p><h2>"; +print $langs->trans('CronWaitingJobs'); +print "</h2></p>"; + +if (count($object->lines)>0) { + + print '<table width="100%" cellspacing="0" cellpadding="4" class="border">'; + print '<tr class="liste_titre">'; + $arg_url='&page='.$page.'&status='.$status.'&search_label='.$search_label; + print_liste_field_titre($langs->trans("CronLabel"),$_SERVEUR['PHP_SELF'],"t.label","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronTask"),'','',"",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronDtStart"),$_SERVEUR['PHP_SELF'],"t.datestart","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronDtEnd"),$_SERVEUR['PHP_SELF'],"t.dateend","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronDtLastLaunch"),$_SERVEUR['PHP_SELF'],"t.datelastrun","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronDtNextLaunch"),$_SERVEUR['PHP_SELF'],"t.datenextrun","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronFrequency"),'',"","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronNbRun"),$_SERVEUR['PHP_SELF'],"t.nbrun","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronLastResult"),$_SERVEUR['PHP_SELF'],"t.lastresult","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVEUR['PHP_SELF'],"t.lastoutput","",$arg_url,'',$sortfield,$sortorder); + print '<td></td>'; + + print '</tr>'; + + print '<form method="get" action="'.$url_form.'" name="search_form">'."\n"; + print '<input type="hidden" name="status" value="'.$status.'" >'; + print '<tr class="liste_titre">'; + + + + print '<td class="liste_titre">'; + print '<input type="text" class="flat" name="search_label" value="'.$search_label.'" size="10">'; + print '</td>'; + print '<td> </td>'; + print '<td> </td>'; + print '<td> </td>'; + print '<td> </td>'; + print '<td> </td>'; + print '<td> </td>'; + print '<td> </td>'; + print '<td> </td>'; + print '<td> </td>'; + print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; + print ' '; + print '<input type="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">'; + print '</td>'; + + print '</tr>'; + print '</from>'; + + + + // Boucler sur chaque job + $style='impair'; + foreach($object->lines as $line){ + // title profil + if ($style=='pair') {$style='impair';} + else {$style='pair';} + + print '<tr class="'.$style.'">'; + + print '<td>'; + if(!empty($line->label)) { + print '<a href="'.dol_buildpath('/cron/cron/card.php',1).'?id='.$line->id.'">'.$line->label.'</a>'; + } + else { + print $langs->trans('CronNone'); + } + print '</td>'; + + print '<td>'; + if ($line->jobtype=='method') { + print $langs->trans('CronModule').':'.$line->module_name.'<BR>'; + print $langs->trans('CronClass').':'. $line->classesname.'<BR>'; + print $langs->trans('CronObject').':'. $line->objectname.'<BR>'; + print $langs->trans('CronMethod').':'. $line->methodename; + if(!empty($line->params)) { + print '<BR/>'.$langs->trans('CronArgs').':'. $line->params; + } + + }elseif ($line->jobtype=='command') { + print $langs->trans('CronCommand').':'. dol_trunc($line->command); + if(!empty($line->params)) { + print '<BR/>'.$langs->trans('CronArgs').':'. $line->params; + } + } + print '</td>'; + + print '<td>'; + if(!empty($line->datestart)) {print dol_print_date($line->datestart,'dayhourtext');} else {print $langs->trans('CronNone');} + print '</td>'; + + print '<td>'; + if(!empty($line->dateend)) {print dol_print_date($line->dateend,'dayhourtext');} else {print $langs->trans('CronNone');} + print '</td>'; + + print '<td>'; + if(!empty($line->datelastrun)) {print dol_print_date($line->datelastrun,'dayhourtext');} else {print $langs->trans('CronNone');} + print '</td>'; + + print '<td>'; + if(!empty($line->datenextrun)) {print dol_print_date($line->datenextrun,'dayhourtext');} else {print $langs->trans('CronNone');} + print '</td>'; + + print '<td>'; + if($line->unitfrequency == "60") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Minutes'); + if($line->unitfrequency == "3600") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Hours'); + if($line->unitfrequency == "86400") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Days'); + if($line->unitfrequency == "604800") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Weeks'); + print '</td>'; + + print '<td>'; + if(!empty($line->nbrun)) {print $line->nbrun;} else {print '0';} + print '</td>'; + + print '<td>'; + if(!empty($line->lastresult)) {print dol_trunc($line->lastresult);} else {print $langs->trans('CronNone');} + print '</td>'; + + print '<td>'; + if(!empty($line->lastoutput)) {print dol_trunc(nl2br($line->lastoutput),100);} else {print $langs->trans('CronNone');} + print '</td>'; + + print '<td>'; + if ($user->rights->cron->delete) { + print "<a href=\"".dol_buildpath('/cron/cron/list.php',1)."?id=".$line->id."&status=".$status."&action=delete\" title=\"".$langs->trans('CronDelete')."\"><img src=\"".dol_buildpath('/cron/img/delete.png',1)."\" alt=\"".$langs->trans('CronDelete')."\" /></a>"; + } else { + print "<a href=\"#\" title=\"".$langs->trans('NotEnoughPermissions')."\"><img src=\"".dol_buildpath('/cron/img/delete.png',1)."\" alt=\"".$langs->trans('NotEnoughPermissions')."\" /></a>"; + } + if ($user->rights->cron->execute) { + print "<a href=\"".dol_buildpath('/cron/cron/list.php',1)."?id=".$line->id."&status=".$status."&action=execute\" title=\"".$langs->trans('CronExecute')."\"><img src=\"".dol_buildpath('/cron/img/execute.png',1)."\" alt=\"".$langs->trans('CronExecute')."\" /></a>"; + } else { + print "<a href=\"#\" title=\"".$langs->trans('NotEnoughPermissions')."\"><img src=\"".dol_buildpath('/cron/img/execute.png',1)."\" alt=\"".$langs->trans('NotEnoughPermissions')."\" /></a>"; + } + print '</td>'; + + print '</tr>'; + } + print '</table>'; +} else { + print $langs->trans('CronNoJobs'); +} + +print "\n\n<div class=\"tabsAction\">\n"; +if (! $user->rights->cron->create) { + print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("New").'</a>'; +} else { + print '<a class="butAction" href="'.dol_buildpath('/cron/card.php',1).'?action=create">'.$langs->trans("New").'</a>'; +} +print '<br><br></div>'; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index cac81eda0708e204a316afc728d205d624abb98c..393a316df15749294ca40272a752160a737ea7b1 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -51,7 +51,6 @@ class Expedition extends CommonObject var $origin; var $origin_id; var $lines=array(); - var $expedition_method_id; // deprecated var $shipping_method_id; var $tracking_number; var $tracking_url; @@ -203,7 +202,7 @@ class Expedition extends CommonObject $sql.= ", ".($this->date_delivery>0?"'".$this->db->idate($this->date_delivery)."'":"null"); $sql.= ", ".$this->socid; $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null"); - $sql.= ", ".($this->expedition_method_id>0?$this->expedition_method_id:"null"); + $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null"); $sql.= ", '".$this->db->escape($this->tracking_number)."'"; $sql.= ", ".$this->weight; $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth @@ -373,7 +372,6 @@ class Expedition extends CommonObject $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->modelpdf = $obj->model_pdf; - $this->expedition_method_id = $obj->fk_expedition_methode; // TODO deprecated $this->shipping_method_id = $obj->fk_expedition_methode; $this->tracking_number = $obj->tracking_number; $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility @@ -683,7 +681,7 @@ class Expedition extends CommonObject if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid); if (isset($this->fk_delivery_address)) $this->fk_delivery_address=trim($this->fk_delivery_address); - if (isset($this->expedition_method_id)) $this->expedition_method_id=trim($this->expedition_method_id); + if (isset($this->shipping_method_id)) $this->shipping_method_id=trim($this->shipping_method_id); if (isset($this->tracking_number)) $this->tracking_number=trim($this->tracking_number); if (isset($this->statut)) $this->statut=trim($this->statut); if (isset($this->trueDepth)) $this->trueDepth=trim($this->trueDepth); @@ -714,7 +712,7 @@ class Expedition extends CommonObject $sql.= " date_expedition=".(dol_strlen($this->date_expedition)!=0 ? "'".$this->db->idate($this->date_expedition)."'" : 'null').","; $sql.= " date_delivery=".(dol_strlen($this->date_delivery)!=0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; $sql.= " fk_address=".(isset($this->fk_delivery_address)?$this->fk_delivery_address:"null").","; - $sql.= " fk_expedition_methode=".((isset($this->expedition_method_id) && $this->expedition_method_id > 0)?$this->expedition_method_id:"null").","; + $sql.= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0)?$this->shipping_method_id:"null").","; $sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").","; $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; $sql.= " height=".(($this->trueHeight != '')?$this->trueHeight:"null").","; @@ -1291,11 +1289,11 @@ class Expedition extends CommonObject { $code=''; - if (! empty($this->expedition_method_id)) + if (! empty($this->shipping_method_id)) { $sql = "SELECT em.code, em.tracking"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.rowid = ".$this->expedition_method_id; + $sql.= " WHERE em.rowid = ".$this->shipping_method_id; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 21289f60864d8bbb9e5fb386c616984748d5d91d..bcb55bb3ef8812dfce94d4c4bea0f8f87130806b 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -104,7 +104,7 @@ if ($action == 'add') $object->ref_customer = $objectsrc->ref_client; $object->date_delivery = $date_delivery; // Date delivery planed $object->fk_delivery_address = $objectsrc->fk_delivery_address; - $object->expedition_method_id = GETPOST('expedition_method_id','int'); + $object->shipping_method_id = GETPOST('shipping_method_id','int'); $object->tracking_number = GETPOST('tracking_number','alpha'); $object->ref_int = GETPOST('ref_int','alpha'); @@ -260,7 +260,7 @@ else if ($action == 'settrackingnumber' || $action == 'settrackingurl' || $action == 'settrueWidth' || $action == 'settrueHeight' || $action == 'settrueDepth' -|| $action == 'setexpedition_method_id') +|| $action == 'setshipping_method_id') { $error=0; @@ -274,7 +274,7 @@ else if ($action == 'settrackingnumber' || $action == 'settrackingurl' if ($action == 'settrueWidth') $shipping->trueWidth = trim(GETPOST('trueWidth','int')); if ($action == 'settrueHeight') $shipping->trueHeight = trim(GETPOST('trueHeight','int')); if ($action == 'settrueDepth') $shipping->trueDepth = trim(GETPOST('trueDepth','int')); - if ($action == 'setexpedition_method_id') $shipping->expedition_method_id = trim(GETPOST('expedition_method_id','int')); + if ($action == 'setshipping_method_id') $shipping->shipping_method_id = trim(GETPOST('shipping_method_id','int')); if (! $error) { @@ -658,7 +658,7 @@ if ($action == 'create') print "<tr><td>".$langs->trans("DeliveryMethod")."</td>"; print '<td colspan="3">'; $expe->fetch_delivery_methods(); - print $form->selectarray("expedition_method_id",$expe->meths,GETPOST('expedition_method_id','int'),1,0,0,"",1); + print $form->selectarray("shipping_method_id",$expe->meths,GETPOST('shipping_method_id','int'),1,0,0,"",1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print "</td></tr>\n"; @@ -1105,26 +1105,26 @@ else print $langs->trans('SendingMethod'); print '</td>'; - if ($action != 'editexpedition_method_id') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editexpedition_method_id&id='.$object->id.'">'.img_edit($langs->trans('SetSendingMethod'),1).'</a></td>'; + if ($action != 'editshipping_method_id') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshipping_method_id&id='.$object->id.'">'.img_edit($langs->trans('SetSendingMethod'),1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="2">'; - if ($action == 'editexpedition_method_id') + if ($action == 'editshipping_method_id') { - print '<form name="setexpedition_method_id" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<form name="setshipping_method_id" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="setexpedition_method_id">'; + print '<input type="hidden" name="action" value="setshipping_method_id">'; $object->fetch_delivery_methods(); - print $form->selectarray("expedition_method_id",$object->meths,$object->expedition_method_id,1,0,0,"",1); + print $form->selectarray("shipping_method_id",$object->meths,$object->shipping_method_id,1,0,0,"",1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; } else { - if ($object->expedition_method_id > 0) + if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$langs->getLabelFromKey($db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); + $code=$langs->getLabelFromKey($db,$object->shipping_method_id,'c_shipment_mode','rowid','code'); print $langs->trans("SendingMethod".strtoupper($code)); } } diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index d5fb257cead0b32eca74188ee15137fa70d16859..9728e9d4a29f1672d860f739ffe7c43aec3044ad 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -81,6 +81,7 @@ alter table llx_socpeople CHANGE COLUMN cp zip varchar(10); alter table llx_societe_rib CHANGE COLUMN adresse_proprio owner_address text; alter table llx_societe_address CHANGE COLUMN ville town text; alter table llx_societe_address CHANGE COLUMN cp zip varchar(10); +alter table llx_expedition CHANGE COLUMN fk_expedition_methode fk_shipping_method integer; ALTER TABLE llx_c_shipment_mode ADD COLUMN tracking VARCHAR(256) NOT NULL DEFAULT '' AFTER description; @@ -153,7 +154,43 @@ ALTER TABLE llx_holiday ADD COLUMN note_public text; -- Add new trigger on Invoice BILL_UNVALIDATE + Index INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (28,'BILL_UNVALIDATE','Customer invoice unvalidated','Executed when a customer invoice status set back to draft','facture',10); -ALTER TABLE llx_c_action_trigger ADD INDEX idx_action_trigger_rang (rang) +ALTER TABLE llx_c_action_trigger ADD INDEX idx_action_trigger_rang (rang); + + +ALTER TABLE llx_facture_fourn_det ADD COLUMN fk_code_ventilation integer DEFAULT 0 NOT NULL; +ALTER TABLE llx_facturedet DROP COLUMN fk_export_compta; + +CREATE TABLE llx_cronjob +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + datec datetime, + jobtype varchar(10) NOT NULL, + label text NOT NULL, + command varchar(255), + classesname varchar(255), + objectname varchar(255), + methodename varchar(255), + params text NOT NULL, + md5params varchar(32), + module_name varchar(255), + priority integer DEFAULT 0, + datelastrun datetime, + datenextrun datetime, + datestart datetime, + dateend datetime, + datelastresult datetime, + lastresult text, + lastoutput text, + unitfrequency integer NOT NULL DEFAULT 0, + frequency integer NOT NULL DEFAULT 0, + nbrun integer, + status integer NOT NULL DEFAULT 1, + fk_user_author integer DEFAULT NULL, + fk_user_mod integer DEFAULT NULL, + note text +)ENGINE=innodb; + ALTER TABLE llx_societe MODIFY COLUMN zip varchar(25); diff --git a/htdocs/install/mysql/tables/llx_cronjob.sql b/htdocs/install/mysql/tables/llx_cronjob.sql index 5a8e33ef38f61b2c39b5f25ec77b862696f039fd..a5bb3c10f590fc975216b61396d6ba5414b17e68 100644 --- a/htdocs/install/mysql/tables/llx_cronjob.sql +++ b/htdocs/install/mysql/tables/llx_cronjob.sql @@ -1,32 +1,52 @@ --- =================================================================== --- Copyright (C) 2013 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/>. --- --- =================================================================== - -create table llx_cronjob -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, - datec datetime, - command varchar(256), - params text, - frequency varchar(24), - datelastrun datetime, - lastresult date, - lastoutput text, - fk_user integer DEFAULT NULL, - note text -)ENGINE=innodb; +-- =================================================================== +-- Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> +-- Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> +-- +-- 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/>. +-- +-- =================================================================== + + +CREATE TABLE llx_cronjob +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + datec datetime, + jobtype varchar(10) NOT NULL, + label text NOT NULL, + command varchar(255), + classesname varchar(255), + objectname varchar(255), + methodename varchar(255), + params text NOT NULL, + md5params varchar(32), + module_name varchar(255), + priority integer DEFAULT 0, + datelastrun datetime, + datenextrun datetime, + datestart datetime, + dateend datetime, + datelastresult datetime, + lastresult text, + lastoutput text, + unitfrequency integer NOT NULL DEFAULT 0, + frequency integer NOT NULL DEFAULT 0, + nbrun integer, + status integer NOT NULL DEFAULT 1, + fk_user_author integer DEFAULT NULL, + fk_user_mod integer DEFAULT NULL, + note text +)ENGINE=innodb; + + diff --git a/htdocs/install/mysql/tables/llx_facture_fourn_det.sql b/htdocs/install/mysql/tables/llx_facture_fourn_det.sql index 16dacbbb336bd3088071e5f3ade586a92dceada4..325950a4e46d0cbcb90f315b4d7f93ccffca3de3 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn_det.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn_det.sql @@ -43,5 +43,6 @@ create table llx_facture_fourn_det product_type integer DEFAULT 0, date_start datetime DEFAULT NULL, -- date debut si service date_end datetime DEFAULT NULL, -- date fin si service + fk_code_ventilation integer DEFAULT 0 NOT NULL, import_key varchar(14) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index 847178d83304a96abb375672111d63a3b0961467..949dee1933c44660f36d1550d5bc6f94ec0a23be 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -51,7 +51,6 @@ create table llx_facturedet buy_price_ht double(24,8) DEFAULT 0, -- prix d'achat HT fk_product_fournisseur_price integer DEFAULT NULL, -- reference prix fournisseur fk_code_ventilation integer DEFAULT 0 NOT NULL, - fk_export_compta integer DEFAULT 0 NOT NULL, special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- ordre d'affichage import_key varchar(14) diff --git a/htdocs/install/mysql/tables/llx_paiement.sql b/htdocs/install/mysql/tables/llx_paiement.sql index 6787aee87fd92f606d6321a84350476eeffd94e8..00680f29d6995996e5d3614bb4299ebda344e4e4 100644 --- a/htdocs/install/mysql/tables/llx_paiement.sql +++ b/htdocs/install/mysql/tables/llx_paiement.sql @@ -18,10 +18,6 @@ -- -- =================================================================== - --- Satut, 0 ou 1, 1 n'est plus supprimable --- fk_export_compta 0 pas exporte - create table llx_paiement ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -36,7 +32,6 @@ create table llx_paiement fk_bank integer NOT NULL DEFAULT 0, fk_user_creat integer, -- utilisateur qui a cree l'info fk_user_modif integer, -- utilisateur qui a modifie l'info - statut smallint DEFAULT 0 NOT NULL, - fk_export_compta integer DEFAULT 0 NOT NULL - + statut smallint DEFAULT 0 NOT NULL, -- Satut, 0 ou 1, 1 n'est plus supprimable + fk_export_compta integer DEFAULT 0 NOT NULL -- fk_export_compta 0 pas exporte )ENGINE=innodb; diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 0c7f39025f9284001f2f3c94c2a9c00cb4b88833..b1f9282b6bf664dc4d1935aa96a10544ff8ef442 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -116,3 +116,4 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_tva FOR EACH ROW EXE CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_user FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_user_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_usergroup FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cronjob FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/langs/ar_SA/main.lang b/htdocs/langs/ar_SA/main.lang index 5befea18b77a574d075be311e47e18245e9369fb..f273f913d049a466020ec5cc34a7230a70cd0fe4 100644 --- a/htdocs/langs/ar_SA/main.lang +++ b/htdocs/langs/ar_SA/main.lang @@ -428,8 +428,6 @@ NbOfThirdParties=عدد من الأطراف الثالثة NbOfCustomers=عدد من العملاء NbOfLines=عدد الخطوط NbOfObjects=عدد الأجسام -NbOfReferers=عدد referers -Referers=Referers TotalQuantity=الكمية الإجمالية DateFromTo=ل٪ من ق ق ٪ DateFrom=من ق ٪ diff --git a/htdocs/langs/ar_SA/members.lang b/htdocs/langs/ar_SA/members.lang index 570dfab40697f23705b6b975812b3ad1f87d7254..6b16226f9e5e1639295131d428f973f6a8a335b3 100644 --- a/htdocs/langs/ar_SA/members.lang +++ b/htdocs/langs/ar_SA/members.lang @@ -152,7 +152,7 @@ ShowTypeCard=وتبين من نوع '٪ ق' HTPasswordExport=الملف htpassword جيل NoThirdPartyAssociatedToMember=لم يرتبط بها من طرف ثالث لهذا العضو ThirdPartyDolibarr=Dolibarr طرف ثالث -MembersAndSubscriptions=وأعضاء Suscriptions +MembersAndSubscriptions=وأعضاء Subscriptions // Date 2009-08-11 13:27:01 // STOP - Lines generated via parser diff --git a/htdocs/langs/bg_BG/members.lang b/htdocs/langs/bg_BG/members.lang index c2fabf1da50b0d94dee9632749eb56bbb31f7cc5..88d614bb1adcd58152fbf2f4d20390c79eac4233 100644 --- a/htdocs/langs/bg_BG/members.lang +++ b/htdocs/langs/bg_BG/members.lang @@ -163,7 +163,7 @@ ShowTypeCard=Покажи тип "%s" HTPasswordExport=htpassword файл поколение NoThirdPartyAssociatedToMember=Никоя трета страна, свързана с този потребител ThirdPartyDolibarr=Dolibarr трета страна -MembersAndSubscriptions=Членове и Suscriptions +MembersAndSubscriptions=Членове и Subscriptions MoreActions=Допълнително действие на запис MoreActionBankDirect=Създаване на директен запис на сделката по сметка MoreActionBankViaInvoice=Създаване на фактура и плащане по сметка diff --git a/htdocs/langs/ca_ES/commissions.lang b/htdocs/langs/ca_ES/commissions.lang deleted file mode 100644 index da97a4066f2dc6f99e2ce72c17347515c49fed12..0000000000000000000000000000000000000000 --- a/htdocs/langs/ca_ES/commissions.lang +++ /dev/null @@ -1,41 +0,0 @@ -# Dolibarr language file - ca_ES - commissions -CHARSET=UTF-8 - -Module60000Desc=Gestió de comissions -commissionsSetup=Configuració de la gestió de comissions - -ProductCommissionRate=Taxa de comissió sobre els productes -ServiceCommissionRate=Taxa de comissió sobre els serveis - -ProductCommissionRateDetails=Taxa usada per calcular les comissions sobre les vendes de productes -ServiceCommissionRateDetails=Taxa usada per calcular les comissions sobre les vendes de serveis - -Commissions=Comissions -CommissionDetails=Detall de comissions - -IncludeUnpayedInvoices=Incloure les factures no cobrades -TotalCommission=Total comissions - -ProductMargin=Marge / productes -ServiceMargin=Marge / serveis - -CommissionRate=Taxes comissions - -ProductCommission=Comissió / productes -ServiceCommission=Comissió / serveis - -CommissionBase=Base de càlcul de comissions -CommissionBasedOnTurnover=Comissions calculades sobre el volum de venda -CommissionBasedOnMargins=Comissions calculades sobre els marges -CommissionBaseDetails=Estableix el mètode de càlcul de les comissions -CommissionBasedOnMarginsDetails=El càlcul basat en els marges requereix l'activació del mòdul marges - -TurnoverTotal = Volum de vendes sense IVA -ProductTurnover=Vendes sense IVA / productes -ServiceTurnover=Vendes sense IVA / serveis - -CommercialAgent=Agent comercial - -StartDate=Data d'inici -EndDate=Data de fi -Launch=Començar \ No newline at end of file diff --git a/htdocs/langs/ca_ES/orders.lang b/htdocs/langs/ca_ES/orders.lang index 39ee41a4ca94f1971f5dd214914964298d463b93..a0a49bb243cabda7762d408028efc00f18e99a83 100644 --- a/htdocs/langs/ca_ES/orders.lang +++ b/htdocs/langs/ca_ES/orders.lang @@ -84,8 +84,8 @@ NumberOfOrdersByMonth=Nombre de comandes per mes AmountOfOrdersByMonthHT=Import total de comandes per mes (Sense IVA) ListOfOrders=Llistat de comandes CloseOrder=Tancar comanda -ConfirmCloseOrder=Esteu segur de voler tancar aquesta comanda? Un cop tancat, haurà de facturar-se -ConfirmCloseOrderIfSending=Esteu segur de voler tancar aquesta comanda? No ha de tancar una comanda que encara no té els seus productes enviats +ConfirmCloseOrder=Esteu segur que voleu classificar aquesta comanda com a enviat? Un cop enviat una comanda, només podrà facturar-se +ConfirmCloseOrderIfSending=Esteu segur que voleu tancar aquesta comanda? Només hauria de tancar una comanda quan aquesta hagi estat enviada completament. ConfirmDeleteOrder=Esteu segur de voler eliminar aquest comanda? ConfirmValidateOrder=Esteu segur de voler validar aquesta comanda sota la referència <b>%s</b> ? ConfirmUnvalidateOrder=Esteu segur de voler restaurar la comanda <b>%s</b> a l'estat esborrany? diff --git a/htdocs/langs/da_DK/members.lang b/htdocs/langs/da_DK/members.lang index c2975ad715c7ce9dedcc239e3b87a60cba5629c5..9492f48514aeddc318d8fa0c444313af34f91f6f 100644 --- a/htdocs/langs/da_DK/members.lang +++ b/htdocs/langs/da_DK/members.lang @@ -161,7 +161,7 @@ MemberId=Medlem id PaymentSubscription=Nye bidrag betaling NoThirdPartyAssociatedToMember=Nr. tredjepart forbundet til dette medlem ThirdPartyDolibarr=Dolibarr tredjepart -MembersAndSubscriptions=Medlemmer og Suscriptions +MembersAndSubscriptions=Medlemmer og Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 20:39:59). diff --git a/htdocs/langs/el_GR/members.lang b/htdocs/langs/el_GR/members.lang index 8343aff155cdfd97e4b843995677526c834ee919..270e3cd1f1e75dacec5bad40f46e8bea8ea9af14 100644 --- a/htdocs/langs/el_GR/members.lang +++ b/htdocs/langs/el_GR/members.lang @@ -152,7 +152,7 @@ ShowTypeCard=Show type '%s' HTPasswordExport=htpassword file generation NoThirdPartyAssociatedToMember=No third party associated to this member ThirdPartyDolibarr=Dolibarr third party -MembersAndSubscriptions= Members and Suscriptions +MembersAndSubscriptions= Members and Subscriptions MoreActions=Complementary action on recording MoreActionBankDirect=Create a direct transaction record on account MoreActionBankViaInvoice=Create an invoice and payment on account diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5e632efbe1ea5aa3b11d02814b9037e882770033..a9aae9516929cef18b26bb0e29943a059b0f34ea 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -369,7 +369,7 @@ Module1Desc=Companies and contact management (customers, prospects...) Module2Name=Commercial Module2Desc=Commercial management Module10Name=Accounting -Module10Desc=Simple accounting management (invoice and payment dispatching) +Module10Desc=Simple accounting reports (journals, turnover) based onto database content. No dispatching. Module20Name=Proposals Module20Desc=Commercial proposal management Module22Name=Mass E-mailings @@ -672,6 +672,10 @@ Permission1237=Export supplier orders and their details Permission1251=Run mass imports of external data into database (data load) Permission1321=Export customer invoices, attributes and payments Permission1421=Export customer orders and attributes +Permission23001 = Read Scheduled task +Permission23002 = Create/update Scheduled task +Permission23003 = Delete Scheduled task +Permission23004 = Execute Scheduled task Permission2401=Read actions (events or tasks) linked to his account Permission2402=Create/modify actions (events or tasks) linked to his account Permission2403=Delete actions (events or tasks) linked to his account diff --git a/htdocs/langs/en_US/commissions.lang b/htdocs/langs/en_US/commissions.lang deleted file mode 100644 index 776f4d0c1a1e1d6f21bdde518c5d776b75ab9e9b..0000000000000000000000000000000000000000 --- a/htdocs/langs/en_US/commissions.lang +++ /dev/null @@ -1,44 +0,0 @@ -# Dolibarr language file - fr_FR - commissions -CHARSET=UTF-8 - -Module60000Desc=Commissions management -commissionsSetup=Commissions management setup - -ProductCommissionRate=Commission rate on products -ServiceCommissionRate=Commission rate on services - -ProductCommissionRateDetails=Commission rate on product sales -ServiceCommissionRateDetails=Commission rate on service sales - -Commissions=Commissions -CommissionDetails=Commissions details - -IncludeUnpayedInvoices=Include overdue invoices -TotalCommission=Commissions subtotal - -ProductMargin=Margin / products -ServiceMargin=Margin / services - -CommissionRate=Commission rate - -ProductCommission=Commission / produics -ServiceCommission=Commission / services - -CommissionBase=Commissions base -CommissionBasedOnTurnover=Commissions based on turnover -CommissionBasedOnMargins=Commissions based on margins -CommissionBaseDetails=Define calculation method for commissions -CommissionBasedOnMarginsDetails=Commissions based on margins needs margin module activation. - -TurnoverTotal = Total turrnover -ProductTurnover=Product turnover -ServiceTurnover=Service turnover - -CommercialAgent=Commercial agent - -StartDate=Start date -EndDate=End date -Launch=Start - -AgentContactType=Contact type used for commissioning -AgentContactTypeDetails=Défine what contact type (linked on invoices) will be associated with commercial agents \ No newline at end of file diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 1ce5db6ccd497f46773b38a6bfb9cba1334be3e9..0ae15edba41cddb833c9f5e9774d5adb44489626 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -392,6 +392,7 @@ UniqueThirdParties=Total of unique third parties InActivity=Open ActivityCeased=Closed ActivityStateFilter=Activity status +ProductsIntoElements=List of products into # Monkey MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for supplier code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0. diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c38ccd07d689fa6234ffddce1cdd07f8f88fd459..538b4f1784a6b8829af8f8c55ebf4d90062faad1 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -149,4 +149,6 @@ WarningDepositsNotIncluded=Deposits invoices are not included in this version wi DatePaymentTermCantBeLowerThanObjectDate=Payment term date can't be lower than object date. Pcg_version=Pcg version Pcg_type=Pcg type -Pcg_subtype=Pcg subtype \ No newline at end of file +Pcg_subtype=Pcg subtype +InvoiceLinesToDispatch=Invoice lines to dispatch +InvoiceDispatched=Dispatched invoices \ No newline at end of file diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 4f504d34e5931aed73b71e02e95479035fa82d92..c64c74f1f5814b8c17e40d9251a7a42fbbd192f2 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -1,11 +1,87 @@ # Dolibarr language file - en_US - cron CHARSET=UTF-8 -CronSetup=Cron scheduler setup -CronDesc=This page can be used to setup options of the scheduler manager + +# +# Admin +# +CronSetup= Configuration Scheduled task management URLToLaunchCronJobs=URL to launch cron jobs +OrToLaunchASpecificJob=Or to launch a specific job KeyForCronAccess=Security key for URL to launch cron jobs -DateLastRun=Last run -LastOutput=Last run output -LastResult=Last result code -ListOfCronJobs=List of scheduled jobs -Command=Command \ No newline at end of file +FileToLaunchCronJobs=Command to launch cron jobs +CronExplainHowToRunUnix=On Unix environement you should use crontab to run Command line each minutes +CronExplainHowToRunWin=On Microsoft(tm) Windows environement you can use Scheduled task tools to run Command line each minutes + +# +# Page list +# +CronDateLastRun=Last run +CronLastOutput=Last run output +CronLastResult=Last result code +CronListOfCronJobs=List of scheduled jobs +CronCommand=Command +CronList= Job list +CronDelete= Delete cron jobs +CronConfirmDelete= Are you sure to delete this cron jobs ? +CronExecute=Launch task +CronConfirmExecute= Are you sure to execute this job now +CronInfo= Jobs allow to execute task that have been planned +CronWaitingJobs=Wainting jobs +CronTask=Task +CronNone= None +CronDtStart=Start date +CronDtEnd=End fin +CronDtNextLaunch=Next execution +CronDtLastLaunch=Last execution +CronFrequency=Frequancy +CronClass=Classe +CronMethod=Method +CronModule=Module +CronAction=Action +CronStatus=Status +CronStatusActive=Active +CronStatusInactive=Inactive +CronNoJobs=No jobs registered +CronPriority=Priority +CronLabel=Description +CronNbRun=Nb. launch + +# +#Page card +# +CronAdd= Add jobs +CronHourStart= Start Hour and date of task +CronEvery= And execute task each +CronObject= Instance/Object to create +CronArgs=Parameters +CronSaveSucess=Save succefully +CronNote=Comment +CronFieldMandatory=Fields %s is mandatory +CronErrEndDateStartDt=End date cannot be before start date +CronStatusActiveBtn=Active +CronStatusInactiveBtn=Inactive +CronTaskInactive=This task is inactive +CronDtLastResult=Last result date +CronId=Id +CronClassFile=Classes (file name) +CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module). <BR> For exemple to fetch method of Dolibarr Product object /htdocs/<u>product</u>/class/product.class.php, the value of module is <i>product</i> +CronClassFileHelp=The file name to load. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/<u>product.class.php</u>, the value of class file name is <i>product.class.php</i> +CronObjectHelp=The object name to load. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of class file name is <i>Product</i> +CronMethodHelp=The object method to launch. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of method is is <i>fecth</i> +CronArgsHelp=The method arguments. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of paramters can be <i>0, ProductRef</i> +CronCommandHelp=The system command line to execute. + +# +# Info +# +CronInfoPage=Information + + +# +# Common +# +CronType=Task type +CronType_method=Call method of a Dolibarr Class +CronType_command=Shell command +CronMenu=Cron +CronCannotLoadClass=Cannot load class %s or object %s \ No newline at end of file diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 0b82960dab24b0be0ea7411698bd90c29fefb9b8..99a60857e3d445b0689c682a188ea0c07731dd2d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -487,7 +487,7 @@ NbOfCustomers=Number of customers NbOfLines=Number of lines NbOfObjects=Number of objects NbOfReferers=Number of referrers -Referers=Referrers +Referers=Consumption TotalQuantity=Total quantity DateFromTo=From %s to %s DateFrom=From %s diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 77657563851bc635bdd1c7ac9e5e65a328d4a539..e1eda16c790b4c6d44044bc5277d84293932f172 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -155,7 +155,7 @@ ShowTypeCard=Show type '%s' HTPasswordExport=htpassword file generation NoThirdPartyAssociatedToMember=No third party associated to this member ThirdPartyDolibarr=Dolibarr third party -MembersAndSubscriptions= Members and Suscriptions +MembersAndSubscriptions= Members and Subscriptions MoreActions=Complementary action on recording MoreActionsOnSubscription=Complementary action, suggested by default when recording a subscription MoreActionBankDirect=Create a direct transaction record on account diff --git a/htdocs/langs/es_ES/commissions.lang b/htdocs/langs/es_ES/commissions.lang deleted file mode 100644 index 2077ca5990cc5d5595055fd3884a341b518ecd2b..0000000000000000000000000000000000000000 --- a/htdocs/langs/es_ES/commissions.lang +++ /dev/null @@ -1,41 +0,0 @@ -# Dolibarr language file - es_ES - commissions -CHARSET=UTF-8 - -Module60000Desc=Gestión de comisiones -commissionsSetup=Configuración de la gestión de comisiones - -ProductCommissionRate=Tasa de comisión sobre los productos -ServiceCommissionRate=Tasa de comisión sobre los servicios - -ProductCommissionRateDetails=Tasa usada para calcular las comisiones sobre las ventas de productos -ServiceCommissionRateDetails=Tasa usada para calcular las comisiones sobre las ventas de servicios - -Commissions=Comisiones -CommissionDetails=Detalle de comisiones - -IncludeUnpayedInvoices=Incluir las facturas no cobradas -TotalCommission=Total comisiones - -ProductMargin=Margen / productos -ServiceMargin=Margen / servicios - -CommissionRate=Tasas comisiones - -ProductCommission=Comisión / productos -ServiceCommission=Comisión / servicios - -CommissionBase=Base de cálculo de comisiones -CommissionBasedOnTurnover=Comisiones calculadas sobre el volumen de venta -CommissionBasedOnMargins=Comisiones calculadas sobre los márgenes -CommissionBaseDetails=Establece el método de cálculo de las comisiones -CommissionBasedOnMarginsDetails=El cálculo basado en los márgenes requiere la activación del módulo márgenes - -TurnoverTotal = Volumen de ventas sin IVA -ProductTurnover=Ventas sin IVA / productos -ServiceTurnover=Ventas sin IVA / servicios - -CommercialAgent=Agente comercial - -StartDate=Fecha de inicio -EndDate=Fecha de fin -Launch=Comenzar \ No newline at end of file diff --git a/htdocs/langs/es_ES/orders.lang b/htdocs/langs/es_ES/orders.lang index 65044ab09a72707bba735f2fb6383bab98b4edfc..3b1069cf7a608719325aabaab970b815375f0ddb 100644 --- a/htdocs/langs/es_ES/orders.lang +++ b/htdocs/langs/es_ES/orders.lang @@ -84,8 +84,8 @@ NumberOfOrdersByMonth=Número de pedidos por mes AmountOfOrdersByMonthHT=Importe total de pedidos por mes (sin IVA) ListOfOrders=Listado de pedidos CloseOrder=Cerrar pedido -ConfirmCloseOrder=¿Está seguro de querer cerrar este pedido? Una vez cerrado, deberá facturarse -ConfirmCloseOrderIfSending=¿Está seguro de querer cerrar este pedido? No debe cerrar un pedido que aún no tiene sus productos enviados +ConfirmCloseOrder=¿Está seguro de querer clasificar este pedido como enviado? Una vez enviado un pedido, solo podrá facturarse +ConfirmCloseOrderIfSending=¿Está seguro de querer cerrar este pedido? Solamente debería cerrar un pedido cuando este haya sido enviado completamente. ConfirmDeleteOrder=¿Está seguro de querer eliminar este pedido? ConfirmValidateOrder=¿Está seguro de querer validar este pedido bajo la referencia <b>%s</b> ? ConfirmUnvalidateOrder=¿Está seguro de querer restaurar el pedido <b>%s</b> al estado borrador? diff --git a/htdocs/langs/et_EE/members.lang b/htdocs/langs/et_EE/members.lang index b2d7eb1bc7a9957d7b8a8ad1de35aef74306c158..ef7bcef6304e2d33d050738615b7ffaefd319958 100644 --- a/htdocs/langs/et_EE/members.lang +++ b/htdocs/langs/et_EE/members.lang @@ -162,7 +162,7 @@ ShowTypeCard=Näita tüüp "%s" HTPasswordExport=htpassword fail põlvkonna NoThirdPartyAssociatedToMember=Ükski kolmas isik on seotud selle liige ThirdPartyDolibarr=Dolibarr kolmanda osapoole -MembersAndSubscriptions=Liikmete ja Suscriptions +MembersAndSubscriptions=Liikmete ja Subscriptions MoreActions=Täiendav tegevus salvestus MoreActionBankDirect=Loo otseseid tehingukulusid rekord konto MoreActionBankViaInvoice=Loo arve ja ettemaks diff --git a/htdocs/langs/fa_IR/members.lang b/htdocs/langs/fa_IR/members.lang index e7ecd54bf5ce9c9c2b39a70a9f697e2f61bd16e7..b0a46554eb667300d763003cc71a24e4108a2056 100644 --- a/htdocs/langs/fa_IR/members.lang +++ b/htdocs/langs/fa_IR/members.lang @@ -152,7 +152,7 @@ ShowTypeCard=وتبين من نوع '٪ ق' HTPasswordExport=الملف htpassword جيل NoThirdPartyAssociatedToMember=لم يرتبط بها من طرف ثالث لهذا العضو ThirdPartyDolibarr=Dolibarr طرف ثالث -MembersAndSubscriptions=وأعضاء Suscriptions +MembersAndSubscriptions=وأعضاء Subscriptions // Date 2009-08-11 13:27:01 // STOP - Lines generated via parser diff --git a/htdocs/langs/fi_FI/members.lang b/htdocs/langs/fi_FI/members.lang index b4c5c52f2d49693a24f93e46f48b3d47388d71c2..cad773224bc6c023c711ddcc085a5795c3a58566 100644 --- a/htdocs/langs/fi_FI/members.lang +++ b/htdocs/langs/fi_FI/members.lang @@ -159,7 +159,7 @@ MemberId=Jäsen id PaymentSubscription=Uusi osuus maksu NoThirdPartyAssociatedToMember=Kolmansista osapuolista ei näihin jäsen ThirdPartyDolibarr=Dolibarr kolmannen osapuolen -MembersAndSubscriptions=Jäsenet ja Suscriptions +MembersAndSubscriptions=Jäsenet ja Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 20:45:19). diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 3834defebc8e685bdfb326f885873eeaf1e35803..a20821cd61bac39f4e4fa25f1287eb08d7311d4b 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -368,7 +368,7 @@ Module1Desc= Gestion des tiers (sociétés, particuliers) et contacts Module2Name= Commercial Module2Desc= Gestion commerciale Module10Name= Comptabilité -Module10Desc= Gestion simpliste de comptabilité (ventilation de factures et paiements uniquement) +Module10Desc= Activation de rapports simplistes de comptabilité (ca, journaux) basé sur la base. Pas de ventilation. Module20Name= Propositions commerciales Module20Desc= Gestion des devis/propositions commerciales Module22Name= EMailings @@ -678,6 +678,10 @@ Permission1411= Lire les mouvements comptables Permission1412= Créer/modifier/annuler les mouvements comptables Permission1415= Lire CA, bilans, résultats, journaux, grands livres Permission1421= Exporter les commandes clients et attributs +Permission23001 = Voir les taches planifiée +Permission23002 = Créer/Modifier les taches planifiée +Permission23003 = Supprimer les taches planifiée +Permission23004 = Executer les taches planifiée Permission2401= Lire les actions (événements ou tâches) liées à son compte Permission2402= Créer/modifier les actions (événements ou tâches) liées à son compte Permission2403= Supprimer les actions (événements ou tâches) liées à son compte diff --git a/htdocs/langs/fr_FR/commissions.lang b/htdocs/langs/fr_FR/commissions.lang deleted file mode 100644 index 5fb83f3232000c4c488a3968daf092809138b419..0000000000000000000000000000000000000000 --- a/htdocs/langs/fr_FR/commissions.lang +++ /dev/null @@ -1,44 +0,0 @@ -# Dolibarr language file - fr_FR - commissions -CHARSET=UTF-8 - -Module60000Desc=Gestion des commissions -commissionsSetup=Paramétrage de la gestion des commissions - -ProductCommissionRate=Taux de commissionnement sur les produits -ServiceCommissionRate=Taux de commissionnement sur les services - -ProductCommissionRateDetails=Taux utilisé pour calculer les commissions sur les ventes de produits -ServiceCommissionRateDetails=Taux utilisé pour calculer les commissions sur les ventes de services - -Commissions=Commissions -CommissionDetails=Détail des commissions - -IncludeUnpayedInvoices=Inclure les factures non réglées -TotalCommission=Total des commissions - -ProductMargin=Marge / produits -ServiceMargin=Marge / services - -CommissionRate=Taux de commissionnement - -ProductCommission=Commission / produits -ServiceCommission=Commission / services - -CommissionBase=Base de calcul des commissions -CommissionBasedOnTurnover=Commissions calculées sur le CA -CommissionBasedOnMargins=Commissions calculées sur les marges -CommissionBaseDetails=Définit le mode de calcul des commissions -CommissionBasedOnMarginsDetails=Le calcul basé sur les marges nécessite l'activation du module marges. - -TurnoverTotal = Chiffre d'affaire réalisé HT -ProductTurnover=CA HT / produits -ServiceTurnover=CA HT / services - -CommercialAgent=Agent commercial - -StartDate=Date de début -EndDate=Date de fin -Launch=Démarrer - -AgentContactType=Type de contact commissionné -AgentContactTypeDetails=Permet de définir le type de contact associé aux factures qui sera associé aux agents commerciaux \ No newline at end of file diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 254d1e8af1656cd86e8853535f504fe775c65d9e..99612d8ec2dbe2f8c9355124ee7d7a08638a9d05 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -394,6 +394,7 @@ UniqueThirdParties=Total de tiers uniques InActivity=En activité ActivityCeased=Clos ActivityStateFilter=Statut d'activité +ProductsIntoElements=Liste des produits dans les %s # Monkey MonkeyNumRefModelDesc=Renvoie le numéro sous la forme %syymm-nnnn pour les codes clients et %syymm-nnnn pour les codes fournisseurs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0. diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 01ba085620bcc1a3e887554f98b19a03f199bba1..12ea0024f63875610d587bff35b0321d827329a6 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -161,3 +161,5 @@ DatePaymentTermCantBeLowerThanObjectDate=La date limite de règlement ne peut ê Pcg_version=Version du plan Pcg_type=Classe de compte Pcg_subtype=Sous classe de compte +InvoiceLinesToDispatch=Lignes de factures à ventiler +InvoiceDispatched=Factures ventilées \ No newline at end of file diff --git a/htdocs/langs/fr_FR/cron.lang b/htdocs/langs/fr_FR/cron.lang index 1a9bf136e0284e81978df4e4d1c000f9347fce8e..d0aaccfecf71fcd8b5dc311dbdb2ea9c2b6e207c 100644 --- a/htdocs/langs/fr_FR/cron.lang +++ b/htdocs/langs/fr_FR/cron.lang @@ -1,11 +1,93 @@ # Dolibarr language file - fr_FR - cron CHARSET=UTF-8 -CronSetup=Configuration du séquenceur de taches -CronDesc=Cette page permet de configurer certaines options du séquenceur de taches + +# +# Admin +# +CronSetup = Page de configuration du module - Gestion de tâches planifiées URLToLaunchCronJobs=URL pour lancer les taches automatiques +OrToLaunchASpecificJob=Ou pour lancer une tache spécifique KeyForCronAccess=Clé de sécurité pour l'URL de lancement des taches automatiques -DateLastRun=Dernier lancement -LastOutput=Dernière sortie -LastResult=Dernière code retour -ListOfCronJobs=Liste des taches programmées -Command=Commande \ No newline at end of file +FileToLaunchCronJobs=Commande pour lancer les taches automatiques +CronExplainHowToRunUnix=Sur un environement Unix vous pouvez paramétré CronTab pour executer cette commande toute les minutes +CronExplainHowToRunWin=Sur un environement Microsoft(tm) Windows vous pouvez utilisr le planificateur de tache pour lancer cette commande toute les minutes + +# +# Menu +# +CronListActive= Liste des tâches planifiées active +CronListInactive= Liste des tâches planifiées inactive + + +# +# Page list +# +CronDateLastRun=Dernier lancement +CronLastOutput=Dernière sortie +CronLastResult=Dernier code retour +CronCommand=Commande +CronList= Liste des tâches planifiées +CronDelete= Supprimer la tâche planifiée +CronConfirmDelete= Êtes-vous sûr de vouloir supprimer cette tâche planifiée ? +CronExecute=Exécuter cette tâche +CronConfirmExecute= Êtes-vous sûr de vouloir exécuter cette tâche maintenant? +CronInfo= Les jobs permettent d'exécuter des tâches à intervales réguliers +CronWaitingJobs= Vos jobs en attente: +CronTask= Tâche +CronNone=Aucun(e) +CronDtStart=Date début +CronDtEnd=Date fin +CronDtNextLaunch=Prochaine éxécution +CronDtLastLaunch=Dernière éxécution +CronFrequency=Fréquence +CronClass=Classes +CronMethod=Méthode +CronModule=Module +CronAction=Action +CronStatus=Status +CronStatusActive=Active +CronStatusInactive=Inactive +CronEach=Tou(te)s +CronNoJobs= Aucun jobs actuellement +CronPriority=Priorité +CronLabel=Description +CronNbRun=Nb. exec. +CronDtLastResult=Date du derniétre resulat de la dernière éxécution + +# +#Page card +# +CronAdd= Ajoutez une tâche +CronHourStart= Jour et Heure de début de la tâche +CronEvery= Puis execution toutes les +CronObject= Instance/Objet à créer +CronArgs= Argument +CronSaveSucess=Enregistrement effectué +CronNote=Note +CronFieldMandatory=Le champ %s est obligatoire +CronErrEndDateStartDt=La date de fin ne peux être avant la date de début +CronStatusActiveBtn=Activer +CronStatusInactiveBtn=Désactiver +CronTaskInactive=Cette tâche est désactivée +CronId=Id +CronClassFile=Classes (fichier) +CronModuleHelp=Nom du repertoire du module dolibarr (fonctionne automatiquement avec les modules externe Dolibarr). <BR> Par exemple pour appeler la mèthode fetch de l'object Product de Dolibarr /htdocs/<u>product</u>/class/product.class.php, la valeur de module est <i>product</i> +CronClassFileHelp=Le fichier qui contient l'objet . <BR> Par exemple pour appeler la mèthode fetch de l'object Product de Dolibarr /htdocs/product/class/<u>product.class.php</u>, la valeur de classe est <i>product.class.php</i> +CronObjectHelp=Le nom de l'object a crée. <BR> Par exemple pour appeler la mèthode fetch de l'object Product de Dolibarr /htdocs/product/class/product.class.php, la valeur de objet est <i>Product</i> +CronMethodHelp=La mèthode a lancer. <BR> Par exemple pour appeler la mèthode fetch de l'object Product de Dolibarr /htdocs/product/class/product.class.php, la valeur de mèthode est <i>fecth</i> +CronArgsHelp=Les arguments de la mèthode. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, la valeur de paramétre pourrait être <i>0, RefProduit</i> +CronCommandHelp=La commande système a éxecuter + +# +# Info +# +CronInfoPage=Suivie + +# +# Common +# +CronType=Type d'action a executer +CronType_method=Méthode d'une classe d'un module Dolibarr +CronType_command=Commande Shell +CronMenu=Cron +CronCannotLoadClass=impossible de charger la classe %s ou l'object %s \ No newline at end of file diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index a7093fd8b75f6643cf3afbd812f7d0853d4040d3..b31b711f3a37b4b641768a4f2b6cfddbc975f83f 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -490,7 +490,7 @@ NbOfCustomers=Nombre de clients NbOfLines=Nombre de lignes NbOfObjects=Nombre d'objets NbOfReferers=Nombre de références -Referers=Référents +Referers=Consommation TotalQuantity=Quantité totale DateFromTo=Du %s au %s DateFrom=A partir du %s diff --git a/htdocs/langs/he_IL/members.lang b/htdocs/langs/he_IL/members.lang index b8f1a2389d06c59a4a7b9c5dc314b2d1157b1f7f..647559b284a7dc929eb49c82899d4330449333af 100644 --- a/htdocs/langs/he_IL/members.lang +++ b/htdocs/langs/he_IL/members.lang @@ -162,7 +162,7 @@ ShowTypeCard=הצג מסוג "%s" HTPasswordExport=htpassword הדור הקובץ NoThirdPartyAssociatedToMember=אין צד שלישי הקשור משתמש זה ThirdPartyDolibarr=Dolibarr צד שלישי -MembersAndSubscriptions=משתמשים ו Suscriptions +MembersAndSubscriptions=משתמשים ו Subscriptions MoreActions=פעולה משלימה על ההקלטה MoreActionBankDirect=יצירת הרשומה העסקה ישירה על חשבון MoreActionBankViaInvoice=יצירת חשבונית התשלום על חשבון diff --git a/htdocs/langs/hu_HU/members.lang b/htdocs/langs/hu_HU/members.lang index a1baf95f0c6509a60438415400f67961857a4075..ff2cbf8d7ec42e37f4c4934ec1c47a3169449e50 100644 --- a/htdocs/langs/hu_HU/members.lang +++ b/htdocs/langs/hu_HU/members.lang @@ -162,7 +162,7 @@ ShowTypeCard=Mutasd típusú "%s" HTPasswordExport=htpassword fájl létrehozása NoThirdPartyAssociatedToMember=Harmadik félnek nem társult a tag ThirdPartyDolibarr=Dolibarr harmadik fél -MembersAndSubscriptions=A tagok és Suscriptions +MembersAndSubscriptions=A tagok és Subscriptions MoreActions=Kiegészítő fellépés a felvételi MoreActionBankDirect=Hozzon létre egy közvetlen tranzakciós rekord miatt MoreActionBankViaInvoice=Hozzon létre egy számlát és előleg diff --git a/htdocs/langs/is_IS/members.lang b/htdocs/langs/is_IS/members.lang index d64fc0dbd558c10549fa59185c89e60b201b3094..20f211f24eff292d273717c7d92354910001e1b3 100644 --- a/htdocs/langs/is_IS/members.lang +++ b/htdocs/langs/is_IS/members.lang @@ -157,7 +157,7 @@ ShowTypeCard=Sýna tegund ' %s ' HTPasswordExport=htpassword skrá kynslóð NoThirdPartyAssociatedToMember=Engar þriðja aðila í tengslum við þennan ThirdPartyDolibarr=Dolibarr þriðja aðila -MembersAndSubscriptions=Aðilar og Suscriptions +MembersAndSubscriptions=Aðilar og Subscriptions // STOP - Lines generated via autotranslator.php tool (2010-06-30 00:15:29). diff --git a/htdocs/langs/it_IT/members.lang b/htdocs/langs/it_IT/members.lang index 4000e50c5140934f44f84aa8c691819b724a0840..e1645587088065ea3ad2763fddc164901a56f24d 100644 --- a/htdocs/langs/it_IT/members.lang +++ b/htdocs/langs/it_IT/members.lang @@ -88,7 +88,7 @@ MemberModifiedInDolibarr =Membri modificati su Dolibarr MEMBER_NEWFORM_PAYONLINE =Saltate sulla integrato pagina di pagamento online MemberNotOrNoMoreExpectedToSubscribe =Membri non iscritti o non più attesi per iscrizione MemberPublicLinks =Link/pagine pubbliche -MembersAndSubscriptions =Deputati e Suscriptions +MembersAndSubscriptions =Deputati e Subscriptions MembersArea =Sezione riservata membri MembersAttributes =Attributi dei membri MembersByCountryDesc =Questa schermata mostra le statistiche dei membri per paese. Il grafico dipende da servizi online di Google ed è disponibile solo se il server può connettersi ad internet. diff --git a/htdocs/langs/ja_JP/members.lang b/htdocs/langs/ja_JP/members.lang index 4fee5b4235509eb8c6bddac74158faed4a5aebba..afc8a3f759b1854651c7217a0744a4a74f8e63ed 100644 --- a/htdocs/langs/ja_JP/members.lang +++ b/htdocs/langs/ja_JP/members.lang @@ -162,7 +162,7 @@ ShowTypeCard=タイプ "%s"を表示 HTPasswordExport=htpasswordファイルの生成 NoThirdPartyAssociatedToMember=このメンバに関連付けられているサードパーティません ThirdPartyDolibarr=Dolibarrサードパーティ -MembersAndSubscriptions=メンバーとSuscriptions +MembersAndSubscriptions=メンバーとSubscriptions MoreActions=記録上の相補的なアクション MoreActionBankDirect=アカウントに直接トランザクション·レコードを作成します。 MoreActionBankViaInvoice=アカウントの請求書と支払いを作成します。 diff --git a/htdocs/langs/nb_NO/members.lang b/htdocs/langs/nb_NO/members.lang index 471b4e735a98d5a39ef381267d19fd94dfc4cbab..62c8faf88225da292e4bd38f1920cc20dfd02e85 100644 --- a/htdocs/langs/nb_NO/members.lang +++ b/htdocs/langs/nb_NO/members.lang @@ -29,7 +29,7 @@ DescADHERENT_CARD_TEXT_RIGHT=Tekst trykt på kort medlem (justere på høyre) DescADHERENT_MAILMAN_LISTS=Liste (er) for automatisk insription av nye medlemmer (separert med komma) NoThirdPartyAssociatedToMember=Ingen tredjepart knyttet til dette medlemmet ThirdPartyDolibarr=Dolibarr tredjepart -MembersAndSubscriptions=Medlemmer og Suscriptions +MembersAndSubscriptions=Medlemmer og Subscriptions // STOP - Lines generated via autotranslator.php tool (2010-07-17 11:48:27). diff --git a/htdocs/langs/pl_PL/members.lang b/htdocs/langs/pl_PL/members.lang index 4782007adfd8cbea01cd84b123bdf324742578ab..0810e643b43c18cfeb3198b22a659f7f306b6ce9 100644 --- a/htdocs/langs/pl_PL/members.lang +++ b/htdocs/langs/pl_PL/members.lang @@ -162,7 +162,7 @@ MemberId=Państwa id PaymentSubscription=Nowy wkład płatności NoThirdPartyAssociatedToMember=Nr trzeciej związane do tego członka ThirdPartyDolibarr=Dolibarr trzeciej -MembersAndSubscriptions=Członkowie i Suscriptions +MembersAndSubscriptions=Członkowie i Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 21:07:31). diff --git a/htdocs/langs/pt_PT/members.lang b/htdocs/langs/pt_PT/members.lang index 0c42a9c32953001631f7d7e8a960545668b2269b..d82002190b51db8bd56761b1a8f5eaa0fe7fb12a 100644 --- a/htdocs/langs/pt_PT/members.lang +++ b/htdocs/langs/pt_PT/members.lang @@ -149,7 +149,7 @@ SetLinkToThirdParty=Link para uma Dolibarr terceiro SubscriptionId=Assinaturas id MemberId=Estados-id PaymentSubscription=Nova contribuição pagamento -MembersAndSubscriptions=Deputados e Suscriptions +MembersAndSubscriptions=Deputados e Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 21:10:10). diff --git a/htdocs/langs/ro_RO/members.lang b/htdocs/langs/ro_RO/members.lang index 067614c8b3060dc65fa68a92a8771b2ede5298b5..d14d60ab82b3691a78ff1513cabf817cccf620c3 100644 --- a/htdocs/langs/ro_RO/members.lang +++ b/htdocs/langs/ro_RO/members.lang @@ -160,7 +160,7 @@ MemberId=Statele id PaymentSubscription=New plata contribuţiei NoThirdPartyAssociatedToMember=Nu părţi terţe asociate la prezenta membru ThirdPartyDolibarr=Dolibarr terţă parte -MembersAndSubscriptions=Membrii şi Suscriptions +MembersAndSubscriptions=Membrii şi Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 21:12:07). diff --git a/htdocs/langs/sv_SE/members.lang b/htdocs/langs/sv_SE/members.lang index bf398731fe3d978feb71e023d1d44454d512de65..ded4d0542d6b54ac7c1878abcd9b8400b8e04b47 100644 --- a/htdocs/langs/sv_SE/members.lang +++ b/htdocs/langs/sv_SE/members.lang @@ -157,7 +157,7 @@ ShowTypeCard=Visa typ "%s" HTPasswordExport=htpassword fil generation NoThirdPartyAssociatedToMember=Ingen tredje part som är associerade till denna medlem ThirdPartyDolibarr=Dolibarr tredje part -MembersAndSubscriptions=Medlemmar och Suscriptions +MembersAndSubscriptions=Medlemmar och Subscriptions // STOP - Lines generated via autotranslator.php tool (2010-08-27 08:51:26). diff --git a/htdocs/langs/zh_TW/members.lang b/htdocs/langs/zh_TW/members.lang index c08035af7a17a645d831cdd54d8c8c3614887dbe..1b344cfd4523df15f32c6866774a7ca1276f4889 100644 --- a/htdocs/langs/zh_TW/members.lang +++ b/htdocs/langs/zh_TW/members.lang @@ -157,7 +157,7 @@ ShowTypeCard=顯示類型'%s' HTPasswordExport=htpassword文件生成 NoThirdPartyAssociatedToMember=無關聯的第三方該會員 ThirdPartyDolibarr=Dolibarr第三者 -MembersAndSubscriptions=議員和Suscriptions +MembersAndSubscriptions=議員和Subscriptions // STOP - Lines generated via autotranslator.php tool (2010-06-08 21:22:55). diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index a195ef6de048b2ddc6cdeaf59e1b5300934cb756..6ca0879a88af3c48fcc8fd249b7d940dcbebfb8e 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> +/* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr> * * 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 @@ -40,7 +40,13 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; +if (! $sortfield) +{ + if ($agentid > 0) + $sortfield="s.nom"; + else + $sortfield="u.name"; +} $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; @@ -75,7 +81,7 @@ $titre=$langs->trans("Margins"); $picto='margin'; dol_fiche_head($head, 'agentMargins', $titre, 0, $picto); -print '<form method="post" name="sel">'; +print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">'; print '<table class="border" width="100%">'; print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>'; @@ -118,10 +124,11 @@ if (! empty($conf->global->DISPLAY_MARK_RATES)) { print "</table>"; print '</form>'; -$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,"; -$sql.= " u.login,"; -$sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,"; -$sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge" ; +$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, u.rowid as agent,"; +$sql.= " u.login, u.name, u.firstname,"; +$sql.= " sum(d.total_ht) as selling_price,"; +$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; +$sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge" ; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE); @@ -155,7 +162,8 @@ if ($agentid > 0) else $sql.= " GROUP BY u.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit +1, $offset); +// TODO: calculate total to display then restore pagination +//$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) @@ -163,7 +171,7 @@ if ($result) $num = $db->num_rows($result); print '<br>'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',0,0,''); $i = 0; print "<table class=\"noborder\" width=\"100%\">"; @@ -172,7 +180,7 @@ if ($result) if ($agentid > 0) print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); else - print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.name","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buying_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); @@ -191,7 +199,7 @@ if ($result) if ($num > 0) { $var=true; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); @@ -208,9 +216,8 @@ if ($result) print "<td>".$companystatic->getNomUrl(1,'customer')."</td>\n"; } else { - $userstatic->id=$objp->agent; - $userstatic->login=$objp->login; - print "<td>".$userstatic->getLoginUrl(1)."</td>\n"; + $userstatic->fetch($objp->agent); + print "<td>".$userstatic->getFullName($langs,0,0,0)."</td>\n"; } print "<td align=\"right\">".price($objp->selling_price)."</td>\n"; print "<td align=\"right\">".price($objp->buying_price)."</td>\n"; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 23fb49dab87bce0ec8dc7ed71dfc7ce4632b6da0..a07d3192e9b15de2ad4b68d7d7a490b8293e5149 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> +/* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr> * * 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 @@ -40,10 +40,6 @@ $result = restrictedArea($user, 'societe','',''); $mesg = ''; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; @@ -77,7 +73,7 @@ $titre=$langs->trans("Margins"); $picto='margin'; dol_fiche_head($head, 'customerMargins', $titre, 0, $picto); -print '<form method="post" name="sel">'; +print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">'; print '<table class="border" width="100%">'; $client = false; @@ -105,6 +101,23 @@ else { print '</td></tr>'; } +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) +{ + if ($client) + { + $sortfield="f.datef"; + $sortorder="DESC"; + } + else + { + $sortfield="s.nom"; + $sortorder="ASC"; + } +} + // Start date print '<td>'.$langs->trans('StartDate').'</td>'; print '<td width="20%">'; @@ -142,8 +155,9 @@ print '</form>'; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client,"; $sql.= " f.facnumber, f.total as total_ht,"; -$sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,"; -$sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge," ; +$sql.= " sum(d.total_ht) as selling_price,"; +$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; +$sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; @@ -166,7 +180,8 @@ if ($client) else $sql.= " GROUP BY s.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit +1, $offset); +// TODO: calculate total to display then restore pagination +//$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) @@ -174,7 +189,7 @@ if ($result) $num = $db->num_rows($result); print '<br>'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',0,0,''); $i = 0; print "<table class=\"noborder\" width=\"100%\">"; @@ -203,7 +218,7 @@ if ($result) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 4f22ba5599e320b78befee4462a43e3ae30495b0..3b709559f289e1a1b62cc9c1d38a0ed7e766ddb6 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> +/* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr> * * 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 @@ -48,7 +48,20 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="p.ref"; +if (! $sortfield) +{ + if ($id > 0) + { + $sortfield="f.datef"; + $sortorder="DESC"; + } + else + { + $sortfield="p.ref"; + $sortorder="ASC"; + } +} + $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; @@ -83,7 +96,7 @@ $titre=$langs->trans("Margins"); $picto='margin'; dol_fiche_head($head, 'productMargins', $titre, 0, $picto); -print '<form method="post" name="sel">'; +print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">'; print '<table class="border" width="100%">'; if ($id > 0) { @@ -144,8 +157,9 @@ print '</form>'; $sql = "SELECT DISTINCT d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref,"; $sql.= " f.facnumber, f.total as total_ht,"; -$sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,"; -$sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge," ; +$sql.= " sum(d.total_ht) as selling_price,"; +$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; +$sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; @@ -170,7 +184,8 @@ if ($id > 0) else $sql.= " GROUP BY d.fk_product"; $sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit +1, $offset); +// TODO: calculate total to display then restore pagination +//$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) @@ -178,7 +193,7 @@ if ($result) $num = $db->num_rows($result); print '<br>'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',0,0,''); $i = 0; print "<table class=\"noborder\" width=\"100%\">"; @@ -207,7 +222,7 @@ if ($result) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 407f3603d49a9217d381fbcd1cf6bdcc7fb682b7..326efc526d21eb1f4d1f1b471e8d6660791ea7fb 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> +/* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr> * * 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 @@ -130,7 +130,10 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT DISTINCT s.nom, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.total as total_ht,"; - $sql.= " (d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price, (d.buy_price_ht * d.qty) as buying_price, d.qty, ((d.subprice - d.buy_price_ht) * d.qty) as marge," ; + $sql.= " d.total_ht as selling_price,"; + $sql.= $db->ifsql('f.type =2','(d.buy_price_ht * d.qty *-1)','(d.buy_price_ht * d.qty)')." as buying_price, "; + $sql.= $db->ifsql('f.type =2','d.qty *-1','d.qty')." as qty,"; + $sql.= $db->ifsql('f.type =2','((d.price + d.buy_price_ht) * d.qty)','((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -148,14 +151,15 @@ if ($id > 0 || ! empty($ref)) if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; $sql.= " ORDER BY $sortfield $sortorder "; - $sql.= $db->plimit($conf->liste_limit +1, $offset); + // TODO: calculate total to display then restore pagination + //$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$object->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$object->id",$sortfield,$sortorder,'',0,0,''); $i = 0; print "<table class=\"noborder\" width=\"100%\">"; @@ -184,7 +188,7 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); $var=!$var; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index cbb42401b5a105f4ed96d6a1222201f2295f5c2d..643d190d04da60ef6626dc51d8118a3a10a077b7 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> +/* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr> * * 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 @@ -128,7 +128,10 @@ if ($socid > 0) $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.total as total_ht,"; - $sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price, sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge," ; + $sql.= " sum(d.total_ht) as selling_price,"; + + $sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; + $sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; @@ -143,14 +146,15 @@ if ($socid > 0) $sql .= " AND d.buy_price_ht <> 0"; $sql.= " GROUP BY f.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; - $sql.= $db->plimit($conf->liste_limit +1, $offset); + // TODO: calculate total to display then restore pagination + //$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',0,0,''); $i = 0; print "<table class=\"noborder\" width=\"100%\">"; @@ -176,7 +180,7 @@ if ($socid > 0) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index 75e15a414a0ba4477a1ff9654d189e37a14d6ffe..838c298212f669f4029d79091d61d7d5d852f801 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -1,5 +1,6 @@ <?php -/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry <forian.henry@open-cocnept.pro * * 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 @@ -16,158 +17,126 @@ */ /** - * \file cron/cron_run_jobs.php - * \ingroup cron - * \brief This file is the page to call to run jobs - * Initialy built by build_class_from_table on 2013-03-17 18:50 + * \file cron/public/cron/cron_run_jobs.php + * \ingroup cron + * \brief Execute pendings jobs */ - -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +if (! defined('NOLOGIN')) define('NOLOGIN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - -// Change this following line to use the correct relative path (../, ../../, etc) -$res=0; -if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; -if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; -if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php'; -if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res) die("Include of main fails"); -// Change this following line to use the correct relative path from htdocs -include_once(DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php'); - - -// C'est un wrapper, donc header vierge -/** - * Header function - * - * @return void - */ -function llxHeaderVierge() { - print '<html><title>Export agenda cal</title><body>'; -} -/** - * Footer function - * - * @return void - */ -function llxFooterVierge() { - print '</body></html>'; -} +// librarie core +// Dolibarr environment +$res = @include("../../main.inc.php"); // From htdocs directory +if (! $res) { + $res = @include("../../../main.inc.php"); // From "custom" directory +} +if (! $res) die("Include of master.inc.php fails"); +// librarie jobs +dol_include_once("/cron/class/cronjob.class.php"); -// Load traductions files requiredby by page -$langs->load("companies"); -$langs->load("other"); -$langs->load("cron@cron"); -// Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); +global $langs, $conf; -// Protection if external user -if ($user->societe_id > 0) +// Check the key, avoid that a stranger starts cron +$key = $_GET['securitykey']; +if (empty($key)) { + echo 'securitykey is require'; + exit; +} +if($key != $conf->global->MAIN_CRON_KEY) { - //accessforbidden(); + echo 'securitykey is wrong'; + exit; } - -// Security check -if (empty($conf->cron->enabled)) accessforbidden('',1,1,1); - -// Check also security key -if (empty($_GET["securitykey"]) || $conf->global->CRON_KEY != $_GET["securitykey"]) -{ - $user->getrights(); - - llxHeaderVierge(); - print '<div class="error">Bad value for key.</div>'; - llxFooterVierge(); - exit; +// Check the key, avoid that a stranger starts cron +$userlogin = $_GET['userlogin']; +if (empty($userlogin)) { + echo 'userlogin is require'; + exit; } - - -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ - -if ($action == 'add') -{ - $object=new Cronjobs($db); - $object->prop1=$_POST["field1"]; - $object->prop2=$_POST["field2"]; - $result=$object->create($user); - if ($result > 0) - { - // Creation OK - } - { - // Creation KO - $mesg=$object->error; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +$user=new User($db); +$result=$user->fetch('',$userlogin); +if ($result<0) { + echo "User Error:".$user->error; + dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); + exit; +}else { + if (empty($user->id)) { + echo " User user login:".$userlogin." do not exists"; + dol_syslog(" User user login:".$userlogin." do not exists", LOG_ERR); + exit; } } +$id = $_GET['id']; +// Language Management +$langs->load("admin"); +$langs->load("cron@cron"); +// create a jobs object +$object = new Cronjob($db); +$filter=array(); +if (empty($id)) { + $filter=array(); + $filter['t.rowid']=$id; +} +$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter); +if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); + exit; +} -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ - -llxHeader('',$langs->trans('CronList'),''); - -$form=new Form($db); - - -// Put here content of your page - -// Example 1 : Adding jquery code -print '<script type="text/javascript" language="javascript"> -jQuery(document).ready(function() { - function init_myfunc() - { - jQuery("#myid").removeAttr(\'disabled\'); - jQuery("#myid").attr(\'disabled\',\'disabled\'); +// current date +$now=dol_now(); + +if(is_array($object->lines) && (count($object->lines)>0)){ + // Loop over job + foreach($object->lines as $line){ + + dol_syslog("cron_run_jobs.php:: fetch cronjobid:".$line->id, LOG_ERR); + + //If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database + if ((($line->datenextrun <= $now) && $line->dateend < $now) + || ((empty($line->datenextrun)) && (empty($line->dateend)))){ + + dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun,'dayhourtext')." line->dateend:".dol_print_date($line->dateend,'dayhourtext')." now:".dol_print_date($now,'dayhourtext'), LOG_ERR); + + $cronjob=new Cronjob($db); + $result=$cronjob->fetch($line->id); + if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); + exit; + } + // execute methode + $result=$cronjob->run_jobs($userlogin); + if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR); + exit; + } + + // we re-program the next execution and stores the last execution time for this job + $result=$cronjob->reprogram_jobs($userlogin); + if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR); + exit; + } + + } } - init_myfunc(); - jQuery("#mybutton").click(function() { - init_needroot(); - }); -}); -</script>'; - - -$cronjob=new CronJob($db); -$result=$cronjob->fetch($id); - -if ($result > 0) -{ - - -} -else -{ - $langs->load("errors"); - print $langs->trans("ErrorRecordNotFound"); + echo "OK"; +} else { + echo "No Jobs to run"; } - - -// End of page -llxFooter(); - -$db->close(); -?> diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php new file mode 100644 index 0000000000000000000000000000000000000000..4f61d24a4aa069812ee7c5783826ad53f80c79b5 --- /dev/null +++ b/htdocs/societe/consumption.php @@ -0,0 +1,439 @@ +<?php +/* Copyright (C) 2012-2013 Philippe Berthet <berthet@systune.be> + * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> + * + * Version V1.1 Initial version of Philippe Berthet + * Version V2 Change to be compatible with 3.4 and enhanced to be more generic + * + * 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/>. + */ + +/** + * \file htdocs/societe/consumption.php + * \ingroup societe + * \brief Add a tab on thirpdarty view to list all products/services bought or sells by thirdparty + */ + +require("../main.inc.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + +// Security check +$socid = GETPOST('socid','int'); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'societe', $socid, '&societe'); +$object = new Societe($db); +if ($socid > 0) $object->fetch($socid); + +// Sort & Order fields +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { + $page = 0; +} +$offset = $conf->liste_limit * $page; +if (! $sortorder) $sortorder='DESC'; +if (! $sortfield) $sortfield='datePrint'; +$limit = $conf->liste_limit; + +// Search fields +$sref=GETPOST("sref"); +$sprod_fulldescr=GETPOST("sprod_fulldescr"); +$month = GETPOST('month','int'); +$year = GETPOST('year','int'); + +// Clean up on purge search criteria ? +if (GETPOST("button_removefilter")) +{ + $sref=''; + $sprod_fulldescr=''; + $year=''; + $month=''; +} +// Customer or supplier selected in drop box +$thirdTypeSelect = GETPOST("third_select_id"); +$type_element = GETPOST('type_element')?GETPOST('type_element'):'invoice'; + +$langs->load("bills"); +$langs->load("orders"); +$langs->load("suppliers"); + + +/* + * Actions + */ + + + +/* + * View + */ + +$form = new Form($db); +$formother = new FormOther($db); +$productstatic=new Product($db); + +$titre = $langs->trans("Referer",$object->name); +llxHeader('',$titre,''); + +if (empty($socid)) +{ + dol_print_error($db); + exit; +} + +$head = societe_prepare_head($object); +dol_fiche_head($head, 'consumption', $langs->trans("ThirdParty"),0,'company'); + +print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; +print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; +print '<input type="hidden" name="socid" value="'.$socid.'">'; + +print '<table class="border" width="100%">'; +print '<tr><td width="30%">'.$langs->trans('ThirdPartyName').'</td>'; +print '<td colspan="3">'; +print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); +print '</td></tr>'; + +if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field +{ + print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; +} + +if ($object->client) +{ + print '<tr><td>'; + print $langs->trans('CustomerCode').'</td><td colspan="3">'; + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; + print '</td></tr>'; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; + $resql=$db->query($sql); + if (!$resql) dol_print_error($db); + + $obj = $db->fetch_object($resql); + $nbFactsClient = $obj->nb; + $thirdTypeArray['customer']=$langs->trans("customer"); + if ($conf->facture->enabled) $elementTypeArray['invoice']=$langs->trans('Invoices'); + if ($conf->commande->enabled) $elementTypeArray['order']=$langs->trans('Orders'); +} + +if ($object->fournisseur) +{ + print '<tr><td>'; + print $langs->trans('SupplierCode').'</td><td colspan="3">'; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; + print '</td></tr>'; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid; + $resql=$db->query($sql); + if (!$resql) dol_print_error($db); + + $obj = $db->fetch_object($resql); + $nbCmdsFourn = $obj->nb; + $thirdTypeArray['supplier']=$langs->trans("supplier"); + if ($conf->fournisseur->enabled) $elementTypeArray['supplier_invoice']=$langs->trans('SuppliersInvoices'); + if ($conf->fournisseur->enabled) $elementTypeArray['supplier_order']=$langs->trans('SuppliersOrders'); +} +print '</table>'; + +dol_fiche_end(); +print '<br>'; + + +$sql_select=''; +if ($type_element == 'invoice') +{ // Customer : show products from invoices +$documentstatic=new Facture($db); +$sql_select = 'SELECT f.rowid as doc_id, f.facnumber as doc_number, f.type as doc_type, f.datef as datePrint, '; +$tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d"; +$where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; +$where.= " AND d.fk_facture = f.rowid"; +$where.= " AND f.entity = ".$conf->entity; +$datePrint = 'f.datef'; +$doc_number='f.facnumber'; +$thirdTypeSelect='customer'; +} +if ($type_element == 'order') +{ + // TODO + +} +if ($type_element == 'supplier_order') +{ // Supplier : Show products from orders. +$documentstatic=new CommandeFournisseur($db); +$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, "1" as doc_type, c.date_valid as datePrint, '; +$tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d"; +$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; +$where.= " AND d.fk_commande = c.rowid"; +$datePrint = 'c.date_creation'; +$doc_number='c.ref'; +$thirdTypeSelect='supplier'; +} +if ($type_element == 'supplier_invoice') +{ + // TODO + +} + +$sql = $sql_select; +$sql.= ' d.fk_product as product_id, d.fk_product as fk_product, d.label, d.description as description, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty,'; +$sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type,'; +$sql.= " s.rowid as socid, p.ref as prod_ref, p.label as product_label"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; +$sql.= $where; +if ($month > 0) { + if ($year > 0) { + $start = dol_mktime(0, 0, 0, $month, 1, $year); + $end = dol_time_plus_duree($start, 1 , 'm') - 1; + $sql.= " AND ".$datePrint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'"; + } else { + $sql.= " AND date_format(".$datePrint.", '%m') = '".sprintf('%02d',$month)."'"; + } +} else if ($year > 0) { + $start = dol_mktime(0, 0, 0, 1, 1, $year); + $end = dol_time_plus_duree($start, 1 , 'y') - 1; + $sql.= " AND ".$datePrint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'"; +} +if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$sref."%'"; +$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->plimit($limit + 1, $offset); + + +// Define type of elements +$typeElementString = $form->selectarray("type_element",$elementTypeArray,GETPOST('type_element')); +$button = '<input type="submit" class="button" name="button_third" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; +$param="&sref=".$sref."&month=".$month."&year=".$year."&sprod_fulldescr=".$sprod_fulldescr."&socid=".$socid; + +print_barre_liste($langs->trans('ProductsIntoElements', $typeElementString.' '.$button), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); + +if ($sql_select) +{ + dol_syslog("sql=".$sql); + $resql=$db->query($sql); + if (!$resql) dol_print_error($db); +} + +print '<table class="liste" width="100%">'."\n"; +// Titles with sort buttons +print '<tr class="liste_titre">'; +print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'doc_number','',$param,'align="left"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'datePrint','',$param,'align="center" width="150"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans('Product'),$_SERVER['PHP_SELF'],'','',$param,'align="left"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder); +// Filters +print '<tr class="liste_titre">'; +print '<td class="liste_titre" align="left">'; +print '<input class="flat" type="text" name="sref" size="8" value="'.$sref.'">'; +print '</td>'; +print '<td class="liste_titre">'; // date +print $formother->select_month($month?$month:-1,'month',1); +$formother->select_year($year?$year:-1,'year',1, 20, 1); +print '</td>'; +print '<td class="liste_titre" align="left">'; +print '<input class="flat" type="text" name="sprod_fulldescr" size="15" value="'.$sprod_fulldescr.'">'; +print '</td>'; +print '<td class="liste_titre" align="right">'; +print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" 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="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" value="'.dol_escape_htmltag($langs->trans("resetFilters")).'" title="'.dol_escape_htmltag($langs->trans("resetFilters")).'">'; +print '</td>'; +print '</tr>'; + +if ($sql_select) +{ + $var=true; + $num = $db->num_rows($resql); + $i = 0; + while (($objp = $db->fetch_object($resql)) && $i < $conf->liste_limit ) + { + $var=!$var; + print "<tr ".$bc[$var].">"; + print '<td class="nobordernopadding" nowrap="nowrap" width="100">'; + $documentstatic->id=$objp->doc_id; + $documentstatic->ref=$objp->doc_number; + $documentstatic->type=$objp->type; + print $documentstatic->getNomUrl(1); + print '</td>'; + print '<td align="center" width="80">'.dol_print_date($db->jdate($objp->datePrint),'day').'</td>'; + + print '<td>'; + + // Define text, description and type + $text=''; $description=''; $type=0; + + // Code to show product duplicated from commonobject->printObjectLine + if ($objp->fk_product > 0) + { + $product_static = new Product($db); + + $product_static->type=$objp->fk_product_type; + $product_static->id=$objp->fk_product; + $product_static->ref=$objp->ref; + $text=$product_static->getNomUrl(1); + } + + // Product + if ($objp->fk_product > 0) + { + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $this->fetch_thirdparty(); + $prod = new Product($db); + $prod->fetch($objp->fk_product); + + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$this->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; + } + else + { + $label = $objp->product_label; + } + + $text.= ' - '.(! empty($objp->label)?$objp->label:$label); + $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); + } + + if (($objp->info_bits & 2) == 2) { ?> + <a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$object->id; ?>"> + <?php + $txt=''; + print img_object($langs->trans("ShowReduc"),'reduc').' '; + if ($objp->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); + //else $txt=$langs->trans("Discount"); + print $txt; + ?> + </a> + <?php + if ($objp->description) + { + if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($db); + $discount->fetch($objp->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); + } + elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($db); + $discount->fetch($objp->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); + // Add date of deposit + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; + } + else + { + echo ($txt?' - ':'').dol_htmlentitiesbr($objp->description); + } + } + } + else + { + if ($objp->fk_product > 0) { + + echo $form->textwithtooltip($text,$description,3,'','',$i,0,''); + + // Show range + echo get_date_range($objp->date_start, $objp->date_end); + + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print (! empty($objp->description) && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):''; + } + + } else { + + //if (! empty($objp->fk_parent_line)) echo img_picto('', 'rightarrow'); + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + + if (! empty($objp->label)) { + $text.= ' <strong>'.$objp->label.'</strong>'; + echo $form->textwithtooltip($text,dol_htmlentitiesbr($objp->description),3,'','',$i,0,''); + } else { + echo $text.' '.dol_htmlentitiesbr($objp->description); + } + + // Show range + echo get_date_range($objp->date_start,$objp->date_end); + } + } + + /* + $prodreftxt=''; + if ($objp->prod_id > 0) + { + $productstatic->id = $objp->prod_id; + $productstatic->ref = $objp->prod_ref; + $productstatic->status = $objp->prod_type; + $prodreftxt = $productstatic->getNomUrl(0); + if(!empty($objp->product_label)) $prodreftxt .= ' - '.$objp->product_label; + } + // Show range + $prodreftxt .= get_date_range($objp->date_start, $objp->date_end); + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + $prodreftxt .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):''; + } + */ + print '</td>'; + + //print '<td align="left">'.$prodreftxt.'</td>'; + + print '<td align="right">'.$objp->prod_qty.'</td>'; + + print "</tr>\n"; + $i++; + } + if ($num > $conf->liste_limit) { + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num); + } + $db->free($resql); +} +else { + print '<tr><td colspan="4">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>'; +} + +print "</table>"; +print "</form>"; + + +/* + * Errors + */ + +dol_htmloutput_errors($warning); +dol_htmloutput_errors($error,$errors); + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/theme/amarok/img/cron.png b/htdocs/theme/amarok/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 Binary files /dev/null and b/htdocs/theme/amarok/img/cron.png differ diff --git a/htdocs/theme/amarok/img/object_cron.png b/htdocs/theme/amarok/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc Binary files /dev/null and b/htdocs/theme/amarok/img/object_cron.png differ diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index 8c92d9e561b4b33d6479b9369caf21df1cc5a585..48fa2c8f5a3c0409e66ca5b2f233bee7eb185a48 100755 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -120,6 +120,9 @@ a:hover, a:active { color:rgba(0,0,0,.6); } +input, input.flat, textarea, textarea.flat, form.flat select, select.flat { + padding: 1px; +} input, textarea { font-size:<?php print $fontsize ?>px; font-family:<?php print $fontlist ?>; @@ -812,7 +815,7 @@ td.vmenu { } div.fiche { - padding:8px 12px 10px; + padding:8px 6px 10px; margin-<?php print $left; ?>: <?php print (empty($conf->browser->phone) || empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))?'16':'24'; ?>px; margin-<?php print $right; ?>: <?php print empty($conf->browser->phone)?'12':'6'; ?>px; } @@ -1140,21 +1143,21 @@ tr.fiche { .ok { color:#159e26; background:url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/ok.png',1); ?>) left center no-repeat !important; - padding-left:20px; + padding-left:20px !important; font-weight:bold; } .warning { color:#bca936; background:url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/warning.png',1); ?>) left center no-repeat !important; - padding-left:20px; + padding-left:20px !important; font-weight:bold; } .error { color:#a61111; background:#f58080 url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/error.png',1); ?>) left center no-repeat !important; - padding-left:20px; + padding-left:20px !important; font-weight:bold; } @@ -1163,7 +1166,7 @@ td.highlights {background:#f9c5c6;} div.ok { background:#61e372; /* url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/ok.png',1); ?>) 3px center no-repeat; */ /*color:#ffffff;*/ - padding:2px 4px 2px 24px; + padding:2px 4px 2px 6px; margin:0.5em 0em; font-weight:normal; } @@ -1171,7 +1174,7 @@ div.ok { div.warning, div.info { background:#fcf5b8; /* url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/warning.png',1); ?>) 3px center no-repeat; */ /*color:#232323; */ - padding:2px 4px 2px 24px; + padding:2px 4px 2px 6px; margin:0.5em 0em; border:1px solid #bca936; font-weight:normal; @@ -1180,7 +1183,7 @@ div.warning, div.info { div.error { background:#f58080; /* url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/error.png',1); ?>) 3px center no-repeat; */ /* color:#ffffff; */ - padding:2px 4px 2px 24px; + padding:2px 4px 2px 6px; margin:0.5em 0em; border:1px solid #a61111; font-weight:normal; diff --git a/htdocs/theme/auguria/img/cron.png b/htdocs/theme/auguria/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 Binary files /dev/null and b/htdocs/theme/auguria/img/cron.png differ diff --git a/htdocs/theme/auguria/img/object_commissions.png b/htdocs/theme/auguria/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 Binary files a/htdocs/theme/auguria/img/object_commissions.png and /dev/null differ diff --git a/htdocs/theme/auguria/img/object_cron.png b/htdocs/theme/auguria/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc Binary files /dev/null and b/htdocs/theme/auguria/img/object_cron.png differ diff --git a/htdocs/theme/bureau2crea/img/cron.png b/htdocs/theme/bureau2crea/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 Binary files /dev/null and b/htdocs/theme/bureau2crea/img/cron.png differ diff --git a/htdocs/theme/bureau2crea/img/object_commissions.png b/htdocs/theme/bureau2crea/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 Binary files a/htdocs/theme/bureau2crea/img/object_commissions.png and /dev/null differ diff --git a/htdocs/theme/bureau2crea/img/object_cron.png b/htdocs/theme/bureau2crea/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc Binary files /dev/null and b/htdocs/theme/bureau2crea/img/object_cron.png differ diff --git a/htdocs/theme/cameleo/img/cron.png b/htdocs/theme/cameleo/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 Binary files /dev/null and b/htdocs/theme/cameleo/img/cron.png differ diff --git a/htdocs/theme/cameleo/img/object_commissions.png b/htdocs/theme/cameleo/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 Binary files a/htdocs/theme/cameleo/img/object_commissions.png and /dev/null differ diff --git a/htdocs/theme/cameleo/img/object_cron.png b/htdocs/theme/cameleo/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc Binary files /dev/null and b/htdocs/theme/cameleo/img/object_cron.png differ diff --git a/htdocs/theme/eldy/img/menus/cron.png b/htdocs/theme/eldy/img/menus/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 Binary files /dev/null and b/htdocs/theme/eldy/img/menus/cron.png differ diff --git a/htdocs/theme/eldy/img/menus/object_cron.png b/htdocs/theme/eldy/img/menus/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc Binary files /dev/null and b/htdocs/theme/eldy/img/menus/object_cron.png differ diff --git a/htdocs/theme/eldy/img/object_commissions.png b/htdocs/theme/eldy/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 Binary files a/htdocs/theme/eldy/img/object_commissions.png and /dev/null differ diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php new file mode 100644 index 0000000000000000000000000000000000000000..0c22107bde637e35909c1b0dfceea58f2b6dfd43 --- /dev/null +++ b/scripts/cron/cron_run_jobs.php @@ -0,0 +1,146 @@ +#!/usr/bin/php +<?php +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry <forian.henry@open-cocnept.pro + * + * 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/>. + */ + +/** + * \file cron/script/cron/cron_run_jobs.php + * \ingroup cron + * \brief Execute pendings jobs + */ +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +if (! defined('NOLOGIN')) define('NOLOGIN','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); +$path=dirname(__FILE__).'/'; + +// Test if batch mode +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + exit; +} + +if (! isset($argv[1]) || ! $argv[1]) { + print "Usage: ".$script_file." securitykey userlogin cronjobid(optional)\n"; + exit; +} +$key=$argv[1]; + +if (! isset($argv[2]) || ! $argv[2]) { + print "Usage: ".$script_file." securitykey userlogin cronjobid(optional)\n"; + exit; +} else { + $userlogin=$argv[2]; +} + + +$res=@include("../../master.inc.php"); // For root directory +if (! $res) $res=@include("../../../master.inc.php"); // For "custom" directory +if (! $res) die("Include of master.inc.php fails"); + + +// librarie jobs +require_once (DOL_DOCUMENT_ROOT_ALT."/cron/class/cronjob.class.php"); + + +//Check security key +if($key != $conf->global->MAIN_CRON_KEY) +{ + echo 'securitykey is wrong'; + exit; +} + +//Check user login +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +$user=new User($db); +$result=$user->fetch('',$userlogin); +if ($result<0) { + echo "User Error:".$user->error; + dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); + exit; +}else { + if (empty($user->id)) { + echo " User user login:".$userlogin." do not exists"; + dol_syslog(" User user login:".$userlogin." do not exists", LOG_ERR); + exit; + } +} + +if (isset($argv[3]) || $argv[3]) { + $id = $argv[3]; +} + +// librarie jobs +require_once (DOL_DOCUMENT_ROOT_ALT."/cron/class/cronjob.class.php"); + +// create a jobs object +$object = new Cronjob($db); + +$filter=array(); +if (empty($id)) { + $filter=array(); + $filter['t.rowid']=$id; +} + +$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter); +if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); + exit; +} + +// current date +$now=dol_now(); + +if(is_array($object->lines) && (count($object->lines)>0)){ + // Loop over job + foreach($object->lines as $line){ + + //If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database + if (($line->datenextrun < $now) && $line->dateend < $now){ + $cronjob=new Cronjob($db); + $result=$cronjob->fetch($line->id); + if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); + exit; + } + // execute methode + $result=$cronjob->run_jobs($userlogin); + if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR); + exit; + } + + // we re-program the next execution and stores the last execution time for this job + $result=$cronjob->reprogram_jobs($userlogin); + if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR); + exit; + } + + } + } +} \ No newline at end of file