Index: /home/aurelien/www/dev/dolibarr/dolibarr_311/trunk/htdocs/compta/facture.php =================================================================== --- /home/aurelien/www/dev/dolibarr/dolibarr_311/trunk/htdocs/compta/facture.php (révision 8) +++ /home/aurelien/www/dev/dolibarr/dolibarr_311/trunk/htdocs/compta/facture.php (copie de travail) @@ -2373,8 +2373,8 @@ $num = $db->num_rows($result); $i = 0; - if ($object->type != 2) - { +// if ($object->type != 2) +// { while ($i < $num) { $objp = $db->fetch_object($result); @@ -2389,7 +2389,7 @@ print ''; $i++; } - } +// } $db->free($result); } else @@ -2397,8 +2397,8 @@ dol_print_error($db); } - if ($object->type != 2) - { +// if ($object->type != 2) +// { // Total already paid print ''; if ($object->type != 3) print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); @@ -2488,13 +2488,13 @@ print ' :'; print ''.price($resteapayeraffiche).''; print ' '; - } - else - { - // Sold credit note - print ''.$langs->trans('TotalTTC').' :'; - print ''.price(abs($object->total_ttc)).' '; - } +// } +// else +// { +// // Sold credit note +// print ''.$langs->trans('TotalTTC').' :'; +// print ''.price(abs($object->total_ttc)).' '; +// } print ''; Index: /home/aurelien/www/dev/dolibarr/dolibarr_311/trunk/htdocs/compta/paiement.php =================================================================== --- /home/aurelien/www/dev/dolibarr/dolibarr_311/trunk/htdocs/compta/paiement.php (révision 8) +++ /home/aurelien/www/dev/dolibarr/dolibarr_311/trunk/htdocs/compta/paiement.php (copie de travail) @@ -83,6 +83,7 @@ $totalpaiement = $totalpaiement + $amounts[$cursorfacid]; $tmpfacture=new Facture($db); $tmpfacture->fetch($cursorfacid); + $ArrType[$cursorfacid] =$tmpfacture->type ; $amountsresttopay[$cursorfacid]=price2num($tmpfacture->total_ttc-$tmpfacture->getSommePaiement()); if ($amounts[$cursorfacid] && $amounts[$cursorfacid] > $amountsresttopay[$cursorfacid]) { @@ -156,6 +157,7 @@ $paiement->num_paiement = $_POST['num_paiement']; $paiement->note = $_POST['comment']; + if (! $error) { $paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0)); @@ -168,7 +170,13 @@ if (! $error) { - $result=$paiement->addPaymentToBank($user,'payment','(CustomerInvoicePayment)',$_POST['accountid'],$_POST['chqemetteur'],$_POST['chqbank']); + + if (!in_array(2,$ArrType)) + $result=$paiement->addPaymentToBank($user,'payment','(CustomerInvoicePayment)',$_POST['accountid'],$_POST['chqemetteur'],$_POST['chqbank']); + elseif (in_array(2,$ArrType)) + $result=$paiement->addPaymentToBank($user,'payment_avoir','(CustomerInvoicePaymentRemboursement)',$_POST['accountid'],'',''); + + if ($result < 0) { $errmsg=$paiement->error; @@ -231,213 +239,260 @@ // Bouchon if ($facture->type == 2) { - print $langs->trans("FeatureNotYetAvailable"); - llxFooter(); - exit; - } + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; - // Initialize data for confirmation (this is used because data can be change during confirmation) - if ($action == 'add_paiement') - { - $i=0; + print ''; - $formquestion[$i++]=array('type' => 'hidden','name' => 'facid', 'value' => $facture->id); - $formquestion[$i++]=array('type' => 'hidden','name' => 'socid', 'value' => $facture->socid); - $formquestion[$i++]=array('type' => 'hidden','name' => 'type', 'value' => $facture->type); + print '\n"; + + // Date payment + print ''; + print ''; + + print '\n"; + + print ''; + + print ''; + print ''; + + print ''; + if ($conf->banque->enabled) + { + if ($facture->type != 2) print ''; + if ($facture->type == 2) print ''; + print ''; + } + else + { + print ''; + } + print "\n"; + + + print '
'.$langs->trans('Company').''.$facture->client->getNomUrl(4)."
'.$langs->trans('Date').''; + $datepayment = dol_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0) : $datepayment); + $html->select_date($datepayment,'','','',0,"add_paiement",1,1); + print ''.$langs->trans('Comments').'
'.$langs->trans('PaymentMode').''; + $html->select_types_paiements((GETPOST('paiementcode')?GETPOST('paiementcode'):''),'paiementcode','',2); + print "'; + print '
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans('AccountToCredit').''.$langs->trans('AccountToDebit').''; + $html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',1); + print ' 
'; +// llxFooter(); +// exit; } + else { + // Initialize data for confirmation (this is used because data can be change during confirmation) + if ($action == 'add_paiement') + { + $i=0; - // Invoice with Paypal transaction - if ($conf->paypalplus->enabled && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && ! empty($facture->ref_int)) - { - if (! empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid=$conf->global->PAYPAL_BANK_ACCOUNT; - $paymentnum=$facture->ref_int; - } - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; } - print '}); - '."\n"; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print ''; + print '
'; - // Third party - print '\n"; + // Third party + print '\n"; - // Date payment - print ''; - print ''; + // Date payment + print ''; + print ''; - $rowspan=5; - if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT)) $rowspan++; + $rowspan=5; + if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT)) $rowspan++; - // Payment mode - print '\n"; - print ''; - print ''; + // Payment mode + print '\n"; + print ''; + print ''; - // Payment amount - if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT)) - { - print ''; - print ''; - print ''; - } + // Payment amount + if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT)) + { + print ''; + print ''; + print ''; + } - print ''; - if ($conf->banque->enabled) - { - if ($facture->type != 2) print ''; - if ($facture->type == 2) print ''; - print ''; - } - else - { - print ''; - } - print "\n"; + print ''; + if ($conf->banque->enabled) + { + if ($facture->type != 2) print ''; + if ($facture->type == 2) print ''; + print ''; + } + else + { + print ''; + } + print "\n"; - // Cheque number - print ''; - print ''; + // Cheque number + print ''; + print ''; - // Check transmitter - print ''; - print ''; + // Check transmitter + print ''; + print ''; - // Bank name - print ''; - print ''; + // Bank name + print ''; + print ''; - print '
'.$langs->trans('Company').''.$facture->client->getNomUrl(4)."
'.$langs->trans('Company').''.$facture->client->getNomUrl(4)."
'.$langs->trans('Date').''; - $datepayment = dol_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0) : $datepayment); - $html->select_date($datepayment,'','','',0,"add_paiement",1,1); - print ''.$langs->trans('Comments').'
'.$langs->trans('Date').''; + $datepayment = dol_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0) : $datepayment); + $html->select_date($datepayment,'','','',0,"add_paiement",1,1); + print ''.$langs->trans('Comments').'
'.$langs->trans('PaymentMode').''; - $html->select_types_paiements((GETPOST('paiementcode')?GETPOST('paiementcode'):$facture->mode_reglement_code),'paiementcode','',2); - print "'; - print '
'.$langs->trans('PaymentMode').''; + $html->select_types_paiements((GETPOST('paiementcode')?GETPOST('paiementcode'):$facture->mode_reglement_code),'paiementcode','',2); + print "'; + print '
'.$langs->trans('AmountPayment').''; - if ($action == 'add_paiement') - { - print ''; - print ''; - } - else - { - print ''; - } - print '
'.$langs->trans('AmountPayment').''; + if ($action == 'add_paiement') + { + print ''; + print ''; + } + else + { + print ''; + } + print '
'.$langs->trans('AccountToCredit').''.$langs->trans('AccountToDebit').''; - $html->select_comptes($accountid,'accountid',0,'',2); - print ' 
'.$langs->trans('AccountToCredit').''.$langs->trans('AccountToDebit').''; + $html->select_comptes($accountid,'accountid',0,'',2); + print ' 
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print '
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans('CheckTransmitter'); - print ' ('.$langs->trans("ChequeMaker").')'; - print '
'.$langs->trans('CheckTransmitter'); + print ' ('.$langs->trans("ChequeMaker").')'; + print '
'.$langs->trans('Bank'); - print ' ('.$langs->trans("ChequeBank").')'; - print '
'.$langs->trans('Bank'); + print ' ('.$langs->trans("ChequeBank").')'; + print '
'; - + print ''; + } /* * List of unpaid invoices */ Index: /home/aurelien/www/dev/dolibarr/dolibarr_311/trunk/htdocs/compta/paiement/class/paiement.class.php =================================================================== --- /home/aurelien/www/dev/dolibarr/dolibarr_311/trunk/htdocs/compta/paiement/class/paiement.class.php (révision 8) +++ /home/aurelien/www/dev/dolibarr/dolibarr_311/trunk/htdocs/compta/paiement/class/paiement.class.php (copie de travail) @@ -383,6 +383,7 @@ if (empty($totalamount)) $totalamount=$this->total; // For backward compatibility if ($mode == 'payment') $totalamount=$totalamount; if ($mode == 'payment_supplier') $totalamount=-$totalamount; + if ($mode == 'payment_avoir') $totalamount=-abs($totalamount); // Insert payment into llx_bank $bank_line_id = $acc->addline($this->datepaye, @@ -410,7 +411,7 @@ if ( ! $error) { $url=''; - if ($mode == 'payment') $url=DOL_URL_ROOT.'/compta/paiement/fiche.php?id='; + if ($mode == 'payment' || $mode == 'payment_avoir') $url=DOL_URL_ROOT.'/compta/paiement/fiche.php?id='; if ($mode == 'payment_supplier') $url=DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='; if ($url) { @@ -429,7 +430,7 @@ $linkaddedforthirdparty=array(); foreach ($this->amounts as $key => $value) // We should have always same third party but we loop in case of. { - if ($mode == 'payment') + if ($mode == 'payment' || $mode == 'payment_avoir') { $fac = new Facture($this->db); $fac->fetch($key);