За последние 24 часа нас посетили 34953 программиста и 1737 роботов. Сейчас ищут 756 программистов ...

smarty

Тема в разделе "PHP для новичков", создана пользователем wolf777, 21 май 2015.

  1. wolf777

    wolf777 Новичок

    С нами с:
    26 авг 2014
    Сообщения:
    207
    Симпатии:
    0
    ребят кто знает smarty подскажите как правильно переписать код?

    Код (PHP):
    1. $id = $invoiceid = (int)$whmcs->get_req_var("id");
    2. $breadcrumbnav = "<a href=\"index.php\">" . $whmcs->get_lang("globalsystemname") . "</a> 
    3. > <a href=\"clientarea.php\">" . $whmcs->get_lang("clientareatitle") . "</a> 
    4. > <a href=\"clientarea.php?action=invoices\">" . $_LANG['invoices'] . "</a> 
    5. > <a href=\"viewinvoice.php?id=" . $invoiceid . "\">" . $pagetitle . "</a>";
    6.  
    7. initialiseClientArea($whmcs->get_lang("invoicestitle") . $invoiceid, "", $breadcrumbnav);
    8.  
    9. if (!isset($_SESSION['uid']) && !isset($_SESSION['adminid'])) {
    10.     $goto = "viewinvoice";
    11.     require "login.php";
    12.     exit();
    13. }
    14.  
    15. $invoice = new WHMCS_Invoice();
    16. $invoice->setID($invoiceid);
    17. $invoiceexists = $invoice->loadData();
    18. $allowedaccess = (isset($_SESSION['adminid']) ? true : $invoice->isAllowed());
    19.  
    20. if (!$invoiceexists || !$allowedaccess) {
    21.     $smarty->assign("error", "on");
    22.     $template_output = $smarty->fetch($whmcs->get_sys_tpl_name() . "/viewinvoice.tpl");
    23.     echo $template_output;
    24.     exit();
    25. }
    26.  
    27.  
    28. if ((($invoice->getData("status") == "Paid" && isset($_SESSION['orderdetails'])) && $_SESSION['orderdetails']['InvoiceID'] == $invoiceid) && !$_SESSION['orderdetails']['paymentcomplete']) {
    29.     $_SESSION['orderdetails']['paymentcomplete'] = true;
    30.     redir("a=complete", "cart.php");
    31. }
    32.  
    33. $gateway = $whmcs->get_req_var("gateway");
    34.  
    35. if ($gateway) {
    36.     check_token();
    37.     $gateways = new WHMCS_Gateways();
    38.     $validgateways = $gateways->getAvailableGateways($invoiceid);
    39.  
    40.     if (array_key_exists($gateway, $validgateways)) {
    41.         update_query("tblinvoices", array("paymentmethod" => $gateway), array("id" => $invoiceid));
    42.         run_hook("InvoiceChangeGateway", array("invoiceid" => $invoiceid, "paymentmethod" => $gateway));
    43.     }
    44.  
    45.     redir($invoiceid);
    46. }
    47.  
    48. $creditbal = get_query_val("tblclients", "credit", array("id" => $invoice->getData("userid")));
    49.  
    50. if ($invoice->getData("status") == "Unpaid" && 0 < $creditbal) {
    51.     $balance = $invoice->getData("balance");
    52.     $creditamount = $whmcs->get_req_var("creditamount");
    53.  
    54.     if ($whmcs->get_req_var("applycredit") && 0 < $creditamount) {
    55.         check_token();
    56.  
    57.         if ($creditbal < $creditamount) {
    58.             echo $_LANG['invoiceaddcreditovercredit'];
    59.             exit();
    60.         }
    61.         else {
    62.             if ($balance < $creditamount) {
    63.                 echo $_LANG['invoiceaddcreditoverbalance'];
    64.                 exit();
    65.             }
    66.             else {
    67.                 applyCredit($invoiceid, $invoice->getData("userid"), $creditamount);
    68.             }
    69.         }
    70.  
    71.         redir("id=" . $invoiceid);
    72.     }
    73.  
    74.     $smartyvalues['manualapplycredit'] = true;
    75.     $smartyvalues['totalcredit'] = formatCurrency($creditbal) . generate_token("form");
    76.  
    77.     if (!$creditamount) {
    78.         $creditamount = ($balance <= $creditbal $balance : $creditbal);
    79.     }
    80.  
    81.     $smartyvalues['creditamount'] = $creditamount;
    82. }
    83.  
    84. $outputvars = $invoice->getOutput();
    85. $smartyvalues = array_merge($smartyvalues, $outputvars);
    86. $invoiceitems = $invoice->getLineItems();
    87. $smartyvalues['invoiceitems'] = $invoiceitems;
    88. $transactions = $invoice->getTransactions();
    89. $smartyvalues['transactions'] = $transactions;
    90. $paymentbutton = (($invoice->getData("status") == "Unpaid" && 0 < $invoice->getData("balance")) ? $invoice->getPaymentLink() : "");
    91. $smartyvalues['paymentbutton'] = $paymentbutton;
    92. $smartyvalues['offlinepaid'] = $whmcs->get_req_var("offlinepaid");
    93.  
    94. if ($whmcs->get_config("AllowCustomerChangeInvoiceGateway")) {
    95.     $smartyvalues['allowchangegateway'] = true;
    96.     $gateways = new WHMCS_Gateways();
    97.     $availablegateways = $gateways->getAvailableGateways($invoiceid);
    98.     $frm = new WHMCS_Form();
    99.     $gatewaydropdown = generate_token("form") . $frm->dropdown("gateway", $availablegateways, $invoice->getData("paymentmodule"), "submit()");
    100.     $smartyvalues['gatewaydropdown'] = $gatewaydropdown;
    101. }
    102. else {
    103.     $smartyvalues['allowchangegateway'] = false;
    104. }
    105.  
    106. outputClientArea("viewinvoice");
    чтоб было наподобие этого

    Код (PHP):
    1. if ($action == "emails") {
    2.   $ca->addToBreadCrumb("clientarea.php?action=emails", $whmcs->get_lang("clientareaemails"));
    3. }
    4.  
    5. ________________
    6.  if ($action == "emails") {
    7.                         checkContactPermission("emails");
    8.                         $ca->setTemplate("clientareaemails");
    9.                         $result = select_query("tblemails", "COUNT(*)", array("userid" => $client->getID()), "id", "DESC");
    10.                         $data = mysql_fetch_array($result);
    11.                         $numitems = $data[0];
    12.                         list($orderby, $sort, $limit) = clientAreaTableInit("emails", "date", "DESC", $numitems);
    13.                         $smartyvalues['orderby'] = $orderby;
    14.                         $smartyvalues['sort'] = strtolower($sort);
    15.  
    16.                         if ($orderby == "subject") {
    17.                           $orderby = "subject";
    18.                         } else {
    19.                           $orderby = "date";
    20.                         }
    21.  
    22.                         $emails = array();
    23.                         $result = select_query("tblemails", "", array("userid" => $client->getID()), $orderby, $sort, $limit);
    24.  
    25.                         while ($data = mysql_fetch_array($result)) {
    26.                           $id = $data['id'];
    27.                           $date = $data['date'];
    28.                           $subject = $data['subject'];
    29.                           $date = fromMySQLDate($date, 1, 1);
    30.                           $emails[] = array("id" => $id, "date" => $date, "subject" => $subject);
    31.                         }
    32.  
    33.                         $ca->assign("emails", $emails);
    34.                         $smartyvalues = array_merge($smartyvalues, clientAreaTablePageNav($numitems));
    35.                       }
    а то что то нифига не получается((( вот например код
    Код (Text):
    1.  if ($action == "emails") {
    вызывается по адресу http://site.ru/clientarea.php?action=emails

    хочется как то первый код переписать чтоб вызывалось так http://site.ru/clientarea.php?action=viewinvoice=?id=38

    помогите его переписать ребят пожалуйста, а то нифига не получается сколько не пытался разобраться в этом smarty(((((((((((((((((((
     
  2. runcore

    runcore Старожил

    С нами с:
    12 окт 2012
    Сообщения:
    3.625
    Симпатии:
    158
    за тебя писать все это никто не будет, думаю. ибо кода приведено много и переписывать все это под смарти, тем более когда не совсем понятно в чем проблема - лениво.
    начни делать сам. и если не получается - задавай конкретные небольшие вопросы.
    на них тебе тут точно ответят.