<?php

/* VGMWOBundle:Invoicing:index.html.twig */
class __TwigTemplate_42a92f8ece655c06b282cb7b3c996297a2cabbade7357b45169efdd45cfba678 extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        // line 1
        $this->parent = $this->loadTemplate("VGMWOBundle::layout.html.twig", "VGMWOBundle:Invoicing:index.html.twig", 1);
        $this->blocks = array(
            'stylesheets' => array($this, 'block_stylesheets'),
            'content' => array($this, 'block_content'),
            'advanced_search_panel' => array($this, 'block_advanced_search_panel'),
            'javascripts' => array($this, 'block_javascripts'),
        );
    }

    protected function doGetParent(array $context)
    {
        return "VGMWOBundle::layout.html.twig";
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        $this->parent->display($context, array_merge($this->blocks, $blocks));
    }

    // line 2
    public function block_stylesheets($context, array $blocks = array())
    {
        // line 3
        echo "    ";
        $this->displayParentBlock("stylesheets", $context, $blocks);
        echo "
    <link href=\"";
        // line 4
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/css/bootstrap-datetimepicker.css"), "html", null, true);
        echo "\" rel=\"stylesheet\" media=\"screen\">
    <link href=\"";
        // line 5
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/css/waitMe.css"), "html", null, true);
        echo "\" rel=\"stylesheet\" media=\"screen\">
    <link href=\"https://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css\" rel=\"stylesheet\" media=\"screen\">
    <link href=\"https://cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css\" rel=\"stylesheet\" media=\"screen\">
    <style>.dataTables_wrapper .ui-toolbar {padding: 0px !important;}.dataTables_filter {display: none;}div.DTTT_container {margin-left: 1em;}#workorders-list>tbody>tr{cursor: pointer;}
        table.dataTable thead th, table.dataTable thead td {padding: 5px;}table.dataTable tbody th, table.dataTable tbody td {padding: 5px;}
        table.dataTable thead .sorting {
            background-image: none;
        }
        table.dataTable thead .sorting_desc, table.dataTable thead .sorting_desc_disabled {
            background-image: url(\"";
        // line 14
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/images/sort_desc.png"), "html", null, true);
        echo "\");
            background-position: center bottom;
        }
        table.dataTable thead .sorting_asc, table.dataTable thead .sorting_asc_disabled {
            background-image: url(\"";
        // line 18
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/images/sort_asc.png"), "html", null, true);
        echo "\");
            background-position: center bottom;
        }
    </style>
";
    }

    // line 23
    public function block_content($context, array $blocks = array())
    {
        // line 24
        echo "    <div id=\"invoices_list\" class=\"container\">
        <div id=\"header-area\">
            <strong style=\"font-size: 3vmin;\">Invoices</strong>";
        // line 29
        echo "            <div class=\"form-inline pull-right\">
                <div class=\"form-group\" id=\"table-buttons-div\" style=\"padding: 0vw 0.5vw;\"></div>
                <div class=\"form-group\">
                    <label class=\"sr-only\" for=\"datatable-searchbox\">Search</label>
                    <input id=\"datatable-searchbox\" class=\"form-control\" placeholder=\"Search\"/>
                </div>
                <div class=\"vertical-divider\"></div>
                <div class=\"form-group\">
                    <a href=\"#\" data-toggle=\"modal\" data-target=\"#advanced-serach-panel\" style=\"display: inline-block\">Advanced Search</a>
                </div>
            </div>
        </div>
        <div id=\"advanced-search-area\" class=\"text-right\">
            <div class=\"form-inline\" style=\"display: inline-block;\">
                <div class=\"form-group\">
                    <label for=\"invoice-purpose-selection\" style=\"height: 100%; vertical-align: bottom; margin-bottom: 0px;\">Invoice purpose:</label>
                    <select id=\"invoice-purpose-selection\" class=\"form-control\"
                            data-bind=\"options: invoice_destinations,optionsText: 'name',value: chosen_dest\"></select>
                </div>
                <div class=\"vertical-divider\"></div>
                <div class=\"form-group\">
                    <label for=\"invoice-status-selection\"  style=\"height: 100%; vertical-align: bottom; margin-bottom: 0px;\">Invoice status:</label>
                    <select id=\"invoice-status-selection\" class=\"form-control\">
                        <option value=\"0\" selected>All</option>
                        <option value=\"1\">F</option>
                        <option value=\"2\">PF</option>
                        <option value=\"3\">S</option>
                    </select>
                </div>
            </div>
        </div>
        <secction id=\"list-area\" class=\"table-responsive row\" style=\"padding-left: 0px; padding-right: 0px;\">
            <table class=\"table table-hover fixed-header display table-int-grid\" cellspacing=\"0\" id=\"invoices-list\">
                <thead>
                <tr style=\"background-color: #fff;\">
                    <th class=\"col-xs-05\">Created</th>
                    <th class=\"col-xs-05\">Purpose</th>
                    <th>Status</th>
                    <th class=\"col-xs-2 col-sm-\">Client</th>
                    <th class=\"col-xs-3 col-sm-3\">Equipment</th>
                    <th class=\"col-xs-2 col-sm-1\">WO-Stock</th>
                    <th class=\"col-xs-1 col-sm-1\" style=\"white-space: nowrap;\">Stock</th>
                    <th class=\"col-xs-1 col-sm-1\" style=\"white-space: nowrap;\">To invoice</th>
                    <th class=\"col-xs-1  col-sm-1\">Invoiced</th>
                    <th class=\"col-xs-1 col-sm-1\" style=\"white-space: nowrap;\">Inv. date</th>
                    <th class=\"col-xs-1 col-sm-1\">Invoice</th>
                </tr>
                </thead></table>
            <div id=\"total-area\" class=\"pull-right col-xs-3 col-sm-3\">
                <table class=\"table table-responsive totals\">
                    <tbody>
                        <tr>
                            <td style=\"border-top: none; border-bottom: 1px solid #ddd; font-size: 17px;\"><strong>Stock:</strong></td>
                            <td class=\"text-right\" style=\"border-top: none; border-bottom: 1px solid #ddd; font-size: 17px;\">
                                ";
        // line 84
        echo "                                <strong id=\"total-to-stock-value\"></strong>
                                <strong>x K</strong>
                            </td>
                        </tr>
                        <tr>
                            <td style=\"border-top: none; border-bottom: 1px solid #ddd; font-size: 17px;\"><strong>To invoice:</strong></td>
                            <td class=\"text-right\" style=\"border-top: none; border-bottom: 1px solid #ddd; font-size: 17px;\">
                                ";
        // line 92
        echo "                                <strong id=\"total-to-invoice-value\"></strong>
                                <strong>x K</strong>
                            </td>
                        </tr>
                        <tr>
                            <td style=\"border-top: none; border-bottom: 1px solid #ddd; font-size: 17px;\"><strong>Invoiced:</strong></td>
                            <td class=\"text-right\" style=\"border-top: none; border-bottom: 1px solid #ddd; font-size: 17px;\">
                                ";
        // line 100
        echo "                                <strong id=\"total-invoiced-value\"></strong>
                                <strong>x K</strong>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </secction>
    </div>
    ";
        // line 109
        $this->displayBlock('advanced_search_panel', $context, $blocks);
    }

    public function block_advanced_search_panel($context, array $blocks = array())
    {
        $this->loadTemplate("VGMWOBundle:Invoicing/Modal_panels:advance_search.html.twig", "VGMWOBundle:Invoicing:index.html.twig", 109)->display($context);
    }

    // line 111
    public function block_javascripts($context, array $blocks = array())
    {
        // line 112
        echo "    ";
        $this->displayParentBlock("javascripts", $context, $blocks);
        echo "
    <script type=\"text/javascript\" src=\"";
        // line 113
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/js/bootstrap-datetimepicker.js"), "html", null, true);
        echo "\"></script>
    <script type=\"text/javascript\" src=\"";
        // line 114
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/js/jquery/jquery.inputmask.js"), "html", null, true);
        echo "\"></script>
    <script type=\"text/javascript\" src=\"";
        // line 115
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/js/jquery/jquery.dataTables.min.js"), "html", null, true);
        echo "\"></script>
    <script type=\"text/javascript\" src=\"";
        // line 116
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/js/customized/Invoices/invoices.lists.js"), "html", null, true);
        echo "\"></script>
    <script type=\"text/javascript\" src=\"https://cdn.datatables.net/buttons/1.0.3/js/dataTables.buttons.min.js\"></script>
    <script type=\"text/javascript\" src=\"https://cdn.datatables.net/buttons/1.0.3/js/buttons.print.min.js\"></script>
    <script type=\"text/javascript\">
        function get_invoices_list_url(){return '";
        // line 120
        echo $this->env->getExtension('routing')->getPath("get_invoices_list");
        echo "';};
        function convertImgToBase64(url, callback, outputFormat){
            var img = new Image();
            img.crossOrigin = 'Anonymous';
            img.onload = function(){
                var canvas = document.createElement('CANVAS');
                var ctx = canvas.getContext('2d');
                canvas.height = this.height;
                canvas.width = this.width;
                ctx.drawImage(this,0,0);
                var dataURL = canvas.toDataURL(outputFormat || 'image/png');
                callback(dataURL);
                canvas = null;
            };
            img.src = url;
        };
        var calcDataTableHeight = 0;
        var total_to_stock = 0;
        var total_to_invoice = 0;
        var total_invoiced = 0;
        var dt_config = {\"processing\": true,\"loading\": false,\"scrollCollapse\": true,
            \"paging\": false,
            \"scrollY\": function(){return (\$(window).height() - \$(\"nav.navbar-inverse.menu-bar\").height()) -  120;},
            \"responsive\": true,\"dom\": 'Bfrtip',
            \"buttons\": [{extend:'print',text:\"Print PreView\",autoPrint:false,exportOptions:{columns:':visible'},
                customize:function(win){
                    \$(win.document.body).css('font-size','10pt').css('height','95vh').css('margin','0px 10px');
                    \$(win.document.body).find('h1').text(\"Aeroservicios - Invoicing\");
                    \$(win.document.body).find('table').addClass('compact').css('font-size','inherit');
                    var to_add = \$('#total-area').wrap('<p/>').parent().html();
                    \$('#total-area').unwrap();
                    \$(win.document.body).append(to_add);
                }},
                {extend:'print',text:\"Print\",exportOptions:{columns:':visible'},key:{key:80,ctrlKey: true},
                    customize:function(win){
                        \$(win.document.body).css('font-size','10pt').css('height','95vh').css('margin','0px 10px');
                        \$(win.document.body).find('h1').text(\"Aeroservicios - Invoicing\");
                        \$(win.document.body).find( 'table' ).addClass( 'compact' ).css( 'font-size', 'inherit' );
                        var to_add = \$('#total-area').wrap('<p/>').parent().html();
                        \$('#total-area').unwrap();
                        \$(win.document.body).append(to_add);
                    }},
                {text: \"Excel\",key:{key:'e',ctrlKey: true},action: function(){
                    \$.ajax({type:'post',async:true,dataType:'json',url: '";
        // line 163
        echo $this->env->getExtension('routing')->getPath("export_invl2excel");
        echo "',
                        data:ajax_parameters(),
                        success: function(response){window.location.assign(response.url);},
                        error:function() {alert(\"Error\");}});}}],
            \"aaSorting\": [[8,'desc']],
            \"info\": true,
            \"ajax\":{
                url: get_invoices_list_url(),
                type: \"POST\",
                data: ajax_parameters()},
            \"aoColumns\": [{\"sType\" : \"usdate\", \"bSortable\": true, \"visible\": true},
                {\"sType\" : \"text\", \"bSortable\": true, \"visible\": true},
                {\"sType\" : \"text\", \"bSortable\": true, \"visible\": true},
                {\"sType\" : \"text\", \"bSortable\": true, \"visible\": true},
                {\"type\" : \"text\", \"bSortable\": true, \"visible\": true},
                {\"type\" : \"ot-number\", \"bSortable\": true, \"visible\": true, \"searchable\": false},
                {\"type\" : \"us-money\", \"bSortable\": true, \"visible\": true},
                {\"type\" : \"us-money\", \"bSortable\": true, \"visible\": true},
                {\"type\" : \"us-money\", \"bSortable\": true, \"visible\": true, \"searchable\": false},
                {\"sType\" : \"usdate\", \"bSortable\": true, \"visible\": true},
                {\"sType\" : \"text\", \"bSortable\": true, \"visible\": true}],
             \"rowCallback\": function(nRow,aData,iDisplayIndex,iDisplayIndexFull){
                 if(iDisplayIndex == 0){total_to_stock = 0;total_to_invoice = 0;total_invoiced = 0;}
                 total_to_stock += aData[6] != null && aData[6] != \"\" ? (parseFloat(aData[6].replace(',',''))) : 0;
                 total_to_invoice += aData[6] != null && aData[7] != \"\" ? (parseFloat(aData[7].replace(',',''))) : 0;
                 total_invoiced += aData[7] != null && aData[8] != \"\" ? (parseFloat(aData[8].replace(',',''))) : 0;
             },
            \"drawCallback\": function(){
                \$('#total-to-stock-value').text(parseFloat(total_to_stock).format(3,3,',','.'));
                \$('#total-to-invoice-value').text(parseFloat(total_to_invoice).format(3,3,',','.'));
                \$('#total-invoiced-value').text(parseFloat(total_invoiced).format(3,3,',','.'));}
        };
        \$(document).ready(function(){
            loadPageFeatures();
            clear_ajax_parameters();
            jQuery.extend(jQuery.fn.dataTableExt.oSort,{\"usdate-pre\":function(a){if(a==null||a==\"\"){return 0;}
                var usDatea=a.replace(' ','').split('/');return (usDatea[2]+usDatea[0]+usDatea[1]) * 1;},
                \"usdate-asc\":function(a,b){return ((a<b)?-1:((a>b)?1:0));},
                \"usdate-desc\":function(a,b){return ((a<b)?1:((a>b)?-1:0));},
                \"ot-number-asc\":function(a,b){
                    a = a.replace(' ','').split('-');
                    a = (a.length > 1 ? (a[1].length == 1? parseFloat(a[0] + \".0\" + a[1]) : parseFloat(a[0] + \".\" + a[1])) : parseFloat(a[0]));
                    b = b.replace(' ','').split('-');
                    b = (b.length > 1 ? (b[1].length == 1? parseFloat(b[0] + \".0\" + b[1]) : parseFloat(b[0] + \".\" + b[1])) : parseFloat(b[0]));
                    return ((a<b)?-1:((a>b)?1:0));
                },
                \"ot-number-desc\":function(a,b){
                    a = a.replace(' ','').split('-');
                    a = (a.length > 1 ? (a[1].length == 1? parseFloat(a[0] + \".0\" + a[1]) : parseFloat(a[0] + \".\" + a[1])) : parseFloat(a[0]));
                    b = b.replace(' ','').split('-');
                    b = (b.length > 1 ? (b[1].length == 1? parseFloat(b[0] + \".0\" + b[1]) : parseFloat(b[0] + \".\" + b[1])) : parseFloat(b[0]));
                    return (parseInt(a) == parseInt(b) ? ((a<b)?-1:((a>b)?1:0)) : ((a<b)?1:((a>b)?-1:0)));
                },
                \"us-money-asc\":function(a,b){
                    a = parseFloat(a);
                    b = parseFloat(b);
                    return ((a<b)?-1:((a>b)?1:0));
                },
                \"us-money-desc\":function(a,b){
                    a = parseFloat(a);
                    b = parseFloat(b);
                    return ((a<b)?1:((a>b)?-1:0));
                },
                \"text-asc\":function(a,b){return ((a<b)?-1:((a>b)?1:0));},
                \"text-desc\":function(a,b){return ((a<b)?1:((a>b)?-1:0));}});

            var oTable = \$('#invoices-list').DataTable(dt_config);
            oTable.buttons( 0, null ).container().appendTo(\$(\"#table-buttons-div\"));

            \$(\"#datatable-searchbox\").on(\"keyup\",function(event){if(event.keyCode == 13 || this.value == \"\")oTable.search(this.value).draw();});
            \$(\"#invoice-status-selection, #invoice-purpose-selection\").on(\"change\",function(){oTable.ajax.reload();this.blur();});
            \$('#execute-search-link').on( 'click', function(){oTable.ajax.reload();this.blur();});
            \$(document).bind(\"keyup keydown\", function(e){if(e.ctrlKey&&(e.keyCode==80||e.keyCode==69)){return false;}});
            \$(window).bind('resize',function(){\$(\".dataTables_scrollBody\").css('max-height',dt_config.scrollY()+'px');});
            \$('#total-area').appendTo(\$('#invoices-list_wrapper'));
        });
        viewModel.LoadData = ko.dependentObservable(function() {
            ";
        // line 240
        if ((isset($context["salest"]) ? $context["salest"] : null)) {
            // line 241
            echo "                var ttsales=[];
                ttsales.push({id:'',name:\"All\"});
                ";
            // line 243
            $context['_parent'] = (array) $context;
            $context['_seq'] = twig_ensure_traversable((isset($context["salest"]) ? $context["salest"] : null));
            foreach ($context['_seq'] as $context["_key"] => $context["tsale"]) {
                // line 244
                echo "                    ttsales.push({id:\"";
                echo twig_escape_filter($this->env, $this->getAttribute($context["tsale"], "id", array()), "html", null, true);
                echo "\",name:\"";
                echo twig_escape_filter($this->env, $this->getAttribute($context["tsale"], "saletype", array()), "html", null, true);
                echo "\"});
                ";
            }
            $_parent = $context['_parent'];
            unset($context['_seq'], $context['_iterated'], $context['_key'], $context['tsale'], $context['_parent'], $context['loop']);
            $context = array_intersect_key($context, $_parent) + $_parent;
            // line 246
            echo "                viewModel.invoice_destinations(ttsales);
            ";
        }
        // line 248
        echo "            viewModel.chosen_dest(viewModel.invoice_destinations()[0]);
            }, viewModel);ko.applyBindings(viewModel, document.getElementById(\"content-body\"));
    </script>
";
    }

    public function getTemplateName()
    {
        return "VGMWOBundle:Invoicing:index.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  350 => 248,  346 => 246,  335 => 244,  331 => 243,  327 => 241,  325 => 240,  245 => 163,  199 => 120,  192 => 116,  188 => 115,  184 => 114,  180 => 113,  175 => 112,  172 => 111,  163 => 109,  152 => 100,  143 => 92,  134 => 84,  78 => 29,  74 => 24,  71 => 23,  62 => 18,  55 => 14,  43 => 5,  39 => 4,  34 => 3,  31 => 2,  11 => 1,);
    }
}
