Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-02-20 20:46:29 +01:00
commit efd23e983c
5 changed files with 80 additions and 98 deletions

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -36,14 +36,17 @@ $langs->load('banks');
$langs->load('companies');
// Security check
$id=GETPOST("id");
$action=GETPOST("action");
$id=GETPOST('id','int');
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
if ($user->societe_id) $socid=$user->societe_id;
// TODO ajouter regle pour restreindre acces paiement
//$result = restrictedArea($user, 'facture', $id,'');
$mesg='';
$object = new Paiement($db);
/*
* Actions
@ -53,9 +56,8 @@ if ($action == 'setnote' && $user->rights->facture->paiement)
{
$db->begin();
$paiement = new Paiement($db);
$paiement->fetch($id);
$result = $paiement->update_note(GETPOST('note'));
$object->fetch($id);
$result = $object->update_note(GETPOST('note'));
if ($result > 0)
{
$db->commit();
@ -63,18 +65,17 @@ if ($action == 'setnote' && $user->rights->facture->paiement)
}
else
{
$mesg='<div class="error">'.$paiement->error.'</div>';
$mesg='<div class="error">'.$object->error.'</div>';
$db->rollback();
}
}
if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights->facture->paiement)
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->paiement)
{
$db->begin();
$paiement = new Paiement($db);
$paiement->fetch($id);
$result = $paiement->delete();
$object->fetch($id);
$result = $object->delete();
if ($result > 0)
{
$db->commit();
@ -84,18 +85,17 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights-
else
{
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans($paiement->error).'</div>';
$mesg='<div class="error">'.$langs->trans($object->error).'</div>';
$db->rollback();
}
}
if ($action == 'confirm_valide' && GETPOST('confirm') == 'yes' && $user->rights->facture->paiement)
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->paiement)
{
$db->begin();
$paiement = new Paiement($db);
$paiement->fetch($id);
if ($paiement->valide() > 0)
$object->fetch($id);
if ($object->valide() > 0)
{
$db->commit();
@ -115,22 +115,21 @@ if ($action == 'confirm_valide' && GETPOST('confirm') == 'yes' && $user->rights-
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
}
Header('Location: fiche.php?id='.$paiement->id);
Header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id);
exit;
}
else
{
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans($paiement->error).'</div>';
$mesg='<div class="error">'.$langs->trans($object->error).'</div>';
$db->rollback();
}
}
if ($action == 'setnum' && !empty($_POST['num']))
if ($action == 'setnum' && ! empty($_POST['num_paiement']))
{
$paiement = new Paiement($db);
$paiement->fetch($id);
$res = $paiement->update_num($_POST['num']);
$object->fetch($id);
$res = $object->update_num($_POST['num_paiement']);
if ($res === 0)
{
$mesg = '<div class="ok">'.$langs->trans('PaymentNumberUpdateSucceeded').'</div>';
@ -141,12 +140,11 @@ if ($action == 'setnum' && !empty($_POST['num']))
}
}
if ($action == 'setdate' && !empty($_POST['dateday']))
if ($action == 'setdate' && ! empty($_POST['datepday']))
{
$paiement = new Paiement($db);
$paiement->fetch($id);
$datepaye = dol_mktime(12, 0, 0, $_POST['datemonth'], $_POST['dateday'], $_POST['dateyear']);
$res = $paiement->update_date($datepaye);
$object->fetch($id);
$datepaye = dol_mktime(12, 0, 0, $_POST['datepmonth'], $_POST['datepday'], $_POST['datepyear']);
$res = $object->update_date($datepaye);
if ($res === 0)
{
$mesg = '<div class="ok">'.$langs->trans('PaymentDateUpdateSucceeded').'</div>';
@ -166,8 +164,7 @@ llxHeader();
$thirdpartystatic=new Societe($db);
$paiement = new Paiement($db);
$result=$paiement->fetch($id);
$result=$object->fetch($id);
if ($result <= 0)
{
dol_print_error($db,'Payement '.$id.' not found in database');
@ -178,7 +175,7 @@ $form = new Form($db);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$id;
$head[$h][0] = $_SERVER['PHP_SELF'].'?id='.$id;
$head[$h][1] = $langs->trans("Card");
$hselected = $h;
$h++;
@ -195,7 +192,7 @@ dol_fiche_head($head, $hselected, $langs->trans("PaymentCustomerInvoice"), 0, 'p
*/
if ($action == 'delete')
{
$ret=$form->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
$ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
if ($ret == 'html') print '<br>';
}
@ -205,7 +202,7 @@ if ($action == 'delete')
if ($action == 'valide')
{
$facid = $_GET['facid'];
$ret=$form->form_confirm('fiche.php?id='.$paiement->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
$ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
if ($ret == 'html') print '<br>';
}
@ -216,37 +213,37 @@ dol_htmloutput_mesg($mesg);
print '<table class="border" width="100%">';
// Ref
print '<tr><td valign="top" width="20%">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>';
print '<tr><td valign="top" width="20%">'.$langs->trans('Ref').'</td><td colspan="3">'.$object->id.'</td></tr>';
// Date payment
print '<tr><td valign="top">'.$form->editfieldkey("Date",'date',$paiement->date,$paiement,$user->rights->facture->paiement).'</td><td colspan="3">';
print $form->editfieldval("Date",'date',$paiement->date,$paiement,$user->rights->facture->paiement,'day');
print '<tr><td valign="top">'.$form->editfieldkey("Date",'datep',$object->date,$object,$user->rights->facture->paiement).'</td><td colspan="3">';
print $form->editfieldval("Date",'datep',$object->date,$object,$user->rights->facture->paiement,'datepicker','',null,$langs->trans('PaymentDateUpdateSucceeded'));
print '</td></tr>';
// Payment type (VIR, LIQ, ...)
$labeltype=$langs->trans("PaymentType".$paiement->type_code)!=("PaymentType".$paiement->type_code)?$langs->trans("PaymentType".$paiement->type_code):$paiement->type_libelle;
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle;
print '<tr><td valign="top">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype.'</td></tr>';
// Payment numero
print '<tr><td valign="top">'.$form->editfieldkey("Numero",'num',$paiement->numero,$paiement,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Numero",'num',$paiement->numero,$paiement,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'string');
print '<tr><td valign="top">'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
print '</td></tr>';
// Amount
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->currency).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant).'&nbsp;'.$langs->trans('Currency'.$conf->currency).'</td></tr>';
// Note
print '<tr><td valign="top">'.$form->editfieldkey("Note",'note',$paiement->note,$paiement,$user->rights->facture->paiement).'</td><td colspan="3">';
print $form->editfieldval("Note",'note',$paiement->note,$paiement,$user->rights->facture->paiement,'text');
print '<tr><td valign="top">'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->facture->paiement).'</td><td colspan="3">';
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->facture->paiement,'textarea');
print '</td></tr>';
// Bank account
if ($conf->banque->enabled)
{
if ($paiement->bank_account)
if ($object->bank_account)
{
$bankline=new AccountLine($db);
$bankline->fetch($paiement->bank_line);
$bankline->fetch($object->bank_line);
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
@ -270,7 +267,7 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture
$sql.= ' WHERE pf.fk_facture = f.rowid';
$sql.= ' AND f.fk_soc = s.rowid';
$sql.= ' AND f.entity = '.$conf->entity;
$sql.= ' AND pf.fk_paiement = '.$paiement->id;
$sql.= ' AND pf.fk_paiement = '.$object->id;
$resql=$db->query($sql);
if ($resql)
{
@ -360,11 +357,11 @@ print '<div class="tabsAction">';
if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
{
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
if ($user->societe_id == 0 && $object->statut == 0 && $_GET['action'] == '')
{
if ($user->rights->facture->paiement)
{
print '<a class="butAction" href="fiche.php?id='.$id.'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
}
}
}
@ -375,7 +372,7 @@ if ($user->societe_id == 0 && $action == '')
{
if (! $disable_delete)
{
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
else
{
@ -386,7 +383,7 @@ if ($user->societe_id == 0 && $action == '')
print '</div>';
$db->close();
llxFooter();
$db->close();
?>

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2011-2012 Regis Houssin <regis@dolibarr.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
@ -63,7 +63,8 @@ if((isset($_GET['field']) && ! empty($_GET['field']))
if ($element == 'propal') $element = 'propale';
else if ($element == 'fichinter') $element = 'ficheinter';
if ($user->rights->$element->lire || $user->rights->$element->read
if (($element == 'payment' && $user->rights->facture->paiement)
|| $user->rights->$element->lire || $user->rights->$element->read
|| $user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read)
{
if ($type == 'select')

View File

@ -69,7 +69,8 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
if ($element == 'propal') $element = 'propale';
else if ($element == 'fichinter') $element = 'ficheinter';
if ($user->rights->$element->creer || $user->rights->$element->write
if (($element == 'payment' && $user->rights->facture->paiement)
|| $user->rights->$element->creer || $user->rights->$element->write
|| $user->rights->$element->$subelement->creer || $user->rights->$element->$subelement->write)
{
// Clean parameters

View File

@ -118,9 +118,10 @@ class Form
* @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...)
* @param string $editvalue When in edit mode, use this value as $value instead of value
* @param object $extObject External object
* @param string $success Success message
* @return string HTML edit field
*/
function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=false)
function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=null,$success=null)
{
global $conf,$langs,$db;
@ -129,7 +130,7 @@ class Form
// When option to edit inline is activated
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE))
{
$ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject);
$ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject, $success);
}
else
{
@ -194,9 +195,10 @@ class Form
* @param int $condition Condition to edit
* @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx')
* @param object $extObject External object
* @param string $success Success message
* @return string HTML edit in place
*/
private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=false)
private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=null, $success=null)
{
global $conf;
@ -238,7 +240,7 @@ class Form
$inputType=$tmp[0]; $inputOption=$tmp[1];
if (! empty($tmp[2])) $savemethod=$tmp[2];
}
if (preg_match('/^datepicker/',$inputType))
else if (preg_match('/^datepicker/',$inputType))
{
$tmp=explode(':',$inputType);
$inputType=$tmp[0]; $inputOption=$tmp[1];
@ -276,6 +278,7 @@ class Form
$out.= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n";
$out.= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n";
$out.= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n";
if (! empty($success)) $out.= '<input id="success_'.$htmlname.'" value="'.$success.'" type="hidden"/>'."\n";
//$out.= '<input id="ext_table_element_'.$htmlname.'" value="'.$ext_table_element.'" type="hidden"/>'."\n";
//$out.= '<input id="ext_fk_element_'.$htmlname.'" value="'.$ext_fk_element.'" type="hidden"/>'."\n";

View File

@ -1,5 +1,5 @@
// Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
// Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
// Copyright (C) 2011-2012 Regis Houssin <regis@dolibarr.fr>
// Copyright (C) 2011 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
@ -45,14 +45,7 @@ $(document).ready(function() {
return getParameters('textarea', htmlname);
},
callback : function(result, settings) {
var obj = $.parseJSON(result);
if (obj.error) {
$(this).html(this.revert);
$.jnotify(obj.error, "error", true);
} else {
$(this).html(obj.value);
}
getResult(this, result);
}
});
$('.editkey_textarea').hover(
@ -85,14 +78,7 @@ $(document).ready(function() {
return getParameters('ckeditor', htmlname);
},
callback : function(result, settings) {
var obj = $.parseJSON(result);
if (obj.error) {
$(this).html(this.revert);
$.jnotify(obj.error, "error", true);
} else {
$(this).html(obj.value);
}
getResult(this, result);
}
});
$('.editkey_ckeditor').hover(
@ -121,14 +107,7 @@ $(document).ready(function() {
return getParameters('string', htmlname);
},
callback : function(result, settings) {
var obj = $.parseJSON(result);
if (obj.error) {
$(this).html(this.revert);
$.jnotify(obj.error, "error", true);
} else {
$(this).html(obj.value);
}
getResult(this, result);
}
});
$('.editkey_string').hover(
@ -193,14 +172,7 @@ $(document).ready(function() {
return getParameters('datepicker', htmlname);
},
callback : function(result, settings) {
var obj = $.parseJSON(result);
if (obj.error) {
$(this).html(this.revert);
$.jnotify(obj.error, "error", true);
} else {
$(this).html(obj.value);
}
getResult(this, result);
}
});
$('.editkey_datepicker').hover(
@ -235,14 +207,7 @@ $(document).ready(function() {
return getParameters('select', htmlname);
},
callback : function(result, settings) {
var obj = $.parseJSON(result);
if (obj.error) {
$(this).html(this.revert);
$.jnotify(obj.error, "error", true);
} else {
$(this).html(obj.value);
}
getResult(this, result);
}
});
$('.editkey_select').hover(
@ -282,6 +247,21 @@ $(document).ready(function() {
};
}
function getResult(obj, result) {
var res = $.parseJSON(result);
if (res.error) {
$(obj).html(obj.revert);
$.jnotify(res.error, "error", true);
} else {
var htmlname = $(obj).attr('id').substr(4);
var success = $( '#success_' + htmlname ).val();
if (success != undefined) {
$.jnotify(success, "ok");
}
$(obj).html(res.value);
}
}
$('.edit_autocomplete').editable(urlSaveInPlace, {
type : 'autocomplete',
id : 'field',