Skip to content

Commit

Permalink
Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into develop
Browse files Browse the repository at this point in the history
Conflicts:
	htdocs/compta/bank/index.php
	htdocs/fourn/facture/card.php
  • Loading branch information
eldy committed Oct 22, 2017
2 parents 5984222 + 6b0d060 commit c9fceaa
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 67 deletions.
6 changes: 3 additions & 3 deletions htdocs/compta/bank/list.php
Expand Up @@ -74,7 +74,7 @@
$extrafields = new ExtraFields($db);

// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('bankaccount');
$extralabels = $extrafields->fetch_name_optionals_label('bank_account');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');

// List of fields to search into when doing a "search in all"
Expand Down Expand Up @@ -143,15 +143,15 @@
// Load array of financial accounts (opened by default)
$accounts = array();

$sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, currency_code, datec as date_creation, tms as date_update";
$sql = "SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bankcacount_extrafields as ef on (c.rowid = ef.fk_object)";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account_extrafields as ef on (b.rowid = ef.fk_object)";
$sql.= " WHERE entity IN (".getEntity('bank_account').")";
if ($search_status == 'opened') $sql.= " AND clos = 0";
if ($search_status == 'closed') $sql.= " AND clos = 1";
Expand Down
5 changes: 3 additions & 2 deletions htdocs/fourn/class/fournisseur.facture.class.php
Expand Up @@ -1311,8 +1311,9 @@ function set_draft($user, $idwarehouse=-1)
if ($this->lines[$i]->fk_product > 0)
{
$mouvP = new MouvementStock($this->db);
// We increase stock for product
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref));
$mouvP->origin = &$this;
// We increase stock for product
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref));
}
}
}
Expand Down
189 changes: 129 additions & 60 deletions htdocs/fourn/facture/card.php
Expand Up @@ -1162,7 +1162,7 @@


// Set invoice to draft status
elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer)
elseif ($action == 'confirm_edit' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
{
$object->fetch($id);

Expand All @@ -1172,10 +1172,36 @@
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
//$ventilExportCompta = $object->getVentilExportCompta();

// On verifie si aucun paiement n'a ete effectue
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
{
$object->set_draft($user);
// On verifie si aucun paiement n'a ete effectue
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
{
$idwarehouse = GETPOST('idwarehouse');

$object->fetch_thirdparty();

$qualified_for_stock_change=0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
$qualified_for_stock_change=$object->hasProductsOrServices(2);
}
else
{
$qualified_for_stock_change=$object->hasProductsOrServices(1);
}

// Check parameters
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
{
$langs->load("stocks");
if (! $idwarehouse || $idwarehouse == -1)
{
$error++;
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$action='';
}
}

$object->set_draft($user, $idwarehouse);

// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
Expand Down Expand Up @@ -1978,19 +2004,62 @@
$qualified_for_stock_change=$object->hasProductsOrServices(1);
}

if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
{
$langs->load("stocks");
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db);
$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' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
}
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
{
$langs->load("stocks");
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db);
$warehouse = new Entrepot($db);
$warehouse_array = $warehouse->list_array();
if (count($warehouse_array) == 1) {
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array));
$value = '<input type="hidden" id="idwarehouse" name="idwarehouse" value="' . key($warehouse_array) . '">';
} else {
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
$value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1);
}
$formquestion = array(
array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value)
);
}

$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, 1, 1);

$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, 1, 1, 240);
}

// Confirmation edit (back to draft)
if ($action == 'edit')
{
$formquestion = array();

$qualified_for_stock_change = 0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
$qualified_for_stock_change = $object->hasProductsOrServices(2);
}
else
{
$qualified_for_stock_change = $object->hasProductsOrServices(1);
}
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
{
$langs->load("stocks");
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
$warehouse = new Entrepot($db);
$warehouse_array = $warehouse->list_array();
if (count($warehouse_array) == 1) {
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans("WarehouseForStockDecrease", current($warehouse_array));
$value = '<input type="hidden" id="idwarehouse" name="idwarehouse" value="' . key($warehouse_array) . '">';
} else {
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockIncrease") : $langs->trans("SelectWarehouseForStockDecrease");
$value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1);
}
$formquestion = array(
array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value)
);
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateBill'), $langs->trans('ConfirmUnvalidateBill', $object->ref), 'confirm_edit', $formquestion, 1, 1);

}

Expand Down Expand Up @@ -2674,8 +2743,8 @@
if (empty($reshook))
{

// Modify a validated invoice with no payments
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer)
// Modify a validated invoice with no payments
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans('Modify').'</a></div>';
}
Expand Down Expand Up @@ -2707,17 +2776,17 @@
else print '<div class="inline-block divButAction"><span class="butActionRefused">'.$langs->trans('SendByMail').'</a></div>';
}

// Make payments
if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
{
print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create'.($object->fk_account>0?'&amp;accountid='.$object->fk_account:'').'">'.$langs->trans('DoPayment').'</a></div>'; // must use facid because id is for payment id not invoice
}
// Make payments
if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
{
print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create'.($object->fk_account>0?'&amp;accountid='.$object->fk_account:'').'">'.$langs->trans('DoPayment').'</a></div>'; // must use facid because id is for payment id not invoice
}

// Classify paid
if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid"';
print '>'.$langs->trans('ClassifyPaid').'</a></div>';
// Classify paid
if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid"';
print '>'.$langs->trans('ClassifyPaid').'</a></div>';

//print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid">'.$langs->trans('ClassifyPaid').'</a>';
}
Expand Down Expand Up @@ -2748,24 +2817,24 @@
}
}

// Validate
if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_DRAFT)
{
if (count($object->lines))
{
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"';
print '>'.$langs->trans('Validate').'</a></div>';
}
else
{
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'"';
print '>'.$langs->trans('Validate').'</a></div>';
}
}
}
// Validate
if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT)
{
if (count($object->lines))
{
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"';
print '>'.$langs->trans('Validate').'</a></div>';
}
else
{
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'"';
print '>'.$langs->trans('Validate').'</a></div>';
}
}
}

// Create event
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page.
Expand All @@ -2788,19 +2857,19 @@
}
}

// Delete
if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer)
{
if ($object->getSommePaiement()) {
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecausePayments") . '">' . $langs->trans('Delete') . '</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>';
}
}
print '</div>';

if ($action != 'edit')
{
// Delete
if ($action != 'confirm_edit' && $user->rights->fournisseur->facture->supprimer)
{
if ($object->getSommePaiement()) {
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecausePayments") . '">' . $langs->trans('Delete') . '</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>';
}
}
print '</div>';

if ($action != 'confirm_edit')
{
print '<div class="fichecenter"><div class="fichehalfleft">';

/*
Expand Down
12 changes: 10 additions & 2 deletions htdocs/product/card.php
Expand Up @@ -1114,6 +1114,14 @@
{
// We do no show price array on create when multiprices enabled.
// We must set them on prices tab.
print '<table class="border" width="100%">';
// VAT
print '<tr><td class="titlefieldcreate">' . $langs->trans("VATRate") . '</td><td>';
$defaultva = get_default_tva($mysoc, $mysoc);
print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1);
print '</td></tr>';
print '</table>';
print '<br>';
}
else
{
Expand Down Expand Up @@ -1574,7 +1582,7 @@
if (! empty($conf->accounting->enabled))
{
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('',$object->accountancy_code_sell);
$accountingaccount->fetch('',$object->accountancy_code_sell,1);

print $accountingaccount->getNomUrl(0,1,1,'',1);
} else {
Expand All @@ -1589,7 +1597,7 @@
if (! empty($conf->accounting->enabled))
{
$accountingaccount2 = new AccountingAccount($db);
$accountingaccount2->fetch('',$object->accountancy_code_buy);
$accountingaccount2->fetch('',$object->accountancy_code_buy,1);

print $accountingaccount2->getNomUrl(0,1,1,'',1);
} else {
Expand Down

0 comments on commit c9fceaa

Please sign in to comment.