if ($object->fk_cash == '5' || $object->fk_cash == '6' || $object->fk_cash == '7') {
    echo "Carr. San Juan –Lagos Km 5.9 <br>San Juan de Los Lagos, Jal.";
}
if ($object->fk_cash == '8') {
    echo "Carr. San Juan –Lagos Km 5.9 <br>San Juan de Los Lagos, Jal.";
}
if ($object->fk_cash == '9' || $object->fk_cash == '10') {
    echo "Moreno Valley #199 <br>San Juan de los Lagos, Jal.<br>01(395) 785 3005";
}
?>
<br><br>
		
		<?php 
// Variables
$object = new Ticket($db);
$result = $object->fetch($id, $ref);
$userstatic = new User($db);
$userstatic->fetch($object->user_close);
print $langs->trans("Vendor") . ': ' . $userstatic->firstname . ' ' . $userstatic->lastname . '<br><br>';
if (!empty($object->fk_place)) {
    $place = new Place($db);
    $place->fetch($object->fk_place);
    print $langs->trans("Place") . ': ' . $place->name . "</p>";
}
?>
	</div>
</div>

<div><?php 
// Recuperation et affichage de la date et de l'heure
$now = dol_now();
 /**
  *	Delete ticket
  *	@param     	int		$idTicket    Id of ticket to delete
  *	@return		int					<0 if KO, >0 if OK
  */
 public static function Delete_Ticket($idTicket)
 {
     global $db;
     $function = "deleteTicket";
     $object = new Ticket($db);
     $object->fetch($idTicket);
     $db->begin;
     $res = $object->delete_ticket();
     if ($res) {
         $db->commit();
     } else {
         $db->rollback();
     }
     return ErrorControl($res, $function);
 }
dol_include_once('/pos/class/ticket.class.php');
require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php";
dol_include_once('/pos/backend/lib/ticket.lib.php');
$langs->load("pos@pos");
// Security check
$ticketid = isset($_GET["ticketid"]) ? $_GET["ticketid"] : '';
if ($user->societe_id) {
    $socid = $user->societe_id;
}
if (!$user->rights->pos->backend) {
    accessforbidden();
}
/*
 * View
 */
$helpurl = 'EN:Module_DoliPos|FR:Module_DoliPos_FR|ES:M&oacute;dulo_DoliPos';
llxHeader('', '', $helpurl);
$ticket = new Ticket($db);
$ticket->fetch($_GET["id"]);
$ticket->info($_GET["id"]);
$soc = new Societe($db, $ticket->socid);
$soc->fetch($ticket->socid);
$head = ticket_prepare_head($ticket);
dol_fiche_head($head, 'info', $langs->trans("Ticket"), 0, 'ticket');
print '<table width="100%"><tr><td>';
dol_print_object_info($ticket);
print '</td></tr></table>';
print '</div>';
llxFooter();
$db->close();
        if ($moneypoints > 0) {
            $json_data['pays_points'] = $usepoints . " " . $langs->trans("Points") . " " . price($moneypoints, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency));
        }
    }
    $json_data['customer_ret'] = ($diff_payment < 0 ? $langs->trans("CustomerRet") : $langs->trans("CustomerDeb")) . " " . price(abs($diff_payment), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency));
    if ($points != 0 && !empty($conf->rewards->enabled)) {
        $json_data['total_points'] = $langs->trans("TotalPointsInvoice") . " " . price($points, "", "", "", "", 2) . " " . $langs->trans('Points');
        $total_points = $rewards->getCustomerPoints($facture->socid);
        $json_data['dispo_points'] = $langs->trans("DispoPoints") . " " . price($total_points, "", "", "", "", 2) . " " . $langs->trans('Points');
    }
    $json_data['predef_msg'] = $conf->global->POS_PREDEF_MSG;
}
if ($pending_print[0][0] == "T" or $pending_print[0][0] == "G") {
    $json_data = array();
    $ticket = new Ticket($db);
    $res = $ticket->fetch($id);
    $mysoc = new Societe($db);
    $mysoc->fetch($ticket->socid);
    $userstatic = new User($db);
    $userstatic->fetch($ticket->user_close);
    $label = $ticket->ref;
    $facture = new Facture($db);
    if ($ticket->fk_facture) {
        $facture->fetch($ticket->fk_facture);
        $label = $facture->ref;
    }
    $json_data['type'] = $pending_print[0][0];
    $json_data['ref'] = $label;
    $json_data['mysoc_name'] = $mysoc->name ? $mysoc->name : "";
    $json_data['mysoc_address'] = $mysoc->address ? $mysoc->address : "";
    $json_data['mysoc_town'] = ($mysoc->zip ? $mysoc->zip : "") . ' ' . ($mysoc->town ? $mysoc->town : "");
 /**
  *      A record into bank for payment with links between this bank record and invoices of payment.
  *      All payment properties must have been set first like after a call to create().
  *      @param      user                Object of user making payment
  *      @param      mode                'payment', 'payment_supplier'
  *      @param      label               Label to use in bank record
  *      @param      accountid           Id of bank account to do link with
  *      @param      emetteur_nom        Name of transmitter
  *      @param      emetteur_banque     Name of bank
  *      @return     int                 <0 if KO, bank_line_id if OK
  */
 function addPaymentToBank($user, $mode, $label, $accountid, $socid, $emetteur_nom, $emetteur_banque, $notrigger = 0)
 {
     global $conf, $langs, $user;
     $error = 0;
     $bank_line_id = 0;
     $this->fk_account = $accountid;
     if ($conf->banque->enabled) {
         require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
         dol_syslog("{$user->id},{$mode},{$label},{$this->fk_account},{$emetteur_nom},{$emetteur_banque}");
         $acc = new Account($this->db);
         $acc->fetch($this->fk_account);
         $totalamount = $this->amount;
         if (empty($totalamount)) {
             $totalamount = $this->total;
         }
         // For backward compatibility
         if ($mode == 'payment') {
             $totalamount = $totalamount;
         }
         if ($mode == 'payment_supplier') {
             $totalamount = -$totalamount;
         }
         // Insert payment into llx_bank
         $bank_line_id = $acc->addline($this->datepaye, $this->paiementid, $label, $totalamount, $this->num_paiement, '', $user, $emetteur_nom, $emetteur_banque);
         // Mise a jour fk_bank dans llx_paiement
         // On connait ainsi le paiement qui a genere l'ecriture bancaire
         if ($bank_line_id > 0) {
             $result = $this->update_fk_bank($bank_line_id);
             if ($result <= 0) {
                 $error++;
                 dol_print_error($this->db);
             }
             // Add link 'payment', 'payment_supplier' in bank_url between payment and bank transaction
             if (!$error) {
                 $url = '';
                 if ($mode == 'payment') {
                     $url = DOL_URL_ROOT . '/compta/paiement/fiche.php?id=';
                 }
                 if ($mode == 'payment_supplier') {
                     $url = DOL_URL_ROOT . '/fourn/paiement/fiche.php?id=';
                 }
                 if ($url) {
                     $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
                     if ($result <= 0) {
                         $error++;
                         dol_print_error($this->db);
                     }
                 }
             }
             // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
             if (!$error) {
                 $linkaddedforthirdparty = array();
                 foreach ($this->amounts as $key => $value) {
                     if ($mode == 'payment') {
                         $fac = new Ticket($this->db);
                         $fac->fetch($key);
                         $fac->fetch_thirdparty();
                         if (!in_array($socid, $linkaddedforthirdparty)) {
                             $thirdparty = new Societe($this->db);
                             $thirdparty->fetch($socid);
                             $result = $acc->add_url_line($bank_line_id, $socid, DOL_URL_ROOT . '/comm/fiche.php?socid=', $thirdparty->nom, 'company');
                             if ($result <= 0) {
                                 dol_print_error($this->db);
                             }
                             $linkaddedforthirdparty[$fac->thirdparty->id] = $socid;
                             // Mark as done for this thirdparty
                         }
                     }
                 }
             }
             if (!$error && !$notrigger) {
                 // Appel des triggers
                 include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
                 $interface = new Interfaces($this->db);
                 $result = $interface->run_triggers('PAYMENT_ADD_TO_BANK', $this, $user, $langs, $conf);
                 if ($result < 0) {
                     $error++;
                     $this->errors = $interface->errors;
                 }
                 // Fin appel triggers
             }
         } else {
             $this->error = $acc->error;
             $error++;
         }
     }
     if (!$error) {
         return $bank_line_id;
     } else {
         return -1;
     }
 }
 print '<td align="right">' . $langs->trans('AmountTTC') . '</td>';
 print '<td align="right">' . $langs->trans('Received') . '</td>';
 print '<td align="right">' . $langs->trans('RemainderToPay') . '</td>';
 print '<td align="right">' . $langs->trans('PaymentAmount') . '</td>';
 print '<td align="right">&nbsp;</td>';
 print "</tr>\n";
 $var = True;
 $total = 0;
 $totalrecu = 0;
 $totalrecucreditnote = 0;
 $totalrecudeposits = 0;
 while ($i < $num) {
     $objp = $db->fetch_object($resql);
     $var = !$var;
     $invoice = new Ticket($db);
     $invoice->fetch($objp->ticketid);
     $paiement = $invoice->getSommePaiement();
     $alreadypayed = price2num($paiement, 'MT');
     $remaintopay = price2num($invoice->total_ttc - $paiement, 'MT');
     //if ($remaintopay>0)
     //{
     print '<tr ' . $bc[$var] . '>';
     print '<td>';
     print $invoice->getNomUrl(1, '');
     print "</td>\n";
     // Date
     print '<td align="center">' . dol_print_date($db->jdate($objp->df), 'day') . "</td>\n";
     // Prix
     print '<td align="right">' . price($objp->total_ttc) . '</td>';
     // Recu
     print '<td align="right">' . price($paiement);
 /**
  *      \brief     	Tag la ticket comme validee + appel trigger BILL_VALIDATE
  *      \param     	user            Utilisateur qui valide la ticket
  *      \param     	force_number	Reference a forcer de la ticket
  *	    \return		int				<0 si ko, >0 si ok
  */
 function validate($user, $force_number = '')
 {
     global $conf, $langs;
     require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
     $error = 0;
     // Protection
     if (!$this->brouillon) {
         dol_syslog("Ticket::validate no draft status", LOG_WARNING);
         return 0;
     }
     if (!$user->rights->ticket->valider) {
         $this->error = 'Permission denied';
         dol_syslog("Ticket::validate " . $this->error, LOG_ERR);
         return -1;
     }
     $this->db->begin();
     $this->fetch_thirdparty();
     $this->fetch_lines();
     // Check parameters
     if ($this->type == 1) {
         // Controle que ticket source connue
         if ($this->fk_ticket_source <= 0) {
             $this->error = $langs->trans("ErrorFieldRequired", $langs->trans("TicketReplacement"));
             $this->db->rollback();
             return -10;
         }
         // Charge la ticket source a remplacer
         $facreplaced = new Ticket($this->db);
         $result = $facreplaced->fetch($this->fk_ticket_source);
         if ($result <= 0) {
             $this->error = $langs->trans("ErrorBadTicket");
             $this->db->rollback();
             return -11;
         }
         // Controle que ticket source non deja remplacee par une autre
         $idreplacement = $facreplaced->getIdReplacingTicket('validated');
         if ($idreplacement && $idreplacement != $this->id) {
             $facreplacement = new Ticket($this->db);
             $facreplacement->fetch($idreplacement);
             $this->error = $langs->trans("ErrorTicketAlreadyReplaced", $facreplaced->ref, $facreplacement->ref);
             $this->db->rollback();
             return -12;
         }
         $result = $facreplaced->set_canceled($user, 'replaced', '');
         if ($result < 0) {
             $this->error = $facreplaced->error . " sql=" . $sql;
             $this->db->rollback();
             return -13;
         }
     }
     // Define new ref
     if ($force_number) {
         $num = $force_number;
     } else {
         if (preg_match('/^[\\(]?PROV/i', $this->ref)) {
             if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
                 $this->date = gmmktime();
                 $this->date_lim_reglement = $this->calculate_date_lim_reglement();
             }
             $num = $this->getNextNumRef($this->client);
         } else {
             $num = $this->ref;
         }
     }
     if ($num) {
         $this->update_price(1);
         // Validate
         $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'pos_ticket';
         $sql .= " SET ticketnumber='" . $num . "', fk_statut = 1, fk_user_valid = " . $user->id;
         if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
             $sql .= ', datef=' . $this->db->idate($this->date);
             $sql .= ', date_lim_reglement=' . $this->db->idate($this->date_lim_reglement);
         }
         $sql .= ' WHERE rowid = ' . $this->id;
         dol_syslog("Ticket::validate sql=" . $sql);
         $resql = $this->db->query($sql);
         if (!$resql) {
             dol_syslog("Ticket::validate Echec update - 10 - sql=" . $sql, LOG_ERR);
             dol_print_error($this->db);
             $error++;
         }
         // On verifie si la ticket etait une provisoire
         if (!$error && preg_match('/^[\\(]?PROV/i', $this->ref)) {
             // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne
         }
         if (!$error) {
             // Define third party as a customer
             $result = $this->client->set_as_client();
             // Si active on decremente le produit principal et ses composants a la validation de ticket
             if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL) {
                 require_once DOL_DOCUMENT_ROOT . "/product/stock/class/mouvementstock.class.php";
                 // Loop on each line
                 for ($i = 0; $i < sizeof($this->lines); $i++) {
                     if ($this->lines[$i]->fk_product > 0 && $this->lines[$i]->product_type == 0) {
                         $mouvP = new MouvementStock($this->db);
                         // We decrease stock for product
                         $entrepot_id = "1";
                         // TODO ajouter possibilite de choisir l'entrepot
                         $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice);
                         if ($result < 0) {
                             $error++;
                         }
                     }
                 }
             }
         }
         if (!$error) {
             // Rename directory if dir was a temporary ref
             if (preg_match('/^[\\(]?PROV/i', $this->ref)) {
                 // On renomme repertoire ticket ($this->ref = ancienne ref, $num = nouvelle ref)
                 // afin de ne pas perdre les fichiers attaches
                 $facref = dol_sanitizeFileName($this->ref);
                 $snumfa = dol_sanitizeFileName($num);
                 $dirsource = $conf->ticket->dir_output . '/' . $facref;
                 $dirdest = $conf->ticket->dir_output . '/' . $snumfa;
                 if (file_exists($dirsource)) {
                     dol_syslog("Ticket::validate rename dir " . $dirsource . " into " . $dirdest);
                     if (@rename($dirsource, $dirdest)) {
                         dol_syslog("Rename ok");
                         // Suppression ancien fichier PDF dans nouveau rep
                         dol_delete_file($conf->ticket->dir_output . '/' . $snumfa . '/' . $facref . '.*');
                     }
                 }
             }
         }
         // Set new ref and define current statut
         if (!$error) {
             $this->ref = $num;
             $this->ticketnumber = $num;
             $this->statut = 1;
         }
         $this->use_webcal = $conf->global->PHPWEBCALENDAR_BILLSTATUS == 'always' ? 1 : 0;
         // Trigger calls
         if (!$error) {
             // Appel des triggers
             /* include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
                $interface=new Interfaces($this->db);
                $result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$langs,$conf);
                if ($result < 0) { $error++; $this->errors=$interface->errors; }
                // Fin appel triggers*/
         }
     } else {
         $error++;
     }
     if (!$error) {
         $this->db->commit();
         return 1;
     } else {
         $this->db->rollback();
         $this->error = $this->db->lasterror();
         return -1;
     }
 }