<?php
/* Smarty version 3.1.33, created on 2022-11-03 13:59:19
  from '/home/crescjwi/dashboard.homeworktask.com/content/themes/dashboard/order/order.create.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '3.1.33',
  'unifunc' => 'content_6363c93707ddd1_48462703',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    'faeb899d467ef709bb51ce7c467d0aa2d8bd1576' => 
    array (
      0 => '/home/crescjwi/dashboard.homeworktask.com/content/themes/dashboard/order/order.create.tpl',
      1 => 1656689818,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_6363c93707ddd1_48462703 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_loadInheritance();
$_smarty_tpl->inheritance->init($_smarty_tpl, true);
?>
 

<?php 
$_smarty_tpl->inheritance->instanceBlock($_smarty_tpl, 'Block_4877385296363c937040327_56100937', 'content_wrapper');
?>


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

<div class="card">
    <div class="card-header with-icon">
        <i class="fa fa-shopping-basket mr10"></i>
        <strong>Orders</strong>
        &rsaquo; <strong>Create</strong>
    </div>

    <form class="form-horizontal js_ajax-forms" id="orderForm" data-url="/order" method="POST">
        <div class="card-body">
            <div class="form-group form-row">
                <label class="col-sm-2 control-label text-left" for="customerId">Customer:</label>
                <div class="col-sm-7">
                    <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 if ($_smarty_tpl->tpl_vars['user']->value['is_admin']) {?> <?php if ($_smarty_tpl->tpl_vars['customer']->value['name']) {?>(<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['customer']->value['name'], ENT_QUOTES, 'UTF-8');?>
)<?php }?> - <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['customer']->value['email'], ENT_QUOTES, 'UTF-8');?>
 <?php }?></option>
                        <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                    </select>
                </div>
            </div>

            <div class="form-group form-row">
                <label class="col-sm-2 control-label text-left" for="academicLevel">Academic Level:</label>
                <div class="col-sm-7">
                    <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 form-row">
                <label class="col-sm-2 control-label text-left" for="paperTypeId">Type of paper:</label>
                <div class="col-sm-7">
                    <select name="paperTypeId" class="form-control select_search js_calculate js_custom-toggle" data-val="64">
                        <?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 form-row">
                <label class="col-sm-2 control-label text-left" for="paperTypeOption">Add Paper Type:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control js_calculate" name="paperTypeOption" id="paperTypeOption" maxlength="255">
                </div>
            </div>

            <div class="form-group form-row">
                <label class="col-sm-2 control-label text-left" for="topicCatId">Discipline:</label>
                <div class="col-sm-7">
                    <select name="topicCatId" id="topicCatId" class="form-control select_search js_calculate js_custom-toggle" data-val="52">
                        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['disciplineGroups']->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['title'], 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['is_complex_assignment'], ENT_QUOTES, 'UTF-8');?>
" value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['discipline']->value['discipline_id'], ENT_QUOTES, 'UTF-8');?>
"><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['discipline']->value['title'], 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 form-row">
                <label class="col-sm-2 control-label text-left" for="topcatOption">Add Discipline:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control js_calculate" name="topcatOption" id="topcatOption" maxlength="255">
                </div>
            </div>

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

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

            <div class="form-group form-row">
                <label class="col-sm-2 control-label text-left" for="paperFormat">Paper Format:</label>
                <div class="col-sm-7">
                    <select class="form-control js_calculate js_custom-toggle" name="paperFormat" data-val="4">
                        <?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['paper_format_id'], ENT_QUOTES, 'UTF-8');?>
"><?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 form-row x-hidden">
                <label class="col-sm-2 control-label text-left" for="paperFormatOption">Add Paper Format:</label>
                <div class="col-sm-7">
                    <input class="form-control js_calculate" type="text" name="paperFormatOption" id="paperFormatOption" maxlength="255">
                </div>
            </div>

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

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

            <div class="form-group form-row">
                <label class="col-sm-2 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 form-row">
                <label class="col-sm-2 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 form-row">
                <label class="col-sm-2 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 form-row">
                <label class="col-sm-2 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 form-row">
                <label class="col-sm-2 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 form-row">
                <label class="col-sm-2 control-label text-left">Writer Category</label>
                <div class="col-sm-7">
                    <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="form-group form-row">
                <label class="col-sm-2 control-label text-left">Tracking ID</label>
                <div class="col-sm-7">
                    <input class="form-control" type="text" name="tracking_id" id="tracking_id" maxlength="255">
                </div>
            </div>

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

            <div class="form-group form-row">
                <label class="col-sm-2 control-label text-left">Get Writer Samples</label>
                <div class="col-sm-7">
                    <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 form-row">
                <label class="col-sm-2 control-label text-left">Copy of Sources</label>
                <div class="col-sm-7">
                    <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 form-row">
                <label class="col-sm-2 control-label text-left">Progressive Delivery</label>
                <div class="col-sm-7">
                    <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 form-row">
                <label class="col-sm-2 control-label text-left">Expert Proofreading</label>
                <div class="col-sm-7">
                    <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 form-row">
                <label class="col-sm-2 control-label text-left">Total</label>
                <div class="col-sm-7">
                    <span id="orderPrice" class="h2 text-success">$0.00</span>
                </div>
            </div>

            <div class="form-group form-row">
                <div class="col-md-9 offset-sm-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 -->
                </div>
            </div>
        </div>
        <div class="card-footer text-center">
            <button type="submit" class="btn btn-info">Create Order</button>
        </div>
    </form>
</div>
<?php
}
}
/* {/block 'content_wrapper'} */
/* {block "custom_js"} */
class Block_15228881866363c93707a715_98056820 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'custom_js' => 
  array (
    0 => 'Block_15228881866363c93707a715_98056820',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>

    <?php echo '<script'; ?>
 type="text/javascript">
    $(function () { 
        var siteId;
        var customerId;
        var academicLevel = $("[name='academicLevelId'] :selected").val();
        var tariffs = <?php echo json_encode($_smarty_tpl->tpl_vars['tariffs']->value);?>
;
        var customerSites = <?php echo json_encode($_smarty_tpl->tpl_vars['customerSites']->value);?>
;

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

        $form.find('[name="customerId"], [name="academicLevelId"]').change(function(e) {
            customerId = $("[name='customerId'] :selected").val();
            academicLevel = $("[name='academicLevelId'] :selected").val();
            siteId = customerSites[customerId];
            if(siteId && academicLevel) {
                renderTariffs(siteId, academicLevel);
            }
        });

        $(document).on('change click input', $form.find('.js_calculate'), function(e) {
            calculate();
        });

        $('.js_custom-toggle').on('change',function(){
            var _this = $(this);
            var $value= _this.val();
            var $val = _this.data('val');
            var parent = $(this).closest('.form-group');

            if($value == $val) {
                parent.next('.form-group').removeClass('x-hidden');
            } else {
                parent.next('.form-group').addClass('x-hidden');
            }
        });

        function renderTariffs( siteId, academicLevel ) {
            var tariffControl = $("[data-tariff-control]");
            tariffControl.empty();

            if ( siteId && academicLevel ) {
                activeTariff = tariffs[siteId][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.price_per_page.value) );
                });
            }

            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('complex') || 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,
                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 "custom_js"} */
}
