/** * Return list of contents of a category * * @param string $field Field name for select in table. Full field name will be fk_field. * @param string $classname PHP Class of object to store entity * @param string $category_table Table name for select in table. Full table name will be PREFIX_categorie_table. * @param string $object_table Table name for select in table. Full table name will be PREFIX_table. * @return void */ function get_prod($idCat, $more, $ticketstate) { global $db, $conf; $objs = array(); $sql = "SELECT o.rowid as id, o.ref, o.label, o.description, "; $sql .= " o.fk_product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_product as c"; $sql .= ", " . MAIN_DB_PREFIX . "product as o"; if ($conf->global->POS_STOCK || $ticketstate == 1) { $sql .= " WHERE o.entity IN (" . getEntity("product", 1) . ")"; $sql .= " AND c.fk_categorie = " . $idCat; $sql .= " AND c.fk_product = o.rowid"; $sql .= " AND o.tosell = 1"; if (!$conf->global->POS_SERVICES) { $sql .= " AND o.fk_product_type = 0"; } } else { $cashid = $_SESSION['TERMINAL_ID']; $cash = new Cash($db); $cash->fetch($cashid); $warehouse = $cash->fk_warehouse; $sql .= ", " . MAIN_DB_PREFIX . "product_stock as ps"; $sql .= " WHERE o.entity IN (" . getEntity("product", 1) . ")"; $sql .= " AND c.fk_categorie = " . $idCat; $sql .= " AND c.fk_product = o.rowid"; $sql .= " AND o.tosell = 1"; $sql .= " AND o.rowid = ps.fk_product"; $sql .= " AND ps.fk_entrepot = " . $warehouse; $sql .= " AND ps.reel > 0"; if ($conf->global->POS_SERVICES) { $sql .= " union select o.rowid as id, o.ref, o.label, o.description,\t"; $sql .= " o.fk_product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_product as c,"; $sql .= MAIN_DB_PREFIX . "product as o"; $sql .= " where c.fk_categorie = " . $idCat; $sql .= " AND c.fk_product = o.rowid"; $sql .= " AND o.tosell = 1"; $sql .= " AND fk_product_type=1"; } } if ($more >= 0) { $sql .= " LIMIT " . $more . ",10 "; } $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $objp = $db->fetch_object($resql); $objs[$objp->id]["id"] = $objp->id; $objs[$objp->id]["ref"] = $objp->ref; $objs[$objp->id]["label"] = $objp->label; $objs[$objp->id]["description"] = $objp->description; $objs[$objp->id]["type"] = $objp->fk_product_type; $objs[$objp->id]["image"] = self::getImageProduct($objp->id, false); $objs[$objp->id]["thumb"] = self::getImageProduct($objp->id, true); $i++; } return $objs; } else { return -1; } }
<?php echo $mysoc->idprof1; ?> <br> <?php echo $mysoc->address; ?> <br> <?php echo $mysoc->zip . ' ' . $mysoc->town; ?> </p> <?php print '<p>' . $langs->trans("CloseCashReport") . ': ' . $ref . '<br>'; $cash = new Cash($db); $cash->fetch($terminal); print $langs->trans("Terminal") . ': ' . $cash->name . '<br>'; $userstatic = new User($db); $userstatic->fetch($fk_user); print $langs->trans("User") . ': ' . $userstatic->firstname . ' ' . $userstatic->lastname . '</p>'; print '<p class="date_heure">' . dol_print_date($db->jdate($date_end), 'dayhour') . '</p>'; ?> </div> </div> <p><?php print $langs->trans("TicketsCash"); ?> </p> <table class="liste_articles"> <tr class="titres"><th><?php print $langs->trans("Ticket");
$ticketstatic->id = $objp->ticketid; $ticketstatic->ref = $objp->facnumber; print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<td class="nobordernopadding" nowrap="nowrap">'; //print $ticketstatic->ref; print $ticketstatic->getNomUrl(1); print '</td>'; print '</tr></table>'; print "</td>\n"; // Date print '<td align="center" nowrap>'; print dol_print_date($db->jdate($objp->df), 'day'); print '</td>'; print '<td align="left">'; $cash = new Cash($db); $cash->fetch($objp->fk_cash); print $cash->getNomUrl(1); print '</td>'; print '<td align="left">'; if ($objp->fk_user_valid > 0) { $userstatic = new User($db); $userstatic->fetch($objp->fk_user_valid); print $userstatic->getNomUrl(1); } print '</td>'; print '<td align="left">'; if (!$user->rights->societe->client->voir) { print $objp->nom; } else { $thirdparty = new Societe($db); $thirdparty->id = $objp->socid;
$sql .= " WHERE login = '******'"; $sql .= " AND entity IN (0," . $conf->entity . ")"; $result = $db->query($sql); if ($result) { $tab = $db->fetch_array($res); foreach ($tab as $key => $value) { $return[$key] = $value; } $_SESSION['uid'] = $tab['rowid']; $_SESSION['uname'] = $username; $_SESSION['nom'] = $tab['lastname']; $_SESSION['prenom'] = $tab['firstname']; $_SESSION['TERMINAL_ID'] = $terminalid; dol_include_once('/pos/class/cash.class.php'); $terminal = new Cash($db); $terminal->fetch($terminalid); $userstatic = new User($db); $userstatic->fetch($_SESSION['uid']); $terminal->set_used($userstatic); if ($terminal->is_closed) { $terminal->set_open($userstatic); } //var_dump($_SESSION);exit; if ($terminal->tactil == 2) { if (file_exists(dol_buildpath('/pos/frontend/movil.php'))) { header('Location: ' . dol_buildpath('/pos/frontend/movil.php', 1)); } else { header('Location: ' . dol_buildpath('/pos/frontend/tpv.php', 1)); } } else { header('Location: ' . dol_buildpath('/pos/frontend/tpv.php', 1));
<div style="text-align: left;"> <?php $presupuesto = substr($object->ref, 0, 2); if ($presupuesto == "TK") { echo "Precios Sujetos a cambio sin Previo Aviso"; } ?> </div> <table class="totpay"> <?php echo '<tr><td></td></tr>'; echo '<tr><td></td></tr>'; $terminal = new Cash($db); $terminal->fetch($object->fk_cash); $pay = $object->getSommePaiement(); if ($object->customer_pay > $pay) { $pay = $object->customer_pay; } $diff_payment = $object->total_ttc - $pay; $listofpayments = $object->getListOfPayments(); foreach ($listofpayments as $paym) { if ($paym['type'] != 'LIQ') { echo '<tr><th nowrap="nowrap">' . $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . '</th><td nowrap="nowrap">' . price($paym['amount'], "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>"; } else { echo '<tr><th nowrap="nowrap">' . $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . '</th><td nowrap="nowrap">' . price($paym['amount'] - ($diff_payment < 0 ? $diff_payment : 0), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>"; } } echo '<tr><th nowrap="nowrap">' . ($diff_payment < 0 ? $langs->trans("CustomerRet") : $langs->trans("CustomerDeb")) . '</th><td nowrap="nowrap">' . price(abs($diff_payment), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>"; ?>
// For "custom" directory require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php"; dol_include_once('/pos/class/cash.class.php'); dol_include_once('/pos/backend/lib/cash.lib.php'); if (!$user->rights->pos->backend) { accessforbidden(); } $langs->load("pos@pos"); // Security check $socid = 0; $id = GETPOST('id'); if ($user->societe_id) { $socid = $user->societe_id; } //$result=restrictedArea($user,'pos',$id,''); /* * View */ $helpurl = 'EN:Module_DoliPos|FR:Module_DoliPos_FR|ES:Módulo_DoliPos'; llxHeader('', '', $helpurl); $cash = new Cash($db); $cash->fetch($id); $cash->info($id); $head = cash_prepare_head($cash); dol_fiche_head($head, 'info', $langs->trans("Cash"), 0, 'cashdesk'); print '<table width="100%"><tr><td>'; dol_print_object_info($cash); print '</td></tr></table>'; print '</div>'; llxFooter(); $db->close();
} print "</table>"; $db->free($resql); } else { dol_print_error($db); } } } /* ************************************************************************** */ /* */ /* Edition */ /* */ /* ************************************************************************** */ if (GETPOST("id") && $action == 'edit' && $user->rights->pos->backend) { $cash = new Cash($db); $cash->fetch(GETPOST("id")); print_fiche_titre($langs->trans("EditCash")); print "<br>"; print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $cash->id . '" method="post" name="formsoc">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="id" value="' . GETPOST("id", "int") . '">' . "\n\n"; print '<table class="border" width="100%">'; // Code print '<tr><td valign="top" class="fieldrequired">' . $langs->trans("Code") . '</td>'; print '<td colspan="3"><input size="3" type="text" class="flat" name="code" value="' . $cash->code . '"></td></tr>'; // Name print '<tr><td valign="top" class="fieldrequired">' . $langs->trans("Name") . '</td>'; print '<td colspan="3"><input size="30" type="text" class="flat" name="name" value="' . $cash->name . '"></td></tr>'; //Tactil print '<tr><td class="fieldrequired">' . $langs->trans('Type') . '</td>';
if ($object->total_localtax2 != 0) { echo '<tr><td></td><th nowrap="nowrap">' . $langs->transcountrynoentities("TotalLT2", $mysoc->country_code) . ' ' . price($localtax2, "", "", "", "", 2) . '%</th><td nowrap="nowrap">' . price($object->total_localtax2, "", "", "", "", 2) . "</td></tr>"; } ?> </table> <table class="totpay"> <?php echo '<tr><td></td></tr>'; echo '<tr><td></td></tr>'; $terminal = new Cash($db); $sql = 'SELECT fk_cash, customer_pay FROM ' . MAIN_DB_PREFIX . 'pos_facture WHERE fk_facture = ' . $object->id; $resql = $db->query($sql); $obj = $db->fetch_object($resql); $customer_pay = $obj->customer_pay; $terminal->fetch($obj > fk_cash); if (!empty($conf->rewards->enabled)) { $rewards = new Rewards($db); $points = $rewards->getInvoicePoints($object->id); } if ($object->type == 0) { $pay = $object->getSommePaiement(); if (!empty($conf->rewards->enabled)) { $usepoints = abs($rewards->getInvoicePoints($object->id, 1)); $moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT); //falta fer algo per aci if ($customer_pay > $pay - $moneypoints) { $pay = $customer_pay; } else { $pay = $pay - $moneypoints; }
print '<td width="16" align="right" class="nobordernopadding">'; $filename = dol_sanitizeFileName($objp->facnumber); $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($objp->facnumber); $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $objp->facid; $formfile->show_documents('facture', $filename, $filedir, $urlsource, '', '', '', 1, '', 1); print '</td>'; print '</tr></table>'; print "</td>\n"; // Date print '<td align="center" nowrap>'; print dol_print_date($db->jdate($objp->df), 'day'); print '</td>'; //Terminal print '<td>'; $cash = new Cash($db); $cash->fetch($objp->cashid); print $cash->getNomUrl(1); print '</td>'; //User print '<td>'; if ($objp->uservalid > 0) { $userstatic = new User($db); $userstatic->fetch($objp->uservalid); print $userstatic->getNomUrl(1); } print '</td>'; //Customer print '<td>'; $thirdparty = new Societe($db); $thirdparty->id = $objp->socid; $thirdparty->nom = $objp->nom;
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } $res = @(include "../../main.inc.php"); // For root directory if (!$res) { $res = @(include "../../../main.inc.php"); } // For "custom" directory dol_include_once('/pos/class/cash.class.php'); // This destroy tag that say "Point of Sale session is on". global $db; $terminal = new Cash($db); $terminal->fetch($_SESSION['TERMINAL_ID']); $terminal->set_unused($user); unset($_SESSION['uid']); unset($_SESSION['TERMINAL_ID']); header('Location: ' . dol_buildpath('/pos/frontend/index.php', 1)); exit;
if ($id || $ref) { if (!preg_match('/,/', $id)) { $moreparam = '&month=' . $month . '&year=' . $year . ($mode == 'showalltime' ? '&mode=showalltime' : ''); if (GETPOST('option', 'string') != 'all') { $morehtml = '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&option=all' . $moreparam . '">' . $langs->trans("ShowAllTerminals") . '</a>'; print $form->showrefnav($cash, 'ref', '', 1, 'name', 'ref', '', $moreparam); } else { $morehtml = '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $id . $moreparam . '">' . $langs->trans("BackToTerminal") . '</a>'; print $langs->trans("All"); //print $morehtml; } } else { $bankaccount = new Cash($db); $listid = explode(',', $id); foreach ($listid as $key => $idb) { $bankaccount->fetch($idb); $bankaccount->name = $bankaccount->name; print $bankaccount->getNomUrl(1); if ($key < sizeof($listid) - 1) { print ', '; } } } } else { print $langs->trans("All"); } print '</td></tr>'; // Name print '<tr><td valign="top">' . $langs->trans("Name") . '</td>'; print '<td colspan="3">'; if ($id && GETPOST('option', 'string') != 'all') {
$res = @(include "../../../main.inc.php"); } // For "custom" directory dol_include_once('/pos/class/pos.class.php'); dol_include_once('/pos/class/mobile_detect.php'); require_once DOL_DOCUMENT_ROOT . "/product/stock/class/entrepot.class.php"; global $db, $langs, $conf; $langs->load("pos@pos"); $langs->load("rewards@rewards"); $langs->load("bills"); $langs->load("companies"); if (empty($_SESSION['uname']) || empty($_SESSION['TERMINAL_ID'])) { accessforbidden(); } $cash = new Cash($db); $cash->fetch($_SESSION['TERMINAL_ID']); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html style="height: 100%; overflow: hidden;" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title><?php echo $langs->trans("DolibarTPV"); ?> </title> <link rel="stylesheet" type="text/css" href="css/layout-default-latest.css"> <link rel="stylesheet" type="text/css" href="css/jquery.css"> <link rel="stylesheet" type="text/css" href="css/keyboard.css"> <link rel="stylesheet" type="text/css" href="css/jquery.ui.chatbox.css"> <link href="css/jquery-ui.css" type="text/css" rel="Stylesheet" class="ui-theme"> <script type="text/javascript" src="js/jquery-latest.js"></script>
print '</tr>'; // Type print '<tr>'; print '<td>' . $langs->trans('Type') . '</td><td colspan="5">'; print $object->getLibType(); print '</td>'; print '</tr>'; //Terminal print '<tr><td>'; print '<table class="nobordernopadding" width="100%">'; print '<tr><td>' . $langs->trans('Terminal') . '</td>'; print '</td><td colspan="5">'; print '</tr></table>'; print '</td><td colspan="5">'; $cash = new Cash($db); $cash->fetch($object->fk_cash); print $cash->getNomUrl(1); print '</td>'; print '</tr>'; //Place if ($conf->global->POS_PLACES) { print '<tr><td>'; print '<table class="nobordernopadding" width="100%">'; print '<tr><td>' . $langs->trans('Place') . '</td>'; print '</td><td colspan="5">'; print '</tr></table>'; print '</td><td colspan="5">'; $place = new Place($db); $place->fetch($object->fk_place); print $place->getNomUrl(1); print '</td>';
print '</td>'; print '<td></td>'; print '<td></td>'; print '<td></td>'; print '<td></td>'; print '<td colspan="2" class="liste_titre" align="right">'; print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">'; print ' '; print '<input type="image" class="liste_titre" name="button_removefilter" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/searchclear.png" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">'; print '</td>'; print "</tr>\n"; $var = True; while ($i < min($num, $conf->liste_limit)) { $obj = $db->fetch_object($resql); $cashwil = new Cash($db); $cashwil->fetch($obj->rowid); $var = !$var; print "<tr {$bc[$var]}>"; print '<td width="30%">' . $cashwil->getNomUrl(1) . '</td>'; print "<td>" . $cashwil->tactiltype($obj->tactil) . "</td>\n"; print '<td align="left">' . $cashwil->getLibStatut(4) . '</td>'; $url = 'cash.php?id=' . $obj->rowid; if (!$cashwil->is_closed) { if ($cashwil->fk_user_u) { $userstatic = new User($db); $userstatic->fetch($cashwil->fk_user_u); if ($user->rights->pos->backend) { print "<td>" . $userstatic->getNomUrl(1) . "</td>\n"; print '<td align="center">'; print '<form action="' . $url . '" name="free" method="POST">'; print '<input type="hidden" name="id" value="' . $cashwil->id . '">';
} if ($sortfield == 'amount_ttc' && $sortorder == 'asc') { asort($amount); $arrayforsort = $amount; } if ($sortfield == 'amount_ttc' && $sortorder == 'desc') { arsort($amount); $arrayforsort = $amount; } foreach ($arrayforsort as $key => $value) { $var = !$var; print "<tr " . $bc[$var] . ">"; // Place //$fullname=$name[$key]; $cash = new Cash($db); $cash->fetch($key); /*if ($key > 0) { $linkname='<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$key.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$fullname.'</a>'; }*/ print "<td>" . $cash->getNomUrl(1) . "</td>\n"; // Amount print '<td align="right">'; $url = dol_buildpath('/pos/backend/liste.php?cashid=' . $key, 1); if ($key > 0) { print '<a href="' . $url . '">'; } else { print '<a href="#">'; } print price($amount[$key]); print '</a>'; print '</td>';
} //$result=restrictedArea($user,'banque',$id,'bank_account','','',$fieldid); $year_start = GETPOST('year_start'); $year_current = strftime("%Y", time()); if (!$year_start) { $year_start = $year_current - 2; $year_end = $year_current; } else { $year_end = $year_start + 2; } $helpurl = 'EN:Module_DoliPos|FR:Module_DoliPos_FR|ES:Módulo_DoliPos'; llxHeader('', '', $helpurl); $form = new Form($db); // Get account informations $acct = new Cash($db); $result = $acct->fetch($id, $ref); # Ce rapport de tresorerie est base sur llx_bank (car doit inclure les transactions sans facture) # plutot que sur llx_paiement + llx_paiementfourn $sql = "SELECT SUM(total_ttc) as amount"; $sql .= ", date_format(date_creation,'%Y-%m') as dm"; $sql .= " FROM " . MAIN_DB_PREFIX . "pos_ticket"; //$sql.= " WHERE fk_cash = ".$id; $sql .= " WHERE entity = " . $conf->entity; $sql .= " AND fk_statut in (1,2,3,4)"; //$sql.= " AND (type = 0)"; //$sql.= " AND total_ht >= 0"; if ($acct->id) { $sql .= " AND fk_cash IN (" . $acct->id . ")"; } $sql .= " GROUP BY dm"; $sql .= " UNION SELECT sum(fac.total_ttc) as amount, date_format(fac.datec,'%Y-%m') as dm";
/** Return next value * @param objsoc Object third party * @param ticket Object ticket * @param mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ function getNextValue($objsoc, $facsim, $mode = 'next') { global $db, $conf; require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php"; // Get Mask value $mask = ''; if (is_object($facsim) && $facsim->type == 2) { $mask = $conf->global->FACSIM_MURO_MASK_CREDIT; } else { $mask = $conf->global->FACSIM_MURO_MASK; } if (!$mask) { $this->error = 'NotConfigured'; return 0; } $where = ''; //ww para warehouse if (preg_match('/\\{(w+)\\}/i', $mask, $regWare)) { dol_include_once("/pos/class/cash.class.php"); require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; $terminal = new Cash($db); $terminal->fetch($facsim->fk_cash); $warehouse = new Entrepot($db); $warehouse->fetch($terminal->fk_warehouse); $maskware = $regWare[1]; $maskware_value = substr($warehouse->libelle, 0, dol_strlen($regWare[1])); //get n first characters of warehouse ref where n is length in mask $maskware_value = str_pad($maskware_value, dol_strlen($regWare[1]), "#", STR_PAD_RIGHT); $maskware_maskbefore = '{' . $maskware . '}'; $maskware_maskafter = $maskware_value; $mask = str_replace($maskware_maskbefore, $maskware_maskafter, $mask); } //kk para terminal if (preg_match('/\\{(k+)\\}/i', $mask, $regTerm)) { dol_include_once("/pos/class/cash.class.php"); $terminal = new Cash($db); $terminal->fetch($facsim->fk_cash); $maskterm = $regTerm[1]; $maskterm_value = substr($terminal->ref, 0, dol_strlen($regTerm[1])); //get n first characters of warehouse ref where n is length in mask $maskterm_value = str_pad($maskterm_value, dol_strlen($regTerm[1]), "#", STR_PAD_RIGHT); $maskterm_maskbefore = '{' . $maskterm . '}'; $maskterm_maskafter = $maskterm_value; $mask = str_replace($maskterm_maskbefore, $maskterm_maskafter, $mask); } $numFinal = get_next_value($db, $mask, 'facture', 'facnumber', $where, $objsoc, time(), $mode); if (!preg_match('/([0-9])+/', $numFinal)) { $this->error = $numFinal; } return $numFinal; }
/** * * Return the money in cash * * @param bool $open money for open or not * @return double Amount of cash since last closed */ function getMoneyCash($open = false) { global $db, $conf, $langs; $cash = new Cash($db); $cash->fetch($this->terminal); $acount = $cash->fk_paycash; $sql = "SELECT sum( b.amount ) as amount"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account AS ba, " . MAIN_DB_PREFIX . "bank AS b"; $sql .= " WHERE b.fk_account =" . $acount; $sql .= " AND b.fk_account = ba.rowid"; $sql .= " AND ba.entity =" . $conf->entity; $sql .= " ORDER BY b.datev ASC , b.datec ASC "; $result = $db->query($sql); if ($result) { if ($db->num_rows($result)) { $obj = $db->fetch_object($result); $amount = $obj->amount; } } if (!$amount) { $amount = 0; } return $amount; }