<?php
/* Smarty version 3.1.33, created on 2019-07-12 12:00:42
  from '/var/www/uvocorp/templates/dashboard/order/order.create.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '3.1.33',
  'unifunc' => 'content_5d285a4a51c452_06189030',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '7505cb3a353a0fdd367f3fa5019613a7901e4bd5' => 
    array (
      0 => '/var/www/uvocorp/templates/dashboard/order/order.create.tpl',
      1 => 1562925633,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_5d285a4a51c452_06189030 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_loadInheritance();
$_smarty_tpl->inheritance->init($_smarty_tpl, true);
?>
 

<?php 
$_smarty_tpl->inheritance->instanceBlock($_smarty_tpl, 'Block_10580631185d285a4a4f84e6_67001492', 'content_wrapper');
$_smarty_tpl->inheritance->endChild($_smarty_tpl, 'dashboard/layout.tpl');
}
/* {block 'content_wrapper'} */
class Block_10580631185d285a4a4f84e6_67001492 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content_wrapper' => 
  array (
    0 => 'Block_10580631185d285a4a4f84e6_67001492',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>

<div class="panel panel-default">
    <div class="panel-heading with-icon">
        <i class="fa fa-shopping-basket pr5 panel-icon"></i>
        <strong>Orders</strong>
        &rsaquo; <strong>Create</strong>
    </div>

    <div class="panel-body">
        <form class="form-horizontal js_ajax-forms" id="orderForm" data-url="/order" method="POST">
            <div class="col-md-9">
                <div class="form-group">
                    <label class="col-sm-3 control-label text-left" for="customerId">Customer:</label>
                    <div class="col-sm-9">
                        <select name="customerId" class="form-control select_search">
                            <option value="-1" selected="" disabled="">Select Customer</option>
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['customers']->value, 'customer');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['customer']->value) {
?>
                                <option value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['customer']->value['customer_id'], ENT_QUOTES, 'UTF-8');?>
"><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['customer']->value['customer_id'], ENT_QUOTES, 'UTF-8');?>
 (<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['customer']->value['name'], ENT_QUOTES, 'UTF-8');?>
) - <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['customer']->value['email'], ENT_QUOTES, 'UTF-8');?>
</option>
                            <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left" for="academicLevel">Academic Level:</label>
                    <div class="col-sm-9">
                        <select name="academicLevelId" class="form-control js_calculate">
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['academicLevels']->value, 'academicLevel');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['academicLevel']->value) {
?>
                                <option value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['academicLevel']->value['id'], ENT_QUOTES, 'UTF-8');?>
" <?php if ($_smarty_tpl->tpl_vars['defaultCourseLevelId']->value == $_smarty_tpl->tpl_vars['academicLevel']->value['id']) {?>selected=""<?php }?>><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['academicLevel']->value['title'], ENT_QUOTES, 'UTF-8');?>
</option>
                            <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left" for="paperTypeId">Type of paper:</label>
                    <div class="col-sm-9">
                        <select name="paperTypeId" class="form-control select_search js_calculate">
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['paperTypes']->value, 'paperType');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['paperType']->value) {
?>
                                <option value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['paperType']->value['id'], ENT_QUOTES, 'UTF-8');?>
"><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['paperType']->value['title'], ENT_QUOTES, 'UTF-8');?>
</option>
                            <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </select>
                    </div>
                </div>

                <div class="form-group x-hidden">
                    <label class="col-sm-3 control-label text-left" for="paperTypeOption">Add custom type of paper:</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control js_calculate" name="paperTypeOption" id="paperTypeOption" maxlength="255">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left" for="topicCatId">Discipline:</label>
                    <div class="col-sm-9">
                        <select id="topicCatId" class="form-control select_search js_calculate" name="topicCatId">
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['disciplinesGroups']->value, 'topicCat');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['topicCat']->value) {
?>
                                <optgroup label="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['topicCat']->value['groupName'], ENT_QUOTES, 'UTF-8');?>
">
                                    <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['topicCat']->value['disciplines'], 'discipline');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['discipline']->value) {
?>
                                        <option data-complex="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['discipline']->value['isComplexAssignment'], ENT_QUOTES, 'UTF-8');?>
" value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['discipline']->value['id'], ENT_QUOTES, 'UTF-8');?>
"><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['discipline']->value['name'], ENT_QUOTES, 'UTF-8');?>
</option>
                                    <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                                </optgroup>
                            <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </select>
                    </div>
                </div>

                <div class="form-group x-hidden">
                    <label class="col-sm-3 control-label text-left" for="topcatOption">Add custom discipline:</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control js_calculate" name="topcatOption" id="topcatOption" maxlength="255">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left" for="topic">Topic:</label>
                    <div class="col-sm-9">   
                        <input type="text" class="form-control" name="topic" id="topic" value="Writer’s choice" maxlength="255">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left" for="paperDetails">Paper instructions:</label>
                    <div class="col-sm-9">
                        <textarea name="paperDetails" class="form-control js_autosize" id="paperDetails"></textarea>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left" for="paperFormat">Paper Format:</label>
                    <div class="col-sm-9">
                        <select class="form-control js_calculate" name="paperFormat">
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['paperFormats']->value, 'paperFormat');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['paperFormat']->value) {
?>
                                <option value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['paperFormat']->value['id'], ENT_QUOTES, 'UTF-8');?>
" <?php if ($_smarty_tpl->tpl_vars['paperFormat']->value['id'] == "1") {?>selected=""<?php }?>><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['paperFormat']->value['title'], ENT_QUOTES, 'UTF-8');?>
</option>
                            <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </select>
                    </div>
                </div>

                <div class="form-group x-hidden">
                    <label class="col-sm-3 control-label text-left" for="paperFormatOption">Add custom paper format:</label>
                    <div class="col-sm-9">
                        <input class="form-control js_calculate" type="text" name="paperFormatOption" id="paperFormatOption" maxlength="255">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Deadline:</label>
                    <div class="col-sm-9">
                        <select name="tariffId" class="form-control js_calculate" data-tariff-control=""></select>
                    </div>
                </div>

                <div class="divider"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Spacing</label>
                    <div class="col-sm-4">
                        <select class="js_calculate form-control" name="spacing">
                            <option value="double">Double Spaced</option>
                            <option value="single">Single Spaced</option>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Pages</label>
                    <div class="col-sm-4">
                        <div class="control-stepper">
                            <button type="button" class="js_calculate btn control-stepper__minus-button incr-btn" data-action="decrease">-</button>
                            <input name="pages" type="text" class="js_calculate form-control control-stepper__input force-integer quantity" data-minvalue="0" value="1">
                            <button type="button" class="js_calculate btn control-stepper__plus-button incr-btn" data-action="increase">+</button>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Sources to be cited</label>
                    <div class="col-sm-4">
                        <div class="control-stepper">
                            <button type="button" class="js_calculate btn control-stepper__minus-button incr-btn" data-action="decrease">-</button>
                            <input name="sources" type="text" class="js_calculate form-control control-stepper__input force-integer quantity" data-minvalue="0" value="0">
                            <button type="button" class="js_calculate btn control-stepper__plus-button incr-btn" data-action="increase">+</button>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Charts</label>
                    <div class="col-sm-4">
                        <div class="control-stepper">
                            <button type="button" class="js_calculate btn control-stepper__minus-button incr-btn" data-action="decrease">-</button>
                            <input name="charts" type="text" class="js_calculate form-control control-stepper__input force-integer quantity" data-minvalue="0" value="0">
                            <button type="button" class="js_calculate btn control-stepper__plus-button incr-btn" data-action="increase">+</button>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">PowerPoint slides</label>
                    <div class="col-sm-4">
                        <div class="control-stepper">
                            <button type="button" class="js_calculate btn control-stepper__minus-button incr-btn" data-action="decrease">-</button>
                            <input name="slides" type="text" class="js_calculate form-control control-stepper__input force-integer quantity" data-minvalue="0" value="0">
                            <button type="button" class="js_calculate btn control-stepper__plus-button incr-btn" data-action="increase">+</button>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Writer Category</label>
                    <div class="col-sm-9">
                        <select class="form-control js_calculate" name="writerCategoryId">
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['writerPreferences']->value, 'writerPreference');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['writerPreference']->value) {
?>
                                <option <?php if (isset($_smarty_tpl->tpl_vars['writerPreference']->value['percent'])) {?>data-percent="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['writerPreference']->value['percent'], ENT_QUOTES, 'UTF-8');?>
"<?php }?> value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['writerPreference']->value['id'], ENT_QUOTES, 'UTF-8');?>
"<?php if ($_smarty_tpl->tpl_vars['writerPreference']->value['id'] == "2") {?>selected=""<?php }?>><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['writerPreference']->value['title'], ENT_QUOTES, 'UTF-8');?>
</option>
                            <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </select>
                    </div>
                </div>

                <div class="divider"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Smart Paper</label>
                    <div class="col-sm-9">
                        <label class="switch" for="smartPaper">
                            <input class="js_calculate" type="checkbox" name="smartPaper" id="smartPaper">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Get Writer Samples</label>
                    <div class="col-sm-9">
                        <label class="switch" for="samplesNeeded">
                            <input class="js_calculate" type="checkbox" name="samplesNeeded" id="samplesNeeded">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Smart Paper</label>
                    <div class="col-sm-9">
                        <label class="switch" for="usedsources">
                            <input class="js_calculate" type="checkbox" name="usedsources" id="usedsources">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Progressive Delivery</label>
                    <div class="col-sm-9">
                        <label class="switch" for="progressiveDeliveryHidden">
                            <input class="js_calculate" type="checkbox" name="progressiveDeliveryHidden" id="progressiveDeliveryHidden">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Expert Proofreading</label>
                    <div class="col-sm-9">
                        <label class="switch" for="expertProofreading">
                            <input class="js_calculate" type="checkbox" name="expertProofreading" id="expertProofreading">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>

                <div class="divider"></div>
                 
                <div class="form-group">
                    <label class="col-sm-3 control-label text-left">Total</label>
                    <div class="col-sm-9">
                        <span id="orderPrice" class="h2 text-success">$0.00</span>
                    </div>
                </div>

            </div>

            <div class="form-group">
                <div class="col-md-9 col-sm-offset-3">
                    <!-- success -->
                    <div class="alert alert-success mt10 x-hidden" role="alert"></div>
                    <!-- success -->

                    <!-- error -->
                    <div class="alert alert-danger mt10 x-hidden" role="alert"></div>
                    <!-- error -->

                    <button type="submit" class="btn btn-primary">Create Order</button>
                </div>
            </div>
        </form>
    </div>
</div>

<?php echo '<script'; ?>
 type="text/javascript">
$(function () { 
    var tariffs = <?php echo json_encode($_smarty_tpl->tpl_vars['tariffs']->value);?>
;

    var $form = $("#orderForm");

    $form 
        && renderTariffs( $("[name='academicLevelId'] :selected").val() ) 
            && calculate();
    $(document).on('change click input', $form.find('.js_calculate'), function(e) {
        calculate();
    });

    $('[name="paperTypeId"]').on('change',function(){
        var $value= $(this).val();
        var parent = $(this).closest('.form-group');

        if($value == 64) {
            parent.next('.form-group').slideDown();
        } else {
            parent.next('.form-group').slideUp();
        }
    });

    $('[name="topicCatId"]').on('change',function(){
        var $value= $(this).val();
        var parent = $(this).closest('.form-group');

        if($value == 52) {
            parent.next('.form-group').slideDown();
        } else {
            parent.next('.form-group').slideUp();
        }
    });

    $('[name="paperFormat"]').on('change',function(){
        var $value= $(this).val();
        var parent = $(this).closest('.form-group');

        if($value == 4) {
            parent.next('.form-group').slideDown();
        } else {
            parent.next('.form-group').slideUp();
        }
    });

    $("[name='academicLevelId']").on('change',function(){
        var academicLevel = $(this).val();
        renderTariffs(academicLevel);
    });

    function renderTariffs( academicLevel ) {
        var tariffControl = $("[data-tariff-control]");
        tariffControl.empty();
        if ( academicLevel ) {
            activeTariff = tariffs[academicLevel]
            $.each(activeTariff, function(i, tariff){
                tariffControl.append( $('<option>').text(tariff.name).attr('value', tariff.id).attr('data-hrs', tariff.hrs).attr('data-cpp', tariff.pricePerPage) );
            });
        }

        return true;
    }

    function calculate() {
        var availableWinbackCoupons = null;
        var discount = null;

        var formStateForCalculator = {
            discount,
            winbackCoupons: availableWinbackCoupons,
            writerCategoryId: parseInt($form.find('[name="writerCategoryId"] :selected').val()) || null,
            writerPercent: parseInt($form.find('[name="writerCategoryId"] :selected').data('percent')) || null,
            complexAssignmentDiscipline: $form.find('[name="topicCatId"] :selected').data('isComplex') || 0,
            pages: parseInt($form.find('[name="pages"]').val()),
            slides: parseInt($form.find('[name="slides"]').val()),
            charts: parseInt($form.find('[name="charts"]').val()),
            tariffPricePerPage: $form.find('[name="tariffId"] :selected').data('cpp') || 0,
            tariffHrs: $form.find('[name="tariffId"] :selected').data('hrs') || 0,
            spacing: $form.find('[name="spacing"] :selected').val() || false,
            getSamplesOn: $form.find('[name="samplesNeeded"]:checked').val() || false,
            getProgressiveDeliveryOn: $form.find('[name="progressiveDeliveryHidden"]:checked').val() || false,
            getUsedSourcesOn: $form.find('[name="usedsources"]:checked').val() || false,
            smartPaper: $form.find('[name="smartPaper"]:checked').val() || false,
            expertProofreading: $form.find('[name="expertProofreading"]:checked').val() || false
        };

        try {
            var cost = PROXIMCostCalculator.calculate(formStateForCalculator);
            $form.find("#orderPrice").text("$"+cost.totalCost);
        } catch (e) {
            console.error(e);
        }
    }        
});
<?php echo '</script'; ?>
>
<?php
}
}
/* {/block 'content_wrapper'} */
}
