Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
c08015a93a
@ -264,6 +264,7 @@ class Contrat extends CommonObject
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @param string $comment Comment
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @see closeAll
|
||||
*/
|
||||
function activateAll($user, $date_start='', $notrigger=0, $comment='')
|
||||
{
|
||||
@ -279,7 +280,7 @@ class Contrat extends CommonObject
|
||||
foreach($this->lines as $contratline)
|
||||
{
|
||||
// Open lines not already open
|
||||
if ($contratline->statut != 4)
|
||||
if ($contratline->statut != ContratLigne::STATUS_OPEN)
|
||||
{
|
||||
$contratline->context = $this->context;
|
||||
|
||||
@ -319,6 +320,7 @@ class Contrat extends CommonObject
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @param string $comment Comment
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @see activateAll
|
||||
*/
|
||||
function closeAll(User $user, $notrigger=0, $comment='')
|
||||
{
|
||||
@ -334,11 +336,11 @@ class Contrat extends CommonObject
|
||||
foreach($this->lines as $contratline)
|
||||
{
|
||||
// Close lines not already closed
|
||||
if ($contratline->statut != 5)
|
||||
if ($contratline->statut != ContratLigne::STATUS_CLOSED)
|
||||
{
|
||||
$contratline->date_cloture=$now;
|
||||
$contratline->fk_user_cloture=$user->id;
|
||||
$contratline->statut='5';
|
||||
$contratline->statut=ContratLigne::STATUS_CLOSED;
|
||||
$result=$contratline->close_line($user, $now, $comment, $notrigger);
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -806,10 +808,10 @@ class Contrat extends CommonObject
|
||||
//dol_syslog("1 ".$line->desc);
|
||||
//dol_syslog("2 ".$line->product_desc);
|
||||
|
||||
if ($line->statut == 0) $this->nbofserviceswait++;
|
||||
if ($line->statut == 4 && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) $this->nbofservicesopened++;
|
||||
if ($line->statut == 4 && (! empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++;
|
||||
if ($line->statut == 5) $this->nbofservicesclosed++;
|
||||
if ($line->statut == ContratLigne::STATUS_INITIAL) $this->nbofserviceswait++;
|
||||
if ($line->statut == ContratLigne::STATUS_OPEN && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) $this->nbofservicesopened++;
|
||||
if ($line->statut == ContratLigne::STATUS_OPEN && (! empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++;
|
||||
if ($line->statut == ContratLigne::STATUS_CLOSED) $this->nbofservicesclosed++;
|
||||
|
||||
$total_ttc+=$objp->total_ttc; // TODO Not saved into database
|
||||
$total_vat+=$objp->total_tva;
|
||||
@ -2518,6 +2520,11 @@ class ContratLigne extends CommonObjectLine
|
||||
var $fk_user_cloture;
|
||||
var $commentaire;
|
||||
|
||||
const STATUS_INITIAL = 0;
|
||||
const STATUS_OPEN = 4;
|
||||
const STATUS_CLOSED = 5;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -2556,51 +2563,51 @@ class ContratLigne extends CommonObjectLine
|
||||
$langs->load("contracts");
|
||||
if ($mode == 0)
|
||||
{
|
||||
if ($statut == 0) { return $langs->trans("ServiceStatusInitial"); }
|
||||
if ($statut == 4 && $expired == -1) { return $langs->trans("ServiceStatusRunning"); }
|
||||
if ($statut == 4 && $expired == 0) { return $langs->trans("ServiceStatusNotLate"); }
|
||||
if ($statut == 4 && $expired == 1) { return $langs->trans("ServiceStatusLate"); }
|
||||
if ($statut == 5) { return $langs->trans("ServiceStatusClosed"); }
|
||||
if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLate"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLate"); }
|
||||
if ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); }
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
if ($statut == 0) { return $langs->trans("ServiceStatusInitial"); }
|
||||
if ($statut == 4 && $expired == -1) { return $langs->trans("ServiceStatusRunning"); }
|
||||
if ($statut == 4 && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort"); }
|
||||
if ($statut == 4 && $expired == 1) { return $langs->trans("ServiceStatusLateShort"); }
|
||||
if ($statut == 5) { return $langs->trans("ServiceStatusClosed"); }
|
||||
if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort"); }
|
||||
if ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); }
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); }
|
||||
if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); }
|
||||
if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLateShort"); }
|
||||
if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLateShort"); }
|
||||
if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); }
|
||||
if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLateShort"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLateShort"); }
|
||||
if ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); }
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0',$moreatt); }
|
||||
if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4',$moreatt); }
|
||||
if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4',$moreatt); }
|
||||
if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3',$moreatt); }
|
||||
if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6',$moreatt); }
|
||||
if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0',$moreatt); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4',$moreatt); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4',$moreatt); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3',$moreatt); }
|
||||
if ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6',$moreatt); }
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); }
|
||||
if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); }
|
||||
if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLate"); }
|
||||
if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLate"); }
|
||||
if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); }
|
||||
if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLate"); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLate"); }
|
||||
if ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); }
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
if ($statut == 0) { return $langs->trans("ServiceStatusInitial").' '.img_picto($langs->trans('ServiceStatusInitial'),'statut0'); }
|
||||
if ($statut == 4 && $expired == -1) { return $langs->trans("ServiceStatusRunning").' '.img_picto($langs->trans('ServiceStatusRunning'),'statut4'); }
|
||||
if ($statut == 4 && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort").' '.img_picto($langs->trans('ServiceStatusNotLateShort'),'statut4'); }
|
||||
if ($statut == 4 && $expired == 1) { return $langs->trans("ServiceStatusLateShort").' '.img_picto($langs->trans('ServiceStatusLate'),'statut3'); }
|
||||
if ($statut == 5) { return $langs->trans("ServiceStatusClosed").' '.img_picto($langs->trans('ServiceStatusClosed'),'statut6'); }
|
||||
if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial").' '.img_picto($langs->trans('ServiceStatusInitial'),'statut0'); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning").' '.img_picto($langs->trans('ServiceStatusRunning'),'statut4'); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort").' '.img_picto($langs->trans('ServiceStatusNotLateShort'),'statut4'); }
|
||||
if ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort").' '.img_picto($langs->trans('ServiceStatusLate'),'statut3'); }
|
||||
if ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed").' '.img_picto($langs->trans('ServiceStatusClosed'),'statut6'); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -3096,13 +3103,13 @@ class ContratLigne extends CommonObjectLine
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = 4,";
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = ".ContratLigne::STATUS_OPEN.",";
|
||||
$sql .= " date_ouverture = " . (dol_strlen($date) != 0 ? "'" . $this->db->idate($date) . "'" : "null") . ",";
|
||||
if ($date_end >= 0) $sql .= " date_fin_validite = " . (dol_strlen($date_end) != 0 ? "'" . $this->db->idate($date_end) . "'" : "null") . ",";
|
||||
$sql .= " fk_user_ouverture = " . $user->id . ",";
|
||||
$sql .= " date_cloture = null,";
|
||||
$sql .= " commentaire = '" . $this->db->escape($comment) . "'";
|
||||
$sql .= " WHERE rowid = " . $this->id . " AND (statut = 0 OR statut = 3 OR statut = 5)";
|
||||
$sql .= " WHERE rowid = " . $this->id . " AND (statut = ".ContratLigne::STATUS_INITIAL." OR statut = ".ContratLigne::STATUS_CLOSED.")";
|
||||
|
||||
dol_syslog(get_class($this) . "::active_line", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -3114,7 +3121,7 @@ class ContratLigne extends CommonObjectLine
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->statut = 4;
|
||||
$this->statut = ContratLigne::STATUS_OPEN;
|
||||
$this->date_ouverture = $date;
|
||||
$this->date_fin_validite = $date_end;
|
||||
$this->fk_user_ouverture = $user->id;
|
||||
@ -3160,11 +3167,11 @@ class ContratLigne extends CommonObjectLine
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = 5,";
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = ".ContratLigne::STATUS_CLOSED.",";
|
||||
$sql .= " date_cloture = '" . $this->db->idate($date_end) . "',";
|
||||
$sql .= " fk_user_cloture = " . $user->id . ",";
|
||||
$sql .= " commentaire = '" . $this->db->escape($comment) . "'";
|
||||
$sql .= " WHERE rowid = " . $this->id . " AND statut = 4";
|
||||
$sql .= " WHERE rowid = " . $this->id . " AND statut = ".ContratLigne::STATUS_OPEN;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -1743,7 +1743,7 @@ class ExtraFields
|
||||
*/
|
||||
function showSeparator($key)
|
||||
{
|
||||
$out = '<tr class="trextrafieldseparator"><td colspan="4"><strong>'.$this->attribute_label[$key].'</strong></td></tr>';
|
||||
$out = '<tr class="trextrafieldseparator trextrafieldseparator'.$key.'"><td colspan="4"><strong>'.$this->attribute_label[$key].'</strong></td></tr>';
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
@ -3083,13 +3083,14 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
|
||||
$pictowithoutext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto);
|
||||
|
||||
//if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on')))
|
||||
if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow')))
|
||||
if (in_array($pictowithoutext, array('bank', 'delete', 'edit', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow')))
|
||||
{
|
||||
$fakey = $pictowithoutext; $facolor=''; $fasize='';
|
||||
if ($pictowithoutext == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; }
|
||||
elseif ($pictowithoutext == 'switch_on') { $fakey = 'fa-toggle-on'; $facolor='#227722'; $fasize='2em'; }
|
||||
elseif ($pictowithoutext == 'off') { $fakey = 'fa-square-o'; $fasize='1.3em'; }
|
||||
elseif ($pictowithoutext == 'on') { $fakey = 'fa-check-square-o'; $fasize='1.3em'; }
|
||||
elseif ($pictowithoutext == 'bank') { $fakey = 'fa-bank'; $facolor='#444'; }
|
||||
elseif ($pictowithoutext == 'delete') { $fakey = 'fa-trash'; $facolor='#444'; }
|
||||
elseif ($pictowithoutext == 'edit') { $fakey = 'fa-pencil'; $facolor='#444'; }
|
||||
elseif ($pictowithoutext == 'printer') { $fakey = 'fa-print'; $fasize='1.2em'; $facolor='#444'; }
|
||||
|
||||
@ -194,12 +194,12 @@ class Stripe extends CommonObject
|
||||
*
|
||||
* @param \Stripe\StripeCustomer $cu Object stripe customer
|
||||
* @param CompanyPaymentMode $object Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity)
|
||||
* @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect
|
||||
* @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect
|
||||
* @param int $status Status (0=test, 1=live)
|
||||
* @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card
|
||||
* @return \Stripe\StripeCard|null Stripe Card or null if not found
|
||||
*/
|
||||
public function cardStripe($cu, CompanyPaymentMode $object, $key='', $status=0, $createifnotlinkedtostripe=0)
|
||||
public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc='', $status=0, $createifnotlinkedtostripe=0)
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
@ -222,10 +222,10 @@ class Stripe extends CommonObject
|
||||
if ($cardref)
|
||||
{
|
||||
try {
|
||||
if (empty($key)) { // If the Stripe connect account not set, we use common API usage
|
||||
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
||||
$card = $cu->sources->retrieve($cardref);
|
||||
} else {
|
||||
$card = $cu->sources->retrieve($cardref, array("stripe_account" => $key));
|
||||
$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
@ -249,12 +249,12 @@ class Stripe extends CommonObject
|
||||
);
|
||||
|
||||
//$a = \Stripe\Stripe::getApiKey();
|
||||
//var_dump($a);var_dump($key);exit;
|
||||
//var_dump($a);var_dump($stripeacc);exit;
|
||||
try {
|
||||
if (empty($key)) { // If the Stripe connect account not set, we use common API usage
|
||||
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
||||
$card = $cu->sources->create($dataforcard);
|
||||
} else {
|
||||
$card = $cu->sources->create($dataforcard, array("stripe_account" => $key));
|
||||
$card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc));
|
||||
}
|
||||
|
||||
if ($card)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user