Uniformisation du code
This commit is contained in:
parent
a4c3b86d9f
commit
4ef6a9d6ae
@ -115,7 +115,7 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0)
|
||||
$result=$facture->create($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$result=$facture->set_valid($facture->id,$user,$socid);
|
||||
$result=$facture->set_valid($user,$socid);
|
||||
if ($result) print " OK";
|
||||
else
|
||||
{
|
||||
|
||||
@ -50,12 +50,13 @@ class ActionComm
|
||||
|
||||
var $datep; // Date action planifie debut (datep)
|
||||
var $datef; // Date action planifie fin (datep2)
|
||||
var $date; // Date action realise debut (datea)
|
||||
var $dateend; // Date action realise fin (datea2)
|
||||
var $durationp = -1;
|
||||
var $durationa = -1;
|
||||
//var $date; // Date action realise debut (datea) // deprecated
|
||||
//var $dateend; // Date action realise fin (datea2) // deprecated
|
||||
var $durationa = -1; // deprecated
|
||||
var $priority;
|
||||
|
||||
var $punctual = 1;
|
||||
|
||||
var $usertodo; // Object user that must do action
|
||||
var $userdone; // Object user that did action
|
||||
|
||||
@ -98,6 +99,7 @@ class ActionComm
|
||||
$this->note=trim($this->note);
|
||||
if (! $this->percentage) $this->percentage = 0;
|
||||
if (! $this->priority) $this->priority = 0;
|
||||
if (! $this->punctual) $this->punctual = 0;
|
||||
if ($this->percentage > 100) $this->percentage = 100;
|
||||
if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date;
|
||||
if ($this->datep && $this->datef) $this->durationp=($this->datef - $this->datep);
|
||||
@ -145,7 +147,7 @@ class ActionComm
|
||||
$sql.= "fk_user_author,";
|
||||
$sql.= "fk_user_action,";
|
||||
$sql.= "fk_user_done,";
|
||||
$sql.= "label,percent,priority,";
|
||||
$sql.= "label,percent,priority,punctual,";
|
||||
$sql.= "fk_facture,propalrowid,fk_commande)";
|
||||
$sql.= " VALUES (";
|
||||
$sql.= "'".$this->db->idate($now)."',";
|
||||
@ -160,7 +162,7 @@ class ActionComm
|
||||
$sql.= "'".$user->id."',";
|
||||
$sql.= ($this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").",";
|
||||
$sql.= ($this->userdone->id > 0?"'".$this->userdone->id."'":"null").",";
|
||||
$sql.= "'".addslashes($this->label)."','".$this->percentage."','".$this->priority."',";
|
||||
$sql.= "'".addslashes($this->label)."','".$this->percentage."','".$this->priority."','".$this->punctual."',";
|
||||
$sql.= ($this->facid?$this->facid:"null").",";
|
||||
$sql.= ($this->propalrowid?$this->propalrowid:"null").",";
|
||||
$sql.= ($this->orderrowid?$this->orderrowid:"null");
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/admin/agenda_actions.php
|
||||
\file htdocs/admin/agenda.php
|
||||
\ingroup agenda
|
||||
\brief Autocreate actions for agenda module setup page
|
||||
\version $Id$
|
||||
@ -49,6 +49,8 @@ $eventstolog=array(
|
||||
array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled),
|
||||
array('id'=>'BILL_CANCELED', 'test'=>$conf->facture->enabled),
|
||||
array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled),
|
||||
array('id'=>'ORDER_SUPPLIER_VALIDATE','test'=>$conf->fournisseur->enabled),
|
||||
array('id'=>'BILL_SUPPLIER_VALIDATE', 'test'=>$conf->fournisseur->enabled),
|
||||
// array('id'=>'PAYMENT_CUSTOMER_CREATE','test'=>$conf->facture->enabled),
|
||||
// array('id'=>'PAYMENT_SUPPLIER_CREATE','test'=>$conf->fournisseur->enabled),
|
||||
// array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled),
|
||||
|
||||
@ -624,13 +624,10 @@ if ($_GET["id"])
|
||||
$html->select_array("contactid", $act->societe->contact_array(), $act->contact->id, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Priorite
|
||||
print '<tr><td nowrap>'.$langs->trans("Priority").'</td><td colspan="3">';
|
||||
print '<input type="text" name="priority" value="'.$act->priority.'" size="5">';
|
||||
print '</td></tr>';
|
||||
print '</table><br><table class="border" width="100%">';
|
||||
|
||||
// Input by
|
||||
print '<tr><td nowrap>'.$langs->trans("ActionAskedBy").'</td><td colspan="3">';
|
||||
print '<tr><td width="30%" nowrap>'.$langs->trans("ActionAskedBy").'</td><td colspan="3">';
|
||||
print $act->author->getNomUrl(1);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -644,8 +641,10 @@ if ($_GET["id"])
|
||||
$html->select_users($act->userdone->id,'doneby',1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table><br><table class="border" width="100%">';
|
||||
|
||||
// Date start
|
||||
print '<tr><td nowrap="nowrap">'.$langs->trans("DateActionStart").'</td><td colspan="3">';
|
||||
print '<tr><td width="30%" nowrap="nowrap">'.$langs->trans("DateActionStart").'</td><td colspan="3">';
|
||||
if ($_REQUEST["afaire"] == 1) $html->select_date($act->datep,'ap',1,1,0,"action");
|
||||
else if ($_REQUEST["afaire"] == 2) $html->select_date($act->datep,'ap',1,1,1,"action");
|
||||
else $html->select_date($act->datep,'ap',1,1,1,"action");
|
||||
@ -659,6 +658,11 @@ if ($_GET["id"])
|
||||
if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < (time() - $conf->global->MAIN_DELAY_ACTIONS_TODO)) print img_warning($langs->trans("Late"));
|
||||
print '</td></tr>';
|
||||
|
||||
// Priorite
|
||||
print '<tr><td nowrap>'.$langs->trans("Priority").'</td><td colspan="3">';
|
||||
print '<input type="text" name="priority" value="'.$act->priority.'" size="5">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Status
|
||||
print '<tr><td nowrap>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3"><input name="percentage" value="'.(isset($_REQUEST["percentage"])?$_REQUEST["percentage"]:$act->percentage).'" size="4">%</td></tr>';
|
||||
|
||||
@ -675,7 +679,7 @@ if ($_GET["id"])
|
||||
{
|
||||
// Editeur wysiwyg
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
$doleditor=new DolEditor('note',$act->note,280,'dolibarr_notes','In',true);
|
||||
$doleditor=new DolEditor('note',$act->note,240,'dolibarr_notes','In',true);
|
||||
$doleditor->Create();
|
||||
}
|
||||
else
|
||||
@ -720,13 +724,10 @@ if ($_GET["id"])
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// Priorite
|
||||
print '<tr><td nowrap>'.$langs->trans("Priority").'</td><td colspan="3">';
|
||||
print $act->priority;
|
||||
print '</td></tr>';
|
||||
print '</table><br><table class="border" width="100%">';
|
||||
|
||||
// Input by
|
||||
print '<tr><td nowrap>'.$langs->trans("ActionAskedBy").'</td><td colspan="3">';
|
||||
print '<tr><td width="30%" nowrap>'.$langs->trans("ActionAskedBy").'</td><td colspan="3">';
|
||||
print $act->author->getNomUrl(1);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -740,8 +741,10 @@ if ($_GET["id"])
|
||||
if ($act->userdone->id > 0) print $act->userdone->getNomUrl(1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table><br><table class="border" width="100%">';
|
||||
|
||||
// Date debut
|
||||
print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
|
||||
print '<tr><td width="30%">'.$langs->trans("DateActionStart").'</td><td colspan="3">';
|
||||
print dolibarr_print_date($act->datep,'dayhour');
|
||||
if ($act->percentage == 0 && $act->datep && $act->datep < (time() - $conf->global->MAIN_DELAY_ACTIONS_TODO)) print img_warning($langs->trans("Late"));
|
||||
print '</td></tr>';
|
||||
@ -752,6 +755,11 @@ if ($_GET["id"])
|
||||
if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < (time() - $conf->global->MAIN_DELAY_ACTIONS_TODO)) print img_warning($langs->trans("Late"));
|
||||
print '</td></tr>';
|
||||
|
||||
// Priorite
|
||||
print '<tr><td nowrap>'.$langs->trans("Priority").'</td><td colspan="3">';
|
||||
print $act->priority;
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td nowrap>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">';
|
||||
print $act->getLibStatut(4);
|
||||
|
||||
@ -469,7 +469,7 @@ if ($_GET['action'] == 'modif' && $user->rights->propale->creer)
|
||||
*/
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($_GET['propalid']);
|
||||
$propal->set_draft($user->id);
|
||||
$propal->set_draft($user);
|
||||
}
|
||||
|
||||
if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
|
||||
@ -1703,53 +1703,10 @@ if ($_GET['propalid'] > 0)
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
/*
|
||||
* Liste des actions propres a la propal
|
||||
*/
|
||||
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
|
||||
{
|
||||
$sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ;
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
|
||||
$sql .= ' WHERE a.propalrowid = '.$propal->id ;
|
||||
if ($socid) $sql .= ' AND a.fk_soc = '.$socid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
print_titre($langs->trans('ActionsOnPropal'));
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
$var=true;
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Date').'</td><td>'.$langs->trans('Action').'</td><td>'.$langs->trans('By').'</td></tr>';
|
||||
print "\n";
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$objp->id.'">'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.'</a></td>';
|
||||
print '<td>'.dolibarr_print_date($objp->da)."</td>\n";
|
||||
print '<td>'.stripslashes($objp->label).'</td>';
|
||||
$authoract = new User($db);
|
||||
$authoract->id = $objp->fk_user_author;
|
||||
$authoract->fetch('');
|
||||
print '<td>'.$authoract->login.'</td>';
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
// List of actions on element
|
||||
include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php');
|
||||
$formactions=new FormActions($db);
|
||||
$somethingshown=$formactions->showactions($propal,'propal',$socid);
|
||||
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
@ -317,16 +317,17 @@ class Commande extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
function set_draft($user)
|
||||
{
|
||||
global $conf;
|
||||
/**
|
||||
* \brief Set draft status
|
||||
* \param user Object user that modify
|
||||
* \param int <0 if KO, >0 if OK
|
||||
*/
|
||||
function set_draft($user)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 0";
|
||||
$sql .= " WHERE rowid = $this->id;";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
|
||||
@ -444,19 +444,19 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
|
||||
|
||||
if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->valider)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socid);
|
||||
if ($_REQUEST['lang_id'])
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
|
||||
$result=$commande->valid($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
if ($_REQUEST['lang_id'])
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||
}
|
||||
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||
$result=$commande->valid($user);
|
||||
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->creer)
|
||||
@ -615,22 +615,16 @@ if ($_POST['action'] == 'send')
|
||||
|
||||
if ($_POST['action'] == 'send')
|
||||
{
|
||||
$subject = $_POST['subject'];
|
||||
|
||||
if($subject == '')
|
||||
{
|
||||
$subject = $langs->transnoentities('Order').' '.$commande->ref;
|
||||
}
|
||||
|
||||
if (strlen($_POST['subject'])) $subject=$_POST['subject'];
|
||||
else $subject = $langs->transnoentities('Order').' '.$commande->ref;
|
||||
$actiontypecode='AC_COM';
|
||||
$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);
|
||||
}
|
||||
|
||||
@ -1864,54 +1858,10 @@ else
|
||||
}
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
/*
|
||||
* Liste des actions propres a la commande
|
||||
*/
|
||||
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
|
||||
{
|
||||
$sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ;
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
|
||||
$sql .= ' WHERE a.fk_commande = '.$commande->id ;
|
||||
if ($socid) $sql .= ' AND a.fk_soc = '.$socid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
//print '<br>';
|
||||
print_titre($langs->trans('ActionsOnOrder'));
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
$var=true;
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Date').'</td><td>'.$langs->trans('Action').'</td><td>'.$langs->trans('By').'</td></tr>';
|
||||
print "\n";
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$objp->id.'">'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.'</a></td>';
|
||||
print '<td>'.dolibarr_print_date($objp->da,'day')."</td>\n";
|
||||
print '<td>'.stripslashes($objp->label).'</td>';
|
||||
$authoract = new User($db);
|
||||
$authoract->id = $objp->fk_user_author;
|
||||
$authoract->fetch('');
|
||||
print '<td>'.$authoract->login.'</td>';
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
// List of actions on element
|
||||
include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php');
|
||||
$formactions=new FormActions($db);
|
||||
$somethingshown=$formactions->showactions($commande,'order',$socid);
|
||||
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
@ -239,7 +239,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
|
||||
$fac->fetch($_GET['facid']);
|
||||
$fac->fetch_client();
|
||||
|
||||
$result = $fac->set_valid($fac->id, $user);
|
||||
$result = $fac->set_valid($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($_REQUEST['lang_id'])
|
||||
@ -2954,54 +2954,11 @@ else
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
/*
|
||||
* Liste des actions propres à la facture
|
||||
* Action 9 and 10 are implicits actions. Do not protect this section according
|
||||
* to agenda module permissions.
|
||||
*/
|
||||
$sql = 'SELECT a.id, '.$db->pdate('a.datea').' as da, a.label, a.note,';
|
||||
$sql.= ' u.login';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a, '.MAIN_DB_PREFIX.'user as u';
|
||||
$sql.= ' WHERE a.fk_user_author = u.rowid';
|
||||
$sql.= ' AND a.fk_action in (9,10)';
|
||||
$sql.= ' AND a.fk_soc = '.$fac->socid ;
|
||||
$sql.= ' AND a.fk_facture = '.$fac->id;
|
||||
|
||||
dolibarr_syslog("compta/facture.php sql=".$sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
print '<br>';
|
||||
print_titre($langs->trans('ActionsOnBill'));
|
||||
|
||||
$i = 0; $total = 0;
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Date').'</td><td>'.$langs->trans('Action').'</td><td>'.$langs->trans('By').'</td></tr>';
|
||||
print "\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$objp->id.'">'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.'</a></td>';
|
||||
print '<td>'.dolibarr_print_date($objp->da,'day').'</td>';
|
||||
print '<td>'.$objp->label.'</td>';
|
||||
print '<td>'.$objp->login.'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
// List of actions on element
|
||||
include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php');
|
||||
$formactions=new FormActions($db);
|
||||
$somethingshown=$formactions->showactions($fac,'invoice',$socid);
|
||||
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
|
||||
@ -987,13 +987,12 @@ class Facture extends CommonObject
|
||||
|
||||
/**
|
||||
* \brief Tag la facture comme validée + appel trigger BILL_VALIDATE
|
||||
* \param rowid Id de la facture à valider
|
||||
* \param user Utilisateur qui valide la facture
|
||||
* \param soc Ne sert plus \\TODO A virer
|
||||
* \param force_number Référence à forcer de la facture
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function set_valid($rowid, $user, $soc='', $force_number='')
|
||||
function set_valid($user, $soc='', $force_number='')
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
@ -1027,7 +1026,7 @@ class Facture extends CommonObject
|
||||
|
||||
// Controle que facture source non deja remplacee par une autre
|
||||
$idreplacement=$facreplaced->getIdReplacingInvoice('validated');
|
||||
if ($idreplacement && $idreplacement != $rowid)
|
||||
if ($idreplacement && $idreplacement != $this->id)
|
||||
{
|
||||
$facreplacement=new Facture($this->db);
|
||||
$facreplacement->fetch($idreplacement);
|
||||
@ -1075,7 +1074,7 @@ class Facture extends CommonObject
|
||||
$sql.= ', datef='.$this->db->idate($this->date);
|
||||
$sql.= ', date_lim_reglement='.$this->db->idate($datelim);
|
||||
}
|
||||
$sql.= ' WHERE rowid = '.$rowid;
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -1192,15 +1191,17 @@ class Facture extends CommonObject
|
||||
|
||||
/**
|
||||
* \brief Set draft status
|
||||
* \param userid Id user setting
|
||||
* \param user Object user that modify
|
||||
* \param int <0 if KO, >0 if OK
|
||||
*/
|
||||
function set_draft($userid)
|
||||
function set_draft($user)
|
||||
{
|
||||
dolibarr_syslog("Facture::set_draft rowid=".$this->id, LOG_DEBUG);
|
||||
global $conf,$langs;
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_statut = 0";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
dolibarr_syslog("Facture::set_draft sql=".$sql, LOG_DEBUG);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
return 1;
|
||||
|
||||
@ -217,17 +217,19 @@ if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes
|
||||
|
||||
if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->valider)
|
||||
{
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socid);
|
||||
$result = $commande->valid($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
exit;
|
||||
}
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
|
||||
$result = $commande->valid($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($_REQUEST['lang_id'])
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user->rights->fournisseur->commande->approuver)
|
||||
@ -235,11 +237,6 @@ if ($_POST['action'] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
$result = $commande->approve($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_refuse' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->approuver)
|
||||
@ -247,11 +244,6 @@ if ($_POST['action'] == 'confirm_refuse' && $_POST['confirm'] == 'yes' && $user-
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
$result = $commande->refuse($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->commander)
|
||||
@ -259,8 +251,6 @@ if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $use
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->fetch($_GET["id"]);
|
||||
$result = $commande->commande($user, $_GET["datecommande"], $_GET["methode"]);
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ $langs->load('bills');
|
||||
$langs->load('suppliers');
|
||||
$langs->load('companies');
|
||||
|
||||
// S<EFBFBD>curit<EFBFBD> acc<63>s client
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
@ -57,9 +57,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
|
||||
{
|
||||
$facturefourn=new FactureFournisseur($db);
|
||||
$facturefourn->fetch($_GET['facid']);
|
||||
$facturefourn->set_valid($user);
|
||||
Header('Location: fiche.php?facid='.$_GET['facid']);
|
||||
exit;
|
||||
$result = $facturefourn->set_valid($user);
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
||||
|
||||
@ -82,6 +82,7 @@ class CommandeFournisseur extends Commande
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm.rowid = c.fk_methode_commande";
|
||||
$sql .= " WHERE c.rowid = ".$id;
|
||||
|
||||
dolibarr_syslog("CommandeFournisseur::fetch sql=".$sql,LOG_DEBUG);
|
||||
$resql = $this->db->query($sql) ;
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
@ -382,17 +382,34 @@ class FactureFournisseur extends Facture
|
||||
*/
|
||||
function set_valid($user)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
|
||||
global $conf,$langs;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
|
||||
$sql.= " SET fk_statut = 1, fk_user_valid = ".$user->id;
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
dolibarr_syslog("FactureFournisseur::set_valid sql=".$sql,LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
if ($resql)
|
||||
{
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('BILL_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_print_error($this->db);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -289,8 +289,38 @@ class InterfaceActionsAuto
|
||||
$object->orderrowid=$object->propalrowid=0;
|
||||
$ok=1;
|
||||
}
|
||||
elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("orders");
|
||||
$langs->load("agenda");
|
||||
|
||||
$object->actiontypecode='AC_OTH';
|
||||
$object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref);
|
||||
$object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref);
|
||||
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
|
||||
|
||||
$object->sendtoid=0;
|
||||
$object->orderrowid=0; // Supplier order not yet supported
|
||||
$object->propalrowid=$object->facid=0;
|
||||
$ok=1;
|
||||
}
|
||||
elseif ($action == 'BILL_SUPPLIER_VALIDATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("bills");
|
||||
$langs->load("agenda");
|
||||
|
||||
$object->actiontypecode='AC_OTH';
|
||||
$object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
|
||||
$object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
|
||||
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
|
||||
$object->sendtoid=0;
|
||||
$object->facid=0; // Supplier invoice not yet supported
|
||||
$object->orderrowid=$object->propalrowid=0;
|
||||
$ok=1;
|
||||
}
|
||||
|
||||
|
||||
// If not found
|
||||
@ -305,6 +335,8 @@ class InterfaceActionsAuto
|
||||
// Add entry in event table
|
||||
if ($ok)
|
||||
{
|
||||
$now=time();
|
||||
|
||||
// Insertion action
|
||||
require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
|
||||
@ -312,7 +344,10 @@ class InterfaceActionsAuto
|
||||
$actioncomm->type_code = $object->actiontypecode;
|
||||
$actioncomm->label = $object->actionmsg2;
|
||||
$actioncomm->note = $object->actionmsg;
|
||||
$actioncomm->date = time(); // L'action est faite maintenant
|
||||
$actioncomm->datep = $now;
|
||||
$actioncomm->datef = $now;
|
||||
$actioncomm->durationp = 0;
|
||||
$actioncomm->punctual = 1;
|
||||
$actioncomm->percentage = 100;
|
||||
$actioncomm->contact = new Contact($this->db,$object->sendtoid);
|
||||
$actioncomm->societe = new Societe($this->db,$object->socid);
|
||||
@ -331,7 +366,7 @@ class InterfaceActionsAuto
|
||||
$error ="Failed to insert : ".$actioncomm->error." ";
|
||||
$this->error=$error;
|
||||
|
||||
//dolibarr_syslog("interface_webcal.class.php: ".$this->error);
|
||||
dolibarr_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1130,23 +1130,25 @@ class Propal extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
function set_draft($userid)
|
||||
/**
|
||||
* \brief Set draft status
|
||||
* \param user Object user that modify
|
||||
* \param int <0 if KO, >0 if OK
|
||||
*/
|
||||
function set_draft($user)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
$sql .= " WHERE rowid = $this->id;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -678,7 +678,7 @@ class FacturationEmission {
|
||||
$y = substr($year, -1);
|
||||
$m = substr("00".$month, -2);
|
||||
|
||||
if ( $fac->set_valid($facid, $user, $soc) )
|
||||
if ( $fac->set_valid($user, $soc) )
|
||||
{
|
||||
$valid_ok = 1;
|
||||
}
|
||||
|
||||
@ -664,12 +664,12 @@ function facture_contrat($db, $user, $contrat_id, $factel_ids, $datetime, &$fact
|
||||
|
||||
if (!$error && !$cancel_facture)
|
||||
{
|
||||
if ($verbose) dolibarr_syslog("Validation de la facture : $facid");
|
||||
if ($verbose) dolibarr_syslog("Validation de la facture : $fac->id");
|
||||
|
||||
$y = substr($year, -1);
|
||||
$m = substr("00".$month, -2);
|
||||
|
||||
if ( $fac->set_valid($facid, $user, $soc) )
|
||||
if ( $fac->set_valid($user, $soc) )
|
||||
{
|
||||
$valid_ok = 1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user