Ejemplo n.º 1
0
    public function showCreateForm()
    {
        $nextno = $this->getNextNo();
        global $bpctrl, $userid, $havewriteperm, $spquotation_prefix;
        $currencyoption = $bpctrl->getSelectCurrency(0, "N");
        $date = date("Y-m-d", time());
        $title = 'Sales Quotation';
        $this->defineHeaderButton();
        include "../simantz/class/FormElement.php";
        include "../bpartner/class/BPartnerFormElement.inc.php";
        $fe = new FormElement();
        $sbfe = new BPartnerFormElement();
        $sbfe->activateAutoComplete();
        $bpbox = $sbfe->getBPartnerBox(0, '', 'bpartner_id', 'bpartner_id', '350px', 'onchange="chooseBPartner()"');
        //        $agentbox = $sbfe->getAgentBox(0, '', 'saleagent_id', 'saleagent_id', '150px');
        $uidoption = $bpctrl->getSelectUsers($userid);
        if ($havewriteperm == 1) {
            $savebutton = "<input  id='nextbutton' name='submit' onclick='return saveform()' type='submit' value='Create'/>\n<input type='hidden' name='action' value='create'>";
        } else {
            $savebutton = "";
        }
        echo <<<EOF
<script>



\$(function() {
\t});

\t    function zoomBPartner(){
\t\t\tvar bpartner_id=document.getElementById("bpartner_id").value;
          if(bpartner_id>0)
           window.open("../bpartner/bpartner.php?action=viewsummary&bpartner_id="+bpartner_id,"_blank");
          else
          alert("You need to choose business partner!");
          }
       function chooseBPartner(){
              var bpid=document.getElementById("bpartner_id").value;
                   var data="action="+"getbpartnerinfo"+
                            "&bpartner_id="+bpid;

                    \$.ajax({
                         url:"{$this->quotationfilename}",type: "POST",data: data,cache: false,
                             success: function (xml)
                             {
                               var address=\$(xml).find("address").text().replace(/{{{/g,"<").replace(/}}}/g,">");
                                var terms=\$(xml).find("terms").text().replace(/{{{/g,"<").replace(/}}}/g,">");
                                 var contact=\$(xml).find("contact").text().replace(/{{{/g,"<").replace(/}}}/g,">");
                                 var currency=\$(xml).find("currency").text().replace(/{{{/g,"<").replace(/}}}/g,">");
                               var bpartneraccounts_id=\$(xml).find("bpartneraccounts_id").text();
\t\t\t\t\t\t\t\t
                              
                                \$("#address_id").html(address);
                                \$("#contacts_id").html(contact);
                                \$("#terms_id").html(terms);
                                \$("#currency_id").html(currency);
                                //document.getElementById("salesagentname").value=salesagent;
 //                               document.getElementById("bpartneraccounts_id").value=bpartneraccounts_id;
//                                comparecurrency();
                                
\t\t\t\t\t\t\t\t\tif(document.getElementById('address_text'))
\t\t\t\t\t\t\t\t\t\tupdateAddressText();
\t\t\t\t\t\t\t\t
\t\t\t\t\t\t\t\t
\t\t\t\t\t\t\t\tvar limitamt=parseFloat(\$(xml).find("limitamt").text());
                                var usage=parseFloat(\$(xml).find("usage").text());
                                var control=\$(xml).find("control").text();

\t\t\t\t\t\t\t\tvar iscontrol="";
\t\t\t\t\t\t\t\tif(control=='1')
\t\t\t\t\t\t\t\t\t\t\tiscontrol="Y";
\t\t\t\t\t\t\t\t\telse
\t\t\t\t\t\t\t\t\t\tiscontrol="N";
\t\t\t\t\t\t\t\t\$("#divlimit").html("Credit Limit:"+limitamt+",Current Usage:"+usage+":Control Limit:"+iscontrol);
\t\t\t\t\t\t\t\t
\t\t\t\t\t\t\t\tif(iscontrol=='Y' && usage>limitamt){
\t\t\t\t\t\t\t\t\talert("Warning! Current usage is bigger than credit limit!");
\t\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t}
                           });



        }
                 
     function saveform(){
\t\t if(confirm("Confirm create {$title}?")){
\t\t\t 
\t\t\tif(\$("#bpartner_id").val()==0){
\t\t\t\t\t\$("#bpartner_id_text").addClass("red");
\t\t\t\talert("Please choose appropriate business partner!");
\t\t\t\treturn false;
\t\t\t\t}
\t\t\telse
\t\t\t\t\$("#bpartner_id_text").removeClass("red");
\t\t\t\t\t
\t\t\t\t
\t\t\t\$("#frmQuotation").submit();
\t\t\treturn true;
\t\t\t
\t\t}
\t\t else
\t\t\treturn false;
\t\t }
\t\t 
     
</script>
<div align=center>
  <table style="width:990px;text-align: left; " >
        <tr><td align="left">{$this->addnewctrl}</td><td align="right">{$this->searchctrl}</td></tr>
  </table>
<form method='post' name='frmQuotation' id='frmQuotation'  action='{$this->quotationfilename}'  enctype="multipart/form-data">
   <table style="text-align: left; width: 990px;" border="0" cellpadding="0" cellspacing="1"  class="searchformblock">
    <tbody>

      <tr>
        <td colspan="4" rowspan="1" align="center" id="idHeaderText" class="searchformheader" >New {$title}</td>
      </tr>

      <tr>
        <td class="head">Date (YYYY-MM-DD)</td>
        <td class="even">
            <input id='document_date' name='document_date'  size='12'  value='{$date}' class='datepick'>
            </td>
        <td class="head">Document No</td>
        <td class="even">
\t\t\t\t\t<input name='spquotation_prefix' id='spquotation_prefix' value='{$spquotation_prefix}'size='4'>
                         <input name='document_no' id='document_no'  value='<<NEW>>' size='12'> Next No: {$nextno}
                         </td>
      </tr>
      <tr> 
        <td class="head">Business Partner</td>
\t\t\t<td class="even">{$bpbox}<img style="cursor:pointer" onclick=zoomBPartner() src="../simantz/images/zoom.png">
\t\t\t<input name='bpartneraccounts_id' id='bpartneraccounts_id' type='hidden' value=0><div id='divlimit'></div></td>
        <td class="head">Ref. No</td>
        <td class="even"><input id='ref_no' size='20' name='ref_no' value='{$this->ref_no}'></td>
      </tr>
      <tr>
        <td class="head">Billing Address</td>
\t\t\t<td class="even"><Select id='address_id' name='address_id'><option value=0>Null</option></Select></td>
        <td class="head">Terms</td>
        <td class="even"> <select id='terms_id' name='terms_id'><option value=0>Null</option></select></td>
      </tr>
      <tr>
        <td class="head">Currency</td>
        <td class="even"> <select id='currency_id' name='currency_id'><option value=0>Null</option></select></td>
        <td class="head">Attn To</td>
        <td class="even"> <select id='contacts_id' name='contacts_id'><option value=0>Null</option></select></td>
      </tr>
      <tr>
         <td class="head">Prepared By</td>
         <td class="even"><select id='preparedbyuid' name='preparedbyuid'>{$uidoption}</select></td>
        <td class="head">Sales Agent</td>
        <td class="even"><input name='salesagentname' id='salesagentname' value=''></td>
      </tr>
      
</table>
{$savebutton}
</form>
</div>
EOF;
    }
Ejemplo n.º 2
0
     } else {
         $msg = "<a class='statusmsg'>Failed to delete Record. Please try again.</a>";
         $arr = array("msg" => $msg, "status" => 2);
         echo json_encode($arr);
     }
     break;
 case "edit":
     if ($o->fetchQuotation($_REQUEST['quotation_id'])) {
         if ($o->iscomplete == 1 || $o->iscomplete == -1) {
             redirect_header("{$o->quotationfilename}?action=view&quotation_id={$o->quotation_id}", "2", "This transaction is readonly, redirect to view mode.");
         } else {
             include "menu.php";
             include "../simantz/class/FormElement.php";
             include "../bpartner/class/BPartnerFormElement.inc.php";
             $fe = new FormElement();
             $sbfe = new BPartnerFormElement();
             $sbfe->activateAutoComplete();
             $xoTheme->addStylesheet("{$url}/modules/simantz/include/jqueryui/themes/base/jquery.ui.all.css");
             $xoTheme->addScript("{$url}/modules/simantz/include/jqueryui/ui/jquery.ui.core.js");
             $xoTheme->addScript("{$url}/modules/simantz/include/jqueryui/ui/jquery.ui.widget.js");
             $xoTheme->addScript("{$url}/modules/simantz/include/jqueryui/ui/jquery.ui.button.js");
             $xoTheme->addScript("{$url}/modules/simantz/include/jqueryui/ui/jquery.ui.datepicker.js");
             $xoTheme->addScript("{$url}/modules/simantz/include/jqueryui/ui/jquery.ui.autocomplete.js");
             $xoTheme->addScript("{$url}/modules/simantz/include/jqueryui/ui/jquery.ui.position.js");
             $xoTheme->addStylesheet("{$url}/modules/simantz/include/jqueryui/demos.css");
             $xoTheme->addStylesheet("{$url}/modules/simantz/include/jqueryui/themes/ui-lightness/jquery.ui.datepicker.css");
             $xoTheme->addStylesheet("{$url}/modules/simantz/include/jqueryui/themes/ui-lightness/jquery.ui.autocomplete.css");
             $xoTheme->addScript("{$url}/modules/simantz/include/validatetext.js");
             $xoTheme->addScript("{$url}/modules/simantz/include/jqjs.js");
             $xoTheme->addScript("{$url}/modules/simantz/include/popup.js");
             $xoTheme->addScript("{$url}/modules/simantz/include/popup.css");