Select bank account for propal and order
This commit is contained in:
parent
823e976f39
commit
f29eeceb1a
@ -254,6 +254,7 @@ else if ($action == 'add' && $user->rights->propal->creer) {
|
||||
$object->duree_validite = $duration;
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->remise_percent = GETPOST('remise_percent');
|
||||
$object->remise_absolue = GETPOST('remise_absolue');
|
||||
$object->socid = GETPOST('socid');
|
||||
@ -279,7 +280,7 @@ else if ($action == 'add' && $user->rights->propal->creer) {
|
||||
$object->duree_validite = GETPOST('duree_validite');
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->contactid = GETPOST('contactidp');
|
||||
$object->fk_project = GETPOST('projectid');
|
||||
$object->modelpdf = GETPOST('model');
|
||||
@ -1104,6 +1105,11 @@ else if ($action == 'setmode' && $user->rights->propal->creer) {
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
}
|
||||
|
||||
// bank account
|
||||
else if ($action == 'setbankaccount' && $user->rights->propal->creer) {
|
||||
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
}
|
||||
|
||||
/*
|
||||
* Ordonnancement des lignes
|
||||
*/
|
||||
@ -1368,6 +1374,11 @@ if ($action == 'create') {
|
||||
$form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank Account
|
||||
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
|
||||
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// What trigger creation
|
||||
print '<tr><td>' . $langs->trans('Source') . '</td><td>';
|
||||
$form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1);
|
||||
@ -1965,6 +1976,25 @@ if ($action == 'create') {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Bank Account
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('BankAccount');
|
||||
print '<td>';
|
||||
if (($action != 'editbankaccount') && $user->rights->propal->creer && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($action == 'editbankaccount')
|
||||
{
|
||||
$form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
|
||||
}
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
// Amount HT
|
||||
print '<tr><td height="10" width="25%">' . $langs->trans('AmountHT') . '</td>';
|
||||
|
||||
@ -79,6 +79,7 @@ class Propal extends CommonObject
|
||||
|
||||
var $cond_reglement_id;
|
||||
var $cond_reglement_code;
|
||||
var $fk_account; // Id of bank account
|
||||
var $mode_reglement_id;
|
||||
var $mode_reglement_code;
|
||||
var $remise;
|
||||
@ -714,6 +715,7 @@ class Propal extends CommonObject
|
||||
$sql.= ", fin_validite";
|
||||
$sql.= ", fk_cond_reglement";
|
||||
$sql.= ", fk_mode_reglement";
|
||||
$sql.= ", fk_account";
|
||||
$sql.= ", ref_client";
|
||||
$sql.= ", date_livraison";
|
||||
$sql.= ", fk_availability";
|
||||
@ -739,6 +741,7 @@ class Propal extends CommonObject
|
||||
$sql.= ", ".($this->fin_validite!=''?"'".$this->db->idate($this->fin_validite)."'":"null");
|
||||
$sql.= ", ".$this->cond_reglement_id;
|
||||
$sql.= ", ".$this->mode_reglement_id;
|
||||
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
|
||||
$sql.= ", '".$this->db->escape($this->ref_client)."'";
|
||||
$sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"null");
|
||||
$sql.= ", ".$this->availability_id;
|
||||
@ -1056,6 +1059,7 @@ class Propal extends CommonObject
|
||||
$sql.= ", p.fk_input_reason";
|
||||
$sql.= ", p.fk_cond_reglement";
|
||||
$sql.= ", p.fk_mode_reglement";
|
||||
$sql.= ', p.fk_account';
|
||||
$sql.= ", c.label as statut_label";
|
||||
$sql.= ", ca.code as availability_code, ca.label as availability";
|
||||
$sql.= ", dr.code as demand_reason_code, dr.label as demand_reason";
|
||||
@ -1120,6 +1124,7 @@ class Propal extends CommonObject
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
$this->mode_reglement_code = $obj->mode_reglement_code;
|
||||
$this->mode_reglement = $obj->mode_reglement;
|
||||
$this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null;
|
||||
$this->cond_reglement_id = $obj->fk_cond_reglement;
|
||||
$this->cond_reglement_code = $obj->cond_reglement_code;
|
||||
$this->cond_reglement = $obj->cond_reglement;
|
||||
|
||||
@ -60,6 +60,7 @@ class Commande extends CommonOrder
|
||||
var $brouillon;
|
||||
var $cond_reglement_id;
|
||||
var $cond_reglement_code;
|
||||
var $fk_account;
|
||||
var $mode_reglement_id;
|
||||
var $mode_reglement_code;
|
||||
var $availability_id;
|
||||
@ -658,7 +659,7 @@ class Commande extends CommonOrder
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande (";
|
||||
$sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_client, ref_int";
|
||||
$sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
|
||||
$sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
|
||||
$sql.= ", remise_absolue, remise_percent";
|
||||
$sql.= ", entity";
|
||||
$sql.= ")";
|
||||
@ -673,6 +674,7 @@ class Commande extends CommonOrder
|
||||
$sql.= ", '".$this->modelpdf."'";
|
||||
$sql.= ", ".($this->cond_reglement_id>0?"'".$this->cond_reglement_id."'":"null");
|
||||
$sql.= ", ".($this->mode_reglement_id>0?"'".$this->mode_reglement_id."'":"null");
|
||||
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
|
||||
$sql.= ", ".($this->availability_id>0?"'".$this->availability_id."'":"null");
|
||||
$sql.= ", ".($this->demand_reason_id>0?"'".$this->demand_reason_id."'":"null");
|
||||
$sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
|
||||
@ -986,6 +988,7 @@ class Commande extends CommonOrder
|
||||
$this->fk_project = $object->fk_project;
|
||||
$this->cond_reglement_id = $object->cond_reglement_id;
|
||||
$this->mode_reglement_id = $object->mode_reglement_id;
|
||||
$this->fk_account = $object->fk_account;
|
||||
$this->availability_id = $object->availability_id;
|
||||
$this->demand_reason_id = $object->demand_reason_id;
|
||||
$this->date_livraison = $object->date_livraison;
|
||||
@ -1329,6 +1332,7 @@ class Commande extends CommonOrder
|
||||
|
||||
$sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut';
|
||||
$sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
|
||||
$sql.= ', c.fk_account';
|
||||
$sql.= ', c.date_commande';
|
||||
$sql.= ', c.date_livraison';
|
||||
$sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
|
||||
@ -1388,6 +1392,7 @@ class Commande extends CommonOrder
|
||||
$this->cond_reglement_code = $obj->cond_reglement_code;
|
||||
$this->cond_reglement = $obj->cond_reglement_libelle;
|
||||
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
|
||||
$this->fk_account = $obj->fk_account;
|
||||
$this->availability_id = $obj->fk_availability;
|
||||
$this->availability_code = $obj->availability_code;
|
||||
$this->demand_reason_id = $obj->fk_input_reason;
|
||||
|
||||
@ -227,6 +227,7 @@ else if ($action == 'add' && $user->rights->commande->creer) {
|
||||
$object->modelpdf = GETPOST('model');
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->availability_id = GETPOST('availability_id');
|
||||
$object->demand_reason_id = GETPOST('demand_reason_id');
|
||||
$object->date_livraison = $datelivraison;
|
||||
@ -488,6 +489,11 @@ else if ($action == 'setconditions' && $user->rights->commande->creer) {
|
||||
}
|
||||
}
|
||||
|
||||
// bank account
|
||||
else if ($action == 'setbankaccount' && $user->rights->propal->creer) {
|
||||
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
}
|
||||
|
||||
else if ($action == 'setremisepercent' && $user->rights->commande->creer) {
|
||||
$result = $object->set_remise($user, GETPOST('remise_percent'));
|
||||
}
|
||||
@ -1392,6 +1398,7 @@ if ($action == 'create' && $user->rights->commande->creer) {
|
||||
$soc = $objectsrc->client;
|
||||
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
|
||||
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
|
||||
$fk_account = (!empty($objectsrc->fk_account)?$objectsrc->fk_account:(!empty($soc->fk_account)?$soc->fk_account:0));
|
||||
$availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0));
|
||||
$demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0));
|
||||
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
|
||||
@ -1411,6 +1418,7 @@ if ($action == 'create' && $user->rights->commande->creer) {
|
||||
{
|
||||
$cond_reglement_id = $soc->cond_reglement_id;
|
||||
$mode_reglement_id = $soc->mode_reglement_id;
|
||||
$fk_account = $soc->fk_account;
|
||||
$availability_id = $soc->availability_id;
|
||||
$demand_reason_id = $soc->demand_reason_id;
|
||||
$remise_percent = $soc->remise_percent;
|
||||
@ -1506,6 +1514,11 @@ if ($action == 'create' && $user->rights->commande->creer) {
|
||||
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank Account
|
||||
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
|
||||
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Delivery delay
|
||||
print '<tr><td>' . $langs->trans('AvailabilityPeriod') . '</td><td colspan="2">';
|
||||
$form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1);
|
||||
@ -2120,7 +2133,27 @@ if ($action == 'create' && $user->rights->commande->creer) {
|
||||
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0)
|
||||
$rowspan ++;
|
||||
|
||||
// Total HT
|
||||
// Bank Account
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('BankAccount');
|
||||
print '<td>';
|
||||
if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($action == 'editbankaccount')
|
||||
{
|
||||
$form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
|
||||
}
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
// Total HT
|
||||
print '<tr><td>' . $langs->trans('AmountHT') . '</td>';
|
||||
print '<td align="right">' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '</td>';
|
||||
|
||||
|
||||
@ -1079,6 +1079,40 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change the bank account
|
||||
*
|
||||
* @param int $fk_account Id of bank account
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function setBankAccount($fk_account)
|
||||
{
|
||||
if (! $this->table_element)
|
||||
{
|
||||
dol_syslog(get_class($this)."::setBankAccount was called on objet with property table_element not defined",LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
if ($fk_account<0) $fk_account='NULL';
|
||||
dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')');
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= " SET fk_account = ".$fk_account;
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->fk_account = ($fk_account=='NULL')?null:$fk_account;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save a new position (field rang) for details lines.
|
||||
* You can choose to set position for lines with already a position or lines without any position defined.
|
||||
|
||||
@ -2480,6 +2480,44 @@ class Form
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to select bank account
|
||||
*
|
||||
* @param string $page Page
|
||||
* @param int $selected Id of bank account
|
||||
* @param string $htmlname Name of select html field
|
||||
* @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
|
||||
* @return void
|
||||
*/
|
||||
function form_select_comptes($page, $selected='', $htmlname='fk_account', $addempty=0)
|
||||
{
|
||||
global $langs;
|
||||
if ($htmlname != "none")
|
||||
{
|
||||
print '<form method="POST" action="'.$page.'">';
|
||||
print '<input type="hidden" name="action" value="setbankaccount">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
print '<tr><td>';
|
||||
$this->select_comptes($selected, $htmlname, 0, '', $addempty);
|
||||
print '</td>';
|
||||
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
print '</tr></table></form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($selected)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
|
||||
$bankstatic=new Account($this->db);
|
||||
$bankstatic->fetch($selected);
|
||||
print $bankstatic->label.' ('.$bankstatic->currency_code.')';
|
||||
} else {
|
||||
print " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of categories having choosed type
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user