order_form.twig (133389B)
1 {{ header }}{{ column_left }} 2 <div id="content"> 3 <div class="page-header"> 4 <div class="container-fluid"> 5 <div class="pull-right"><a href="{{ cancel }}" class="btn btn-default"><i class="fa fa-reply"></i> {{ button_cancel }}</a></div> 6 <h1>{{ heading_title }}</h1> 7 <ul class="breadcrumb"> 8 {% for breadcrumb in breadcrumbs %} 9 <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li> 10 {% endfor %} 11 </ul> 12 </div> 13 </div> 14 <div class="container-fluid"> 15 <div class="panel panel-default"> 16 <div class="panel-heading"> 17 <h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_form }}</h3> 18 </div> 19 <div class="panel-body"> 20 <form class="form-horizontal"> 21 <ul id="order" class="nav nav-tabs nav-justified"> 22 <li class="disabled active"><a href="#tab-customer" data-toggle="tab">1. {{ tab_customer }}</a></li> 23 <li class="disabled"><a href="#tab-cart" data-toggle="tab">2. {{ tab_product }}</a></li> 24 <li class="disabled"><a href="#tab-payment" data-toggle="tab">3. {{ tab_payment }}</a></li> 25 <li class="disabled"><a href="#tab-shipping" data-toggle="tab">4. {{ tab_shipping }}</a></li> 26 <li class="disabled"><a href="#tab-total" data-toggle="tab">5. {{ tab_total }}</a></li> 27 </ul> 28 <div class="tab-content"> 29 <div class="tab-pane active" id="tab-customer"> 30 <div class="form-group"> 31 <label class="col-sm-2 control-label" for="input-store">{{ entry_store }}</label> 32 <div class="col-sm-10"> 33 <select name="store_id" id="input-store" class="form-control"> 34 {% for store in stores %} 35 {% if store.store_id == store_id %} 36 <option value="{{ store.store_id }}" selected="selected">{{ store.name }}</option> 37 {% else %} 38 <option value="{{ store.store_id }}">{{ store.name }}</option> 39 {% endif %} 40 {% endfor %} 41 </select> 42 </div> 43 </div> 44 <div class="form-group"> 45 <label class="col-sm-2 control-label" for="input-currency">{{ entry_currency }}</label> 46 <div class="col-sm-10"> 47 <select name="currency" id="input-currency" class="form-control"> 48 {% for currency in currencies %} 49 {% if currency.code == currency_code %} 50 <option value="{{ currency.code }}" selected="selected">{{ currency.title }}</option> 51 {% else %} 52 <option value="{{ currency.code }}">{{ currency.title }}</option> 53 {% endif %} 54 {% endfor %} 55 </select> 56 </div> 57 </div> 58 <div class="form-group"> 59 <label class="col-sm-2 control-label" for="input-customer">{{ entry_customer }}</label> 60 <div class="col-sm-10"> 61 <input type="text" name="customer" value="{{ customer }}" placeholder="{{ entry_customer }}" id="input-customer" class="form-control" /> 62 <input type="hidden" name="customer_id" value="{{ customer_id }}" /> 63 </div> 64 </div> 65 <div class="form-group"> 66 <label class="col-sm-2 control-label" for="input-customer-group">{{ entry_customer_group }}</label> 67 <div class="col-sm-10"> 68 <select name="customer_group_id" id="input-customer-group" class="form-control"> 69 {% for customer_group in customer_groups %} 70 {% if customer_group.customer_group_id == customer_group_id %} 71 <option value="{{ customer_group.customer_group_id }}" selected="selected">{{ customer_group.name }}</option> 72 {% else %} 73 <option value="{{ customer_group.customer_group_id }}">{{ customer_group.name }}</option> 74 {% endif %} 75 {% endfor %} 76 </select> 77 </div> 78 </div> 79 <div class="form-group required"> 80 <label class="col-sm-2 control-label" for="input-firstname">{{ entry_firstname }}</label> 81 <div class="col-sm-10"> 82 <input type="text" name="firstname" value="{{ firstname }}" id="input-firstname" class="form-control" /> 83 </div> 84 </div> 85 <div class="form-group required"> 86 <label class="col-sm-2 control-label" for="input-lastname">{{ entry_lastname }}</label> 87 <div class="col-sm-10"> 88 <input type="text" name="lastname" value="{{ lastname }}" id="input-lastname" class="form-control" /> 89 </div> 90 </div> 91 <div class="form-group required"> 92 <label class="col-sm-2 control-label" for="input-email">{{ entry_email }}</label> 93 <div class="col-sm-10"> 94 <input type="text" name="email" value="{{ email }}" id="input-email" class="form-control" /> 95 </div> 96 </div> 97 <div class="form-group required"> 98 <label class="col-sm-2 control-label" for="input-telephone">{{ entry_telephone }}</label> 99 <div class="col-sm-10"> 100 <input type="text" name="telephone" value="{{ telephone }}" id="input-telephone" class="form-control" /> 101 </div> 102 </div> 103 {% for custom_field in custom_fields %} 104 {% if custom_field.location == 'account' %} 105 {% if custom_field.type == 'select' %} 106 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 107 <label class="col-sm-2 control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 108 <div class="col-sm-10"> 109 <select name="custom_field[{{ custom_field.custom_field_id }}]" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control"> 110 <option value="">{{ text_select }}</option> 111 {% for custom_field_value in custom_field.custom_field_value %} 112 {% if account_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == account_custom_field[custom_field.custom_field_id] %} 113 <option value="{{ custom_field_value.custom_field_value_id }}" selected="selected">{{ custom_field_value.name }}</option> 114 {% else %} 115 <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option> 116 {% endif %} 117 {% endfor %} 118 </select> 119 </div> 120 </div> 121 {% endif %} 122 {% if custom_field.type == 'radio' %} 123 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 124 <label class="col-sm-2 control-label">{{ custom_field.name }}</label> 125 <div class="col-sm-10"> 126 <div id="input-custom-field{{ custom_field.custom_field_id }}"> 127 {% for custom_field_value in custom_field.custom_field_value %} 128 <div class="radio"> 129 {% if account_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == account_custom_field[custom_field.custom_field_id] %} 130 <label> 131 <input type="radio" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" /> 132 {{ custom_field_value.name }}</label> 133 {% else %} 134 <label> 135 <input type="radio" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" /> 136 {{ custom_field_value.name }}</label> 137 {% endif %} 138 </div> 139 {% endfor %} 140 </div> 141 </div> 142 </div> 143 {% endif %} 144 {% if custom_field.type == 'checkbox' %} 145 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 146 <label class="col-sm-2 control-label">{{ custom_field.name }}</label> 147 <div class="col-sm-10"> 148 <div id="input-custom-field{{ custom_field.custom_field_id }}"> 149 {% for custom_field_value in custom_field.custom_field_value %} 150 <div class="checkbox"> 151 {% if account_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id in account_custom_field[custom_field.custom_field_id] %} 152 <label> 153 <input type="checkbox" name="custom_field[{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" /> 154 {{ custom_field_value.name }}</label> 155 {% else %} 156 <label> 157 <input type="checkbox" name="custom_field[{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" /> 158 {{ custom_field_value.name }}</label> 159 {% endif %} 160 </div> 161 {% endfor %} 162 </div> 163 </div> 164 </div> 165 {% endif %} 166 {% if custom_field.type == 'text' %} 167 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 168 <label class="col-sm-2 control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 169 <div class="col-sm-10"> 170 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ account_custom_field[custom_field.custom_field_id] ? account_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 171 </div> 172 </div> 173 {% endif %} 174 {% if custom_field.type == 'textarea' %} 175 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 176 <label class="col-sm-2 control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 177 <div class="col-sm-10"> 178 <textarea name="custom_field[{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control">{{ custom_field.value }}</textarea> 179 </div> 180 </div> 181 {% endif %} 182 {% if custom_field.type == 'file' %} 183 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 184 <label class="col-sm-2 control-label">{{ custom_field.name }}</label> 185 <div class="col-sm-10"> 186 <button type="button" id="button-custom-field{{ custom_field.custom_field_id }}" class="btn btn-default"><i class="fa fa-upload"></i> {{ button_upload }}</button> 187 <input type="hidden" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ account_custom_field[custom_field.custom_field_id] ? account_custom_field[custom_field.custom_field_id] }}" id="input-custom-field{{ custom_field.custom_field_id }}" /> 188 </div> 189 </div> 190 {% endif %} 191 {% if custom_field.type == 'date' %} 192 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 193 <label class="col-sm-2 control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 194 <div class="col-sm-10"> 195 <div class="input-group date"> 196 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ account_custom_field[custom_field.custom_field_id] ? account_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 197 <span class="input-group-btn"> 198 <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> 199 </span></div> 200 </div> 201 </div> 202 {% endif %} 203 {% if custom_field.type == 'time' %} 204 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 205 <label class="col-sm-2 control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 206 <div class="col-sm-10"> 207 <div class="input-group time"> 208 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ account_custom_field[custom_field.custom_field_id] ? account_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="HH:mm" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 209 <span class="input-group-btn"> 210 <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> 211 </span></div> 212 </div> 213 </div> 214 {% endif %} 215 {% if custom_field.type == 'datetime' %} 216 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 217 <label class="col-sm-2 control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 218 <div class="col-sm-10"> 219 <div class="input-group datetime"> 220 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ account_custom_field[custom_field.custom_field_id] ? account_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD HH:mm" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 221 <span class="input-group-btn"> 222 <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> 223 </span></div> 224 </div> 225 </div> 226 {% endif %} 227 {% endif %} 228 {% endfor %} 229 <div class="text-right"> 230 <button type="button" id="button-customer" data-loading-text="{{ text_loading }}" class="btn btn-primary"><i class="fa fa-arrow-right"></i> {{ button_continue }}</button> 231 </div> 232 </div> 233 <div class="tab-pane" id="tab-cart"> 234 <div class="table-responsive"> 235 <table class="table table-bordered"> 236 <thead> 237 <tr> 238 <td class="text-left">{{ column_product }}</td> 239 <td class="text-left">{{ column_model }}</td> 240 <td class="text-right">{{ column_quantity }}</td> 241 <td class="text-right">{{ column_price }}</td> 242 <td class="text-right">{{ column_total }}</td> 243 <td>{{ column_action }}</td> 244 </tr> 245 </thead> 246 <tbody id="cart"> 247 {% if order_products or order_vouchers %} 248 {% set product_row = 0 %} 249 {% for order_product in order_products %} 250 <tr> 251 <td class="text-left">{{ order_product.name }}<br /> 252 <input type="hidden" name="product[{{ product_row }}][product_id]" value="{{ order_product.product_id }}" /> 253 {% for option in order_product.option %} 254 - <small>{{ option.name }}: {{ option.value }}</small><br /> 255 {% if option.type == 'select' or option.type == 'radio' or option.type == 'image' %} 256 <input type="hidden" name="product[{{ product_row }}][option][{{ option.product_option_id }}]" value="{{ option.product_option_value_id }}" /> 257 {% endif %} 258 {% if option.type == 'checkbox' %} 259 <input type="hidden" name="product[{{ product_row }}][option][{{ option.product_option_id }}][]" value="{{ option.product_option_value_id }}" /> 260 {% endif %} 261 {% if option.type == 'text' or option.type == 'textarea' or option.type == 'file' or option.type == 'date' or option.type == 'datetime' or option.type == 'time' %} 262 <input type="hidden" name="product[{{ product_row }}][option][{{ option.product_option_id }}]" value="{{ option.value }}" /> 263 {% endif %} 264 {% endfor %}</td> 265 <td class="text-left">{{ order_product.model }}</td> 266 <td class="text-right">{{ order_product.quantity }} 267 <input type="hidden" name="product[{{ product_row }}][quantity]" value="{{ order_product.quantity }}" /></td> 268 <td class="text-right"></td> 269 <td class="text-right"></td> 270 <td class="text-center"></td> 271 </tr> 272 {% set product_row = product_row + 1 %} 273 {% endfor %} 274 {% set voucher_row = 0 %} 275 {% for order_voucher in order_vouchers %} 276 <tr> 277 <td class="text-left">{{ order_voucher.description }} 278 <input type="hidden" name="voucher[{{ voucher_row }}][voucher_id]" value="{{ order_voucher.voucher_id }}" /> 279 <input type="hidden" name="voucher[{{ voucher_row }}][description]" value="{{ order_voucher.description }}" /> 280 <input type="hidden" name="voucher[{{ voucher_row }}][code]" value="{{ order_voucher.code }}" /> 281 <input type="hidden" name="voucher[{{ voucher_row }}][from_name]" value="{{ order_voucher.from_name }}" /> 282 <input type="hidden" name="voucher[{{ voucher_row }}][from_email]" value="{{ order_voucher.from_email }}" /> 283 <input type="hidden" name="voucher[{{ voucher_row }}][to_name]" value="{{ order_voucher.to_name }}" /> 284 <input type="hidden" name="voucher[{{ voucher_row }}][to_email]" value="{{ order_voucher.to_email }}" /> 285 <input type="hidden" name="voucher[{{ voucher_row }}][voucher_theme_id]" value="{{ order_voucher.voucher_theme_id }}" /> 286 <input type="hidden" name="voucher[{{ voucher_row }}][message]" value="{{ order_voucher.message }}" /> 287 <input type="hidden" name="voucher[{{ voucher_row }}][amount]" value="{{ order_voucher.amount }}" /></td> 288 <td class="text-left"></td> 289 <td class="text-right">1</td> 290 <td class="text-right"></td> 291 <td class="text-right"></td> 292 <td class="text-center"></td> 293 </tr> 294 {% set voucher_row = voucher_row + 1 %} 295 {% endfor %} 296 {% else %} 297 <tr> 298 <td class="text-center" colspan="6">{{ text_no_results }}</td> 299 </tr> 300 </tbody> 301 {% endif %} 302 </table> 303 </div> 304 <ul class="nav nav-tabs nav-justified"> 305 <li class="active"><a href="#tab-product" data-toggle="tab">{{ tab_product }}</a></li> 306 <li><a href="#tab-voucher" data-toggle="tab">{{ tab_voucher }}</a></li> 307 </ul> 308 <div class="tab-content"> 309 <div class="tab-pane active" id="tab-product"> 310 <fieldset> 311 <legend>{{ text_product }}</legend> 312 <div class="form-group"> 313 <label class="col-sm-2 control-label" for="input-product">{{ entry_product }}</label> 314 <div class="col-sm-10"> 315 <input type="text" name="product" value="" id="input-product" class="form-control" /> 316 <input type="hidden" name="product_id" value="" /> 317 </div> 318 </div> 319 <div class="form-group"> 320 <label class="col-sm-2 control-label" for="input-quantity">{{ entry_quantity }}</label> 321 <div class="col-sm-10"> 322 <input type="text" name="quantity" value="1" id="input-quantity" class="form-control" /> 323 </div> 324 </div> 325 <div id="option"></div> 326 </fieldset> 327 <div class="text-right"> 328 <button type="button" id="button-product-add" data-loading-text="{{ text_loading }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i> {{ button_product_add }}</button> 329 </div> 330 </div> 331 <div class="tab-pane" id="tab-voucher"> 332 <fieldset> 333 <legend>{{ text_voucher }}</legend> 334 <div class="form-group required"> 335 <label class="col-sm-2 control-label" for="input-to-name">{{ entry_to_name }}</label> 336 <div class="col-sm-10"> 337 <input type="text" name="to_name" value="" id="input-to-name" class="form-control" /> 338 </div> 339 </div> 340 <div class="form-group required"> 341 <label class="col-sm-2 control-label" for="input-to-email">{{ entry_to_email }}</label> 342 <div class="col-sm-10"> 343 <input type="text" name="to_email" value="" id="input-to-email" class="form-control" /> 344 </div> 345 </div> 346 <div class="form-group required"> 347 <label class="col-sm-2 control-label" for="input-from-name">{{ entry_from_name }}</label> 348 <div class="col-sm-10"> 349 <input type="text" name="from_name" value="" id="input-from-name" class="form-control" /> 350 </div> 351 </div> 352 <div class="form-group required"> 353 <label class="col-sm-2 control-label" for="input-from-email">{{ entry_from_email }}</label> 354 <div class="col-sm-10"> 355 <input type="text" name="from_email" value="" id="input-from-email" class="form-control" /> 356 </div> 357 </div> 358 <div class="form-group required"> 359 <label class="col-sm-2 control-label" for="input-theme">{{ entry_theme }}</label> 360 <div class="col-sm-10"> 361 <select name="voucher_theme_id" id="input-theme" class="form-control"> 362 {% for voucher_theme in voucher_themes %} 363 <option value="{{ voucher_theme.voucher_theme_id }}">{{ voucher_theme.name }}</option> 364 {% endfor %} 365 </select> 366 </div> 367 </div> 368 <div class="form-group"> 369 <label class="col-sm-2 control-label" for="input-message">{{ entry_message }}</label> 370 <div class="col-sm-10"> 371 <textarea name="message" rows="5" id="input-message" class="form-control"></textarea> 372 </div> 373 </div> 374 <div class="form-group required"> 375 <label class="col-sm-2 control-label" for="input-amount">{{ entry_amount }}</label> 376 <div class="col-sm-10"> 377 <input type="text" name="amount" value="{{ voucher_min }}" id="input-amount" class="form-control" /> 378 </div> 379 </div> 380 </fieldset> 381 <div class="text-right"> 382 <button type="button" id="button-voucher-add" data-loading-text="{{ text_loading }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i> {{ button_voucher_add }}</button> 383 </div> 384 </div> 385 </div> 386 <br /> 387 <div class="row"> 388 <div class="col-sm-6 text-left"> 389 <button type="button" onclick="$('a[href=\'#tab-customer\']').tab('show');" class="btn btn-default"><i class="fa fa-arrow-left"></i> {{ button_back }}</button> 390 </div> 391 <div class="col-sm-6 text-right"> 392 <button type="button" id="button-cart" class="btn btn-primary"><i class="fa fa-arrow-right"></i> {{ button_continue }}</button> 393 </div> 394 </div> 395 </div> 396 <div class="tab-pane" id="tab-payment"> 397 <div class="form-group"> 398 <label class="col-sm-2 control-label" for="input-payment-address">{{ entry_address }}</label> 399 <div class="col-sm-10"> 400 <select name="payment_address" id="input-payment-address" class="form-control"> 401 <option value="0" selected="selected">{{ text_none }}</option> 402 {% for address in addresses %} 403 <option value="{{ address.address_id }}">{{ address.firstname }} {{ address.lastname }}, {{ address.address_1 }}, {{ address.city }}, {{ address.country }}</option> 404 {% endfor %} 405 </select> 406 </div> 407 </div> 408 <div class="form-group required"> 409 <label class="col-sm-2 control-label" for="input-payment-firstname">{{ entry_firstname }}</label> 410 <div class="col-sm-10"> 411 <input type="text" name="firstname" value="{{ payment_firstname }}" id="input-payment-firstname" class="form-control" /> 412 </div> 413 </div> 414 <div class="form-group required"> 415 <label class="col-sm-2 control-label" for="input-payment-lastname">{{ entry_lastname }}</label> 416 <div class="col-sm-10"> 417 <input type="text" name="lastname" value="{{ payment_lastname }}" id="input-payment-lastname" class="form-control" /> 418 </div> 419 </div> 420 <div class="form-group"> 421 <label class="col-sm-2 control-label" for="input-payment-company">{{ entry_company }}</label> 422 <div class="col-sm-10"> 423 <input type="text" name="company" value="{{ payment_company }}" id="input-payment-company" class="form-control" /> 424 </div> 425 </div> 426 <div class="form-group required"> 427 <label class="col-sm-2 control-label" for="input-payment-address-1">{{ entry_address_1 }}</label> 428 <div class="col-sm-10"> 429 <input type="text" name="address_1" value="{{ payment_address_1 }}" id="input-payment-address-1" class="form-control" /> 430 </div> 431 </div> 432 <div class="form-group"> 433 <label class="col-sm-2 control-label" for="input-payment-address-2">{{ entry_address_2 }}</label> 434 <div class="col-sm-10"> 435 <input type="text" name="address_2" value="{{ payment_address_2 }}" id="input-payment-address-2" class="form-control" /> 436 </div> 437 </div> 438 <div class="form-group required"> 439 <label class="col-sm-2 control-label" for="input-payment-city">{{ entry_city }}</label> 440 <div class="col-sm-10"> 441 <input type="text" name="city" value="{{ payment_city }}" id="input-payment-city" class="form-control" /> 442 </div> 443 </div> 444 <div class="form-group required"> 445 <label class="col-sm-2 control-label" for="input-payment-postcode">{{ entry_postcode }}</label> 446 <div class="col-sm-10"> 447 <input type="text" name="postcode" value="{{ payment_postcode }}" id="input-payment-postcode" class="form-control" /> 448 </div> 449 </div> 450 <div class="form-group required"> 451 <label class="col-sm-2 control-label" for="input-payment-country">{{ entry_country }}</label> 452 <div class="col-sm-10"> 453 <select name="country_id" id="input-payment-country" class="form-control"> 454 <option value="">{{ text_select }}</option> 455 {% for country in countries %} 456 {% if country.country_id == payment_country_id %} 457 <option value="{{ country.country_id }}" selected="selected">{{ country.name }}</option> 458 {% else %} 459 <option value="{{ country.country_id }}">{{ country.name }}</option> 460 {% endif %} 461 {% endfor %} 462 </select> 463 </div> 464 </div> 465 <div class="form-group required"> 466 <label class="col-sm-2 control-label" for="input-payment-zone">{{ entry_zone }}</label> 467 <div class="col-sm-10"> 468 <select name="zone_id" id="input-payment-zone" class="form-control"> 469 </select> 470 </div> 471 </div> 472 {% for custom_field in custom_fields %} 473 {% if custom_field.location == 'address' %} 474 {% if custom_field.type == 'select' %} 475 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 476 <label class="col-sm-2 control-label" for="input-payment-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 477 <div class="col-sm-10"> 478 <select name="custom_field[{{ custom_field.custom_field_id }}]" id="input-payment-custom-field{{ custom_field.custom_field_id }}" class="form-control"> 479 <option value="">{{ text_select }}</option> 480 {% for custom_field_value in custom_field.custom_field_value %} 481 {% if payment_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == payment_custom_field[custom_field.custom_field_id] %} 482 <option value="{{ custom_field_value.custom_field_value_id }}" selected="selected">{{ custom_field_value.name }}</option> 483 {% else %} 484 <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option> 485 {% endif %} 486 {% endfor %} 487 </select> 488 </div> 489 </div> 490 {% endif %} 491 {% if custom_field.type == 'radio' %} 492 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 493 <label class="col-sm-2 control-label">{{ custom_field.name }}</label> 494 <div class="col-sm-10"> 495 <div id="input-payment-custom-field{{ custom_field.custom_field_id }}"> 496 {% for custom_field_value in custom_field.custom_field_value %} 497 <div class="radio"> 498 {% if payment_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == payment_custom_field[custom_field.custom_field_id] %} 499 <label> 500 <input type="radio" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" /> 501 {{ custom_field_value.name }}</label> 502 {% else %} 503 <label> 504 <input type="radio" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" /> 505 {{ custom_field_value.name }}</label> 506 {% endif %} 507 </div> 508 {% endfor %} 509 </div> 510 </div> 511 </div> 512 {% endif %} 513 {% if custom_field.type == 'checkbox' %} 514 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 515 <label class="col-sm-2 control-label">{{ custom_field.name }}</label> 516 <div class="col-sm-10"> 517 <div id="input-payment-custom-field{{ custom_field.custom_field_id }}"> 518 {% for custom_field_value in custom_field.custom_field_value %} 519 <div class="checkbox"> 520 {% if payment_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id in payment_custom_field[custom_field.custom_field_id] %} 521 <label> 522 <input type="checkbox" name="custom_field[{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" /> 523 {{ custom_field_value.name }}</label> 524 {% else %} 525 <label> 526 <input type="checkbox" name="custom_field[{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" /> 527 {{ custom_field_value.name }}</label> 528 {% endif %} 529 </div> 530 {% endfor %} 531 </div> 532 </div> 533 </div> 534 {% endif %} 535 {% if custom_field.type == 'text' %} 536 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 537 <label class="col-sm-2 control-label" for="input-payment-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 538 <div class="col-sm-10"> 539 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ payment_custom_field[custom_field.custom_field_id] ? payment_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-payment-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 540 </div> 541 </div> 542 {% endif %} 543 {% if custom_field.type == 'textarea' %} 544 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 545 <label class="col-sm-2 control-label" for="input-payment-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 546 <div class="col-sm-10"> 547 <textarea name="custom_field[{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-payment-custom-field{{ custom_field.custom_field_id }}" class="form-control">{{ payment_custom_field[custom_field.custom_field_id] ? payment_custom_field[custom_field.custom_field_id] : custom_field.value }}</textarea> 548 </div> 549 </div> 550 {% endif %} 551 {% if custom_field.type == 'file' %} 552 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 553 <label class="col-sm-2 control-label">{{ custom_field.name }}</label> 554 <div class="col-sm-10"> 555 <button type="button" id="button-payment-custom-field{{ custom_field.custom_field_id }}" data-loading-text="{{ text_loading }}" class="btn btn-default"><i class="fa fa-upload"></i> {{ button_upload }}</button> 556 <input type="hidden" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ payment_custom_field[custom_field.custom_field_id] ? payment_custom_field[custom_field.custom_field_id] }}" id="input-payment-custom-field{{ custom_field.custom_field_id }}" /> 557 </div> 558 </div> 559 {% endif %} 560 {% if custom_field.type == 'date' %} 561 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 562 <label class="col-sm-2 control-label" for="input-payment-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 563 <div class="col-sm-10"> 564 <div class="input-group date"> 565 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ payment_custom_field[custom_field.custom_field_id] ? payment_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD" id="input-payment-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 566 <span class="input-group-btn"> 567 <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> 568 </span></div> 569 </div> 570 </div> 571 {% endif %} 572 {% if custom_field.type == 'time' %} 573 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 574 <label class="col-sm-2 control-label" for="input-payment-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 575 <div class="col-sm-10"> 576 <div class="input-group time"> 577 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ payment_custom_field[custom_field.custom_field_id] ? payment_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="HH:mm" id="input-payment-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 578 <span class="input-group-btn"> 579 <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> 580 </span></div> 581 </div> 582 </div> 583 {% endif %} 584 {% if custom_field.type == 'datetime' %} 585 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 586 <label class="col-sm-2 control-label" for="input-payment-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 587 <div class="col-sm-10"> 588 <div class="input-group datetime"> 589 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ payment_custom_field[custom_field.custom_field_id] ? payment_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD HH:mm" id="input-payment-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 590 <span class="input-group-btn"> 591 <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> 592 </span></div> 593 </div> 594 </div> 595 {% endif %} 596 {% endif %} 597 {% endfor %} 598 <div class="row"> 599 <div class="col-sm-6 text-left"> 600 <button type="button" onclick="$('a[href=\'#tab-cart\']').tab('show');" class="btn btn-default"><i class="fa fa-arrow-left"></i> {{ button_back }}</button> 601 </div> 602 <div class="col-sm-6 text-right"> 603 <button type="button" id="button-payment-address" data-loading-text="{{ text_loading }}" class="btn btn-primary"><i class="fa fa-arrow-right"></i> {{ button_continue }}</button> 604 </div> 605 </div> 606 </div> 607 <div class="tab-pane" id="tab-shipping"> 608 <div class="form-group"> 609 <label class="col-sm-2 control-label" for="input-shipping-address">{{ entry_address }}</label> 610 <div class="col-sm-10"> 611 <select name="shipping_address" id="input-shipping-address" class="form-control"> 612 <option value="0" selected="selected">{{ text_none }}</option> 613 {% for address in addresses %} 614 <option value="{{ address.address_id }}">{{ address.firstname }} {{ address.lastname }}, {{ address.address_1 }}, {{ address.city }}, {{ address.country }}</option> 615 {% endfor %} 616 </select> 617 </div> 618 </div> 619 <div class="form-group required"> 620 <label class="col-sm-2 control-label" for="input-shipping-firstname">{{ entry_firstname }}</label> 621 <div class="col-sm-10"> 622 <input type="text" name="firstname" value="{{ shipping_firstname }}" id="input-shipping-firstname" class="form-control" /> 623 </div> 624 </div> 625 <div class="form-group required"> 626 <label class="col-sm-2 control-label" for="input-shipping-lastname">{{ entry_lastname }}</label> 627 <div class="col-sm-10"> 628 <input type="text" name="lastname" value="{{ shipping_lastname }}" id="input-shipping-lastname" class="form-control" /> 629 </div> 630 </div> 631 <div class="form-group"> 632 <label class="col-sm-2 control-label" for="input-shipping-company">{{ entry_company }}</label> 633 <div class="col-sm-10"> 634 <input type="text" name="company" value="{{ shipping_company }}" id="input-shipping-company" class="form-control" /> 635 </div> 636 </div> 637 <div class="form-group required"> 638 <label class="col-sm-2 control-label" for="input-shipping-address-1">{{ entry_address_1 }}</label> 639 <div class="col-sm-10"> 640 <input type="text" name="address_1" value="{{ shipping_address_1 }}" id="input-shipping-address-1" class="form-control" /> 641 </div> 642 </div> 643 <div class="form-group"> 644 <label class="col-sm-2 control-label" for="input-shipping-address-2">{{ entry_address_2 }}</label> 645 <div class="col-sm-10"> 646 <input type="text" name="address_2" value="{{ shipping_address_2 }}" id="input-shipping-address-2" class="form-control" /> 647 </div> 648 </div> 649 <div class="form-group required"> 650 <label class="col-sm-2 control-label" for="input-shipping-city">{{ entry_city }}</label> 651 <div class="col-sm-10"> 652 <input type="text" name="city" value="{{ shipping_city }}" id="input-shipping-city" class="form-control" /> 653 </div> 654 </div> 655 <div class="form-group required"> 656 <label class="col-sm-2 control-label" for="input-shipping-postcode">{{ entry_postcode }}</label> 657 <div class="col-sm-10"> 658 <input type="text" name="postcode" value="{{ shipping_postcode }}" id="input-shipping-postcode" class="form-control" /> 659 </div> 660 </div> 661 <div class="form-group required"> 662 <label class="col-sm-2 control-label" for="input-shipping-country">{{ entry_country }}</label> 663 <div class="col-sm-10"> 664 <select name="country_id" id="input-shipping-country" class="form-control"> 665 <option value="">{{ text_select }}</option> 666 {% for country in countries %} 667 {% if country.country_id == shipping_country_id %} 668 <option value="{{ country.country_id }}" selected="selected">{{ country.name }}</option> 669 {% else %} 670 <option value="{{ country.country_id }}">{{ country.name }}</option> 671 {% endif %} 672 {% endfor %} 673 </select> 674 </div> 675 </div> 676 <div class="form-group required"> 677 <label class="col-sm-2 control-label" for="input-shipping-zone">{{ entry_zone }}</label> 678 <div class="col-sm-10"> 679 <select name="zone_id" id="input-shipping-zone" class="form-control"> 680 </select> 681 </div> 682 </div> 683 {% for custom_field in custom_fields %} 684 {% if custom_field.location == 'address' %} 685 {% if custom_field.type == 'select' %} 686 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 687 <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 688 <div class="col-sm-10"> 689 <select name="custom_field[{{ custom_field.custom_field_id }}]" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control"> 690 <option value="">{{ text_select }}</option> 691 {% for custom_field_value in custom_field.custom_field_value %} 692 {% if shipping_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == shipping_custom_field[custom_field.custom_field_id] %} 693 <option value="{{ custom_field_value.custom_field_value_id }}" selected="selected">{{ custom_field_value.name }}</option> 694 {% else %} 695 <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option> 696 {% endif %} 697 {% endfor %} 698 </select> 699 </div> 700 </div> 701 {% endif %} 702 {% if custom_field.type == 'radio' %} 703 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 704 <label class="col-sm-2 control-label">{{ custom_field.name }}</label> 705 <div class="col-sm-10"> 706 <div id="input-shipping-custom-field{{ custom_field.custom_field_id }}"> 707 {% for custom_field_value in custom_field.custom_field_value %} 708 <div class="radio"> 709 {% if shipping_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == shipping_custom_field[custom_field.custom_field_id] %} 710 <label> 711 <input type="radio" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" /> 712 {{ custom_field_value.name }}</label> 713 {% else %} 714 <label> 715 <input type="radio" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" /> 716 {{ custom_field_value.name }}</label> 717 {% endif %} 718 </div> 719 {% endfor %} 720 </div> 721 </div> 722 </div> 723 {% endif %} 724 {% if custom_field.type == 'checkbox' %} 725 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 726 <label class="col-sm-2 control-label">{{ custom_field.name }}</label> 727 <div class="col-sm-10"> 728 <div id="input-shipping-custom-field{{ custom_field.custom_field_id }}"> 729 {% for custom_field_value in custom_field.custom_field_value %} 730 <div class="checkbox"> 731 {% if shipping_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id in shipping_custom_field[custom_field.custom_field_id] %} 732 <label> 733 <input type="checkbox" name="custom_field[{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" /> 734 {{ custom_field_value.name }}</label> 735 {% else %} 736 <label> 737 <input type="checkbox" name="custom_field[{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" /> 738 {{ custom_field_value.name }}</label> 739 {% endif %} 740 </div> 741 {% endfor %} 742 </div> 743 </div> 744 </div> 745 {% endif %} 746 {% if custom_field.type == 'text' %} 747 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 748 <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 749 <div class="col-sm-10"> 750 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ shipping_custom_field[custom_field.custom_field_id] ? shipping_custom_field[custom_field.custom_field_id] ? custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 751 </div> 752 </div> 753 {% endif %} 754 {% if custom_field.type == 'textarea' %} 755 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 756 <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 757 <div class="col-sm-10"> 758 <textarea name="custom_field[{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control">{{ shipping_custom_field[custom_field.custom_field_id] ? shipping_custom_field[custom_field.custom_field_id] : custom_field.value }}</textarea> 759 </div> 760 </div> 761 {% endif %} 762 {% if custom_field.type == 'file' %} 763 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 764 <label class="col-sm-2 control-label">{{ custom_field.name }}</label> 765 <div class="col-sm-10"> 766 <button type="button" id="button-shipping-custom-field{{ custom_field.custom_field_id }}" data-loading-text="{{ text_loading }}" class="btn btn-default"><i class="fa fa-upload"></i> {{ button_upload }}</button> 767 <input type="hidden" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ shipping_custom_field[custom_field.custom_field_id] ? shipping_custom_field[custom_field.custom_field_id] }}" id="input-custom-field{{ custom_field.custom_field_id }}" /> 768 </div> 769 </div> 770 {% endif %} 771 {% if custom_field.type == 'date' %} 772 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 773 <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 774 <div class="col-sm-10"> 775 <div class="input-group date"> 776 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ shipping_custom_field[custom_field.custom_field_id] ? shipping_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 777 <span class="input-group-btn"> 778 <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> 779 </span></div> 780 </div> 781 </div> 782 {% endif %} 783 {% if custom_field.type == 'time' %} 784 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 785 <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 786 <div class="col-sm-10"> 787 <div class="input-group time"> 788 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ shipping_custom_field[custom_field.custom_field_id] ? shipping_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="HH:mm" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 789 <span class="input-group-btn"> 790 <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> 791 </span></div> 792 </div> 793 </div> 794 {% endif %} 795 {% if custom_field.type == 'datetime' %} 796 <div class="form-group custom-field custom-field{{ custom_field.custom_field_id }}" data-sort="{{ custom_field.sort_order + 3 }}"> 797 <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label> 798 <div class="col-sm-10"> 799 <div class="input-group datetime"> 800 <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ shipping_custom_field[custom_field.custom_field_id] ? shipping_custom_field[custom_field.custom_field_id] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD HH:mm" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control" /> 801 <span class="input-group-btn"> 802 <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button> 803 </span></div> 804 </div> 805 </div> 806 {% endif %} 807 {% endif %} 808 {% endfor %} 809 <div class="row"> 810 <div class="col-sm-6 text-left"> 811 <button type="button" onclick="$('a[href=\'#tab-payment\']').tab('show');" class="btn btn-default"><i class="fa fa-arrow-left"></i> {{ button_back }}</button> 812 </div> 813 <div class="col-sm-6 text-right"> 814 <button type="button" id="button-shipping-address" data-loading-text="{{ text_loading }}" class="btn btn-primary"><i class="fa fa-arrow-right"></i> {{ button_continue }}</button> 815 </div> 816 </div> 817 </div> 818 <div class="tab-pane" id="tab-total"> 819 <div class="table-responsive"> 820 <table class="table table-bordered"> 821 <thead> 822 <tr> 823 <td class="text-left">{{ column_product }}</td> 824 <td class="text-left">{{ column_model }}</td> 825 <td class="text-right">{{ column_quantity }}</td> 826 <td class="text-right">{{ column_price }}</td> 827 <td class="text-right">{{ column_total }}</td> 828 </tr> 829 </thead> 830 <tbody id="total"> 831 <tr> 832 <td class="text-center" colspan="5">{{ text_no_results }}</td> 833 </tr> 834 </tbody> 835 </table> 836 </div> 837 <fieldset> 838 <legend>{{ text_order_detail }}</legend> 839 <div class="form-group required"> 840 <label class="col-sm-2 control-label" for="input-shipping-method">{{ entry_shipping_method }}</label> 841 <div class="col-sm-10"> 842 <div class="input-group"> 843 <select name="shipping_method" id="input-shipping-method" class="form-control"> 844 <option value="">{{ text_select }}</option> 845 {% if shipping_code %} 846 <option value="{{ shipping_code }}" selected="selected">{{ shipping_method }}</option> 847 {% endif %} 848 </select> 849 <span class="input-group-btn"> 850 <button type="button" id="button-shipping-method" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_apply }}</button> 851 </span></div> 852 </div> 853 </div> 854 <div class="form-group required"> 855 <label class="col-sm-2 control-label" for="input-payment-method">{{ entry_payment_method }}</label> 856 <div class="col-sm-10"> 857 <div class="input-group"> 858 <select name="payment_method" id="input-payment-method" class="form-control"> 859 <option value="">{{ text_select }}</option> 860 {% if payment_code %} 861 <option value="{{ payment_code }}" selected="selected">{{ payment_method }}</option> 862 {% endif %} 863 </select> 864 <span class="input-group-btn"> 865 <button type="button" id="button-payment-method" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_apply }}</button> 866 </span></div> 867 </div> 868 </div> 869 <div class="form-group"> 870 <label class="col-sm-2 control-label" for="input-coupon">{{ entry_coupon }}</label> 871 <div class="col-sm-10"> 872 <div class="input-group"> 873 <input type="text" name="coupon" value="{{ coupon }}" id="input-coupon" class="form-control" /> 874 <span class="input-group-btn"> 875 <button type="button" id="button-coupon" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_apply }}</button> 876 </span></div> 877 </div> 878 </div> 879 <div class="form-group"> 880 <label class="col-sm-2 control-label" for="input-voucher">{{ entry_voucher }}</label> 881 <div class="col-sm-10"> 882 <div class="input-group"> 883 <input type="text" name="voucher" value="{{ voucher }}" id="input-voucher" data-loading-text="{{ text_loading }}" class="form-control" /> 884 <span class="input-group-btn"> 885 <button type="button" id="button-voucher" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_apply }}</button> 886 </span></div> 887 </div> 888 </div> 889 <div class="form-group"> 890 <label class="col-sm-2 control-label" for="input-reward">{{ entry_reward }}</label> 891 <div class="col-sm-10"> 892 <div class="input-group"> 893 <input type="text" name="reward" value="{{ reward }}" id="input-reward" data-loading-text="{{ text_loading }}" class="form-control" /> 894 <span class="input-group-btn"> 895 <button type="button" id="button-reward" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_apply }}</button> 896 </span></div> 897 </div> 898 </div> 899 <div class="form-group"> 900 <label class="col-sm-2 control-label" for="input-order-status">{{ entry_order_status }}</label> 901 <div class="col-sm-10"> 902 <select name="order_status_id" id="input-order-status" class="form-control"> 903 {% for order_status in order_statuses %} 904 {% if order_status.order_status_id == order_status_id %} 905 <option value="{{ order_status.order_status_id }}" selected="selected">{{ order_status.name }}</option> 906 {% else %} 907 <option value="{{ order_status.order_status_id }}">{{ order_status.name }}</option> 908 {% endif %} 909 {% endfor %} 910 </select> 911 <input type="hidden" name="order_id" value="{{ order_id }}" /> 912 </div> 913 </div> 914 <div class="form-group"> 915 <label class="col-sm-2 control-label" for="input-comment">{{ entry_comment }}</label> 916 <div class="col-sm-10"> 917 <textarea name="comment" rows="5" id="input-comment" class="form-control">{{ comment }}</textarea> 918 </div> 919 </div> 920 <div class="form-group"> 921 <label class="col-sm-2 control-label" for="input-affiliate">{{ entry_affiliate }}</label> 922 <div class="col-sm-10"> 923 <input type="text" name="affiliate" value="{{ affiliate }}" id="input-affiliate" class="form-control" /> 924 <input type="hidden" name="affiliate_id" value="{{ affiliate_id }}" /> 925 </div> 926 </div> 927 </fieldset> 928 <div class="row"> 929 <div class="col-sm-6 text-left"> 930 <button type="button" onclick="$('select[name=\'shipping_method\']').prop('disabled') ? $('a[href=\'#tab-payment\']').tab('show') : $('a[href=\'#tab-shipping\']').tab('show');" class="btn btn-default"><i class="fa fa-arrow-left"></i> {{ button_back }}</button> 931 </div> 932 <div class="col-sm-6 text-right"> 933 <button type="button" id="button-refresh" data-toggle="tooltip" title="{{ button_refresh }}" data-loading-text="{{ text_loading }}" class="btn btn-warning"><i class="fa fa-refresh"></i></button> 934 <button type="button" id="button-save" class="btn btn-primary"><i class="fa fa-check-circle"></i> {{ button_save }}</button> 935 </div> 936 </div> 937 </div> 938 </div> 939 </form> 940 </div> 941 </div> 942 </div> 943 <script type="text/javascript"><!-- 944 // Disable the tabs 945 $('#order a[data-toggle=\'tab\']').on('click', function(e) { 946 return false; 947 }); 948 949 // Currency 950 $('select[name=\'currency\']').on('change', function() { 951 $.ajax({ 952 url: '{{ catalog }}index.php?route=api/currency&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 953 type: 'post', 954 data: 'currency=' + $('select[name=\'currency\'] option:selected').val(), 955 dataType: 'json', 956 crossDomain: true, 957 beforeSend: function() { 958 $('select[name=\'currency\']').prop('disabled', true); 959 }, 960 complete: function() { 961 $('select[name=\'currency\']').prop('disabled', false); 962 }, 963 success: function(json) { 964 $('.alert-dismissible, .text-danger').remove(); 965 $('.form-group').removeClass('has-error'); 966 967 if (json['error']) { 968 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 969 970 // Highlight any found errors 971 $('select[name=\'currency\']').closest('.form-group').addClass('has-error'); 972 } 973 }, 974 error: function(xhr, ajaxOptions, thrownError) { 975 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 976 } 977 }); 978 }); 979 980 $('select[name=\'currency\']').trigger('change'); 981 982 // Customer 983 $('input[name=\'customer\']').autocomplete({ 984 'source': function(request, response) { 985 $.ajax({ 986 url: 'index.php?route=customer/customer/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request), 987 dataType: 'json', 988 success: function(json) { 989 json.unshift({ 990 customer_id: '0', 991 customer_group_id: '{{ customer_group_id }}', 992 name: '{{ text_none }}', 993 customer_group: '', 994 firstname: '', 995 lastname: '', 996 email: '', 997 telephone: '', 998 custom_field: [], 999 address: [] 1000 }); 1001 1002 response($.map(json, function(item) { 1003 return { 1004 category: item['customer_group'], 1005 label: item['name'], 1006 value: item['customer_id'], 1007 customer_group_id: item['customer_group_id'], 1008 firstname: item['firstname'], 1009 lastname: item['lastname'], 1010 email: item['email'], 1011 telephone: item['telephone'], 1012 custom_field: item['custom_field'], 1013 address: item['address'] 1014 } 1015 })); 1016 } 1017 }); 1018 }, 1019 'select': function(item) { 1020 // Reset all custom fields 1021 $('#tab-customer input[type=\'text\'], #tab-customer textarea').not('#tab-customer input[name=\'customer\'], #tab-customer input[name=\'customer_id\']').val(''); 1022 $('#tab-customer select option').not($('#tab-customer select[name=\'store_id\'] option, #tab-customer select[name=\'currency\'] option')).removeAttr('selected'); 1023 $('#tab-customer input[type=\'checkbox\'], #tab-customer input[type=\'radio\']').removeAttr('checked'); 1024 1025 $('#tab-customer input[name=\'customer\']').val(item['label']); 1026 $('#tab-customer input[name=\'customer_id\']').val(item['value']); 1027 $('#tab-customer select[name=\'customer_group_id\']').val(item['customer_group_id']); 1028 $('#tab-customer input[name=\'firstname\']').val(item['firstname']); 1029 $('#tab-customer input[name=\'lastname\']').val(item['lastname']); 1030 $('#tab-customer input[name=\'email\']').val(item['email']); 1031 $('#tab-customer input[name=\'telephone\']').val(item['telephone']); 1032 1033 for (i in item.custom_field) { 1034 $('#tab-customer select[name=\'custom_field[' + i + ']\']').val(item.custom_field[i]); 1035 $('#tab-customer textarea[name=\'custom_field[' + i + ']\']').val(item.custom_field[i]); 1036 $('#tab-customer input[name^=\'custom_field[' + i + ']\'][type=\'text\']').val(item.custom_field[i]); 1037 $('#tab-customer input[name^=\'custom_field[' + i + ']\'][type=\'hidden\']').val(item.custom_field[i]); 1038 $('#tab-customer input[name^=\'custom_field[' + i + ']\'][type=\'radio\'][value=\'' + item.custom_field[i] + '\']').prop('checked', true); 1039 1040 if (item.custom_field[i] instanceof Array) { 1041 for (j = 0; j < item.custom_field[i].length; j++) { 1042 $('#tab-customer input[name^=\'custom_field[' + i + ']\'][type=\'checkbox\'][value=\'' + item.custom_field[i][j] + '\']').prop('checked', true); 1043 } 1044 } 1045 } 1046 1047 $('select[name=\'customer_group_id\']').trigger('change'); 1048 1049 html = '<option value="0">{{ text_none }}</option>'; 1050 1051 for (i in item['address']) { 1052 html += '<option value="' + item['address'][i]['address_id'] + '">' + item['address'][i]['firstname'] + ' ' + item['address'][i]['lastname'] + ', ' + item['address'][i]['address_1'] + ', ' + item['address'][i]['city'] + ', ' + item['address'][i]['country'] + '</option>'; 1053 } 1054 1055 $('select[name=\'payment_address\']').html(html); 1056 $('select[name=\'shipping_address\']').html(html); 1057 } 1058 }); 1059 1060 // Custom Fields 1061 $('select[name=\'customer_group_id\']').on('change', function() { 1062 $.ajax({ 1063 url: 'index.php?route=customer/customer/customfield&user_token={{ user_token }}&customer_group_id=' + this.value, 1064 dataType: 'json', 1065 success: function(json) { 1066 $('.custom-field').hide(); 1067 $('.custom-field').removeClass('required'); 1068 1069 for (i = 0; i < json.length; i++) { 1070 custom_field = json[i]; 1071 1072 $('.custom-field' + custom_field['custom_field_id']).show(); 1073 1074 if (custom_field['required']) { 1075 $('.custom-field' + custom_field['custom_field_id']).addClass('required'); 1076 } 1077 } 1078 }, 1079 error: function(xhr, ajaxOptions, thrownError) { 1080 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1081 } 1082 }); 1083 }); 1084 1085 $('select[name=\'customer_group_id\']').trigger('change'); 1086 1087 $('#button-customer').on('click', function() { 1088 $.ajax({ 1089 url: '{{ catalog }}index.php?route=api/customer&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1090 type: 'post', 1091 data: $('#tab-customer input[type=\'text\'], #tab-customer input[type=\'hidden\'], #tab-customer input[type=\'radio\']:checked, #tab-customer input[type=\'checkbox\']:checked, #tab-customer select, #tab-customer textarea'), 1092 dataType: 'json', 1093 crossDomain: true, 1094 beforeSend: function() { 1095 $('#button-customer').button('loading'); 1096 }, 1097 complete: function() { 1098 $('#button-customer').button('reset'); 1099 }, 1100 success: function(json) { 1101 $('.alert-dismissible, .text-danger').remove(); 1102 $('.form-group').removeClass('has-error'); 1103 1104 if (json['error']) { 1105 if (json['error']['warning']) { 1106 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1107 } 1108 1109 for (i in json['error']) { 1110 var element = $('#input-' + i.replace('_', '-')); 1111 1112 if (element.parent().hasClass('input-group')) { 1113 $(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>'); 1114 } else { 1115 $(element).after('<div class="text-danger">' + json['error'][i] + '</div>'); 1116 } 1117 } 1118 1119 // Highlight any found errors 1120 $('.text-danger').parentsUntil('.form-group').parent().addClass('has-error'); 1121 } else { 1122 // Refresh products, vouchers and totals 1123 var request_1 = $.ajax({ 1124 url: '{{ catalog }}index.php?route=api/cart/add&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1125 type: 'post', 1126 data: $('#cart input[name^=\'product\'][type=\'text\'], #cart input[name^=\'product\'][type=\'hidden\'], #cart input[name^=\'product\'][type=\'radio\']:checked, #cart input[name^=\'product\'][type=\'checkbox\']:checked, #cart select[name^=\'product\'], #cart textarea[name^=\'product\']'), 1127 dataType: 'json', 1128 crossDomain: true, 1129 beforeSend: function() { 1130 $('#button-product-add').button('loading'); 1131 }, 1132 complete: function() { 1133 $('#button-product-add').button('reset'); 1134 }, 1135 success: function(json) { 1136 $('.alert-dismissible, .text-danger').remove(); 1137 $('.form-group').removeClass('has-error'); 1138 1139 if (json['error'] && json['error']['warning']) { 1140 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1141 } 1142 }, 1143 error: function(xhr, ajaxOptions, thrownError) { 1144 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1145 } 1146 }); 1147 1148 var request_2 = request_1.then(function() { 1149 $.ajax({ 1150 url: '{{ catalog }}index.php?route=api/voucher/add&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1151 type: 'post', 1152 data: $('#cart input[name^=\'voucher\'][type=\'text\'], #cart input[name^=\'voucher\'][type=\'hidden\'], #cart input[name^=\'voucher\'][type=\'radio\']:checked, #cart input[name^=\'voucher\'][type=\'checkbox\']:checked, #cart select[name^=\'voucher\'], #cart textarea[name^=\'voucher\']'), 1153 dataType: 'json', 1154 crossDomain: true, 1155 beforeSend: function() { 1156 $('#button-voucher-add').button('loading'); 1157 }, 1158 complete: function() { 1159 $('#button-voucher-add').button('reset'); 1160 }, 1161 success: function(json) { 1162 $('.alert-dismissible, .text-danger').remove(); 1163 $('.form-group').removeClass('has-error'); 1164 1165 if (json['error'] && json['error']['warning']) { 1166 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1167 } 1168 }, 1169 error: function(xhr, ajaxOptions, thrownError) { 1170 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1171 } 1172 }); 1173 }); 1174 1175 request_2.done(function() { 1176 $('#button-refresh').trigger('click'); 1177 1178 $('a[href=\'#tab-cart\']').tab('show'); 1179 }); 1180 } 1181 }, 1182 error: function(xhr, ajaxOptions, thrownError) { 1183 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1184 } 1185 }); 1186 }); 1187 1188 $('#tab-product input[name=\'product\']').autocomplete({ 1189 'source': function(request, response) { 1190 $.ajax({ 1191 url: 'index.php?route=catalog/product/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request), 1192 dataType: 'json', 1193 success: function(json) { 1194 response($.map(json, function(item) { 1195 return { 1196 label: item['name'], 1197 value: item['product_id'], 1198 model: item['model'], 1199 option: item['option'], 1200 price: item['price'] 1201 } 1202 })); 1203 } 1204 }); 1205 }, 1206 'select': function(item) { 1207 $('#tab-product input[name=\'product\']').val(item['label']); 1208 $('#tab-product input[name=\'product_id\']').val(item['value']); 1209 1210 if (item['option'] != '') { 1211 html = '<fieldset>'; 1212 html += ' <legend>{{ entry_option }}</legend>'; 1213 1214 for (i = 0; i < item['option'].length; i++) { 1215 option = item['option'][i]; 1216 1217 if (option['type'] == 'select') { 1218 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1219 html += ' <label class="col-sm-2 control-label" for="input-option' + option['product_option_id'] + '">' + option['name'] + '</label>'; 1220 html += ' <div class="col-sm-10">'; 1221 html += ' <select name="option[' + option['product_option_id'] + ']" id="input-option' + option['product_option_id'] + '" class="form-control">'; 1222 html += ' <option value="">{{ text_select }}</option>'; 1223 1224 for (j = 0; j < option['product_option_value'].length; j++) { 1225 option_value = option['product_option_value'][j]; 1226 1227 html += '<option value="' + option_value['product_option_value_id'] + '">' + option_value['name']; 1228 1229 if (option_value['price']) { 1230 html += ' (' + option_value['price_prefix'] + option_value['price'] + ')'; 1231 } 1232 1233 html += '</option>'; 1234 } 1235 1236 html += ' </select>'; 1237 html += ' </div>'; 1238 html += '</div>'; 1239 } 1240 1241 if (option['type'] == 'radio') { 1242 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1243 html += ' <label class="col-sm-2 control-label" for="input-option' + option['product_option_id'] + '">' + option['name'] + '</label>'; 1244 html += ' <div class="col-sm-10">'; 1245 html += ' <select name="option[' + option['product_option_id'] + ']" id="input-option' + option['product_option_id'] + '" class="form-control">'; 1246 html += ' <option value="">{{ text_select }}</option>'; 1247 1248 for (j = 0; j < option['product_option_value'].length; j++) { 1249 option_value = option['product_option_value'][j]; 1250 1251 html += '<option value="' + option_value['product_option_value_id'] + '">' + option_value['name']; 1252 1253 if (option_value['price']) { 1254 html += ' (' + option_value['price_prefix'] + option_value['price'] + ')'; 1255 } 1256 1257 html += '</option>'; 1258 } 1259 1260 html += ' </select>'; 1261 html += ' </div>'; 1262 html += '</div>'; 1263 } 1264 1265 if (option['type'] == 'checkbox') { 1266 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1267 html += ' <label class="col-sm-2 control-label">' + option['name'] + '</label>'; 1268 html += ' <div class="col-sm-10">'; 1269 html += ' <div id="input-option' + option['product_option_id'] + '">'; 1270 1271 for (j = 0; j < option['product_option_value'].length; j++) { 1272 option_value = option['product_option_value'][j]; 1273 1274 html += '<div class="checkbox">'; 1275 1276 html += ' <label><input type="checkbox" name="option[' + option['product_option_id'] + '][]" value="' + option_value['product_option_value_id'] + '" /> ' + option_value['name']; 1277 1278 if (option_value['price']) { 1279 html += ' (' + option_value['price_prefix'] + option_value['price'] + ')'; 1280 } 1281 1282 html += ' </label>'; 1283 html += '</div>'; 1284 } 1285 1286 html += ' </div>'; 1287 html += ' </div>'; 1288 html += '</div>'; 1289 } 1290 1291 if (option['type'] == 'image') { 1292 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1293 html += ' <label class="col-sm-2 control-label" for="input-option' + option['product_option_id'] + '">' + option['name'] + '</label>'; 1294 html += ' <div class="col-sm-10">'; 1295 html += ' <select name="option[' + option['product_option_id'] + ']" id="input-option' + option['product_option_id'] + '" class="form-control">'; 1296 html += ' <option value="">{{ text_select }}</option>'; 1297 1298 for (j = 0; j < option['product_option_value'].length; j++) { 1299 option_value = option['product_option_value'][j]; 1300 1301 html += '<option value="' + option_value['product_option_value_id'] + '">' + option_value['name']; 1302 1303 if (option_value['price']) { 1304 html += ' (' + option_value['price_prefix'] + option_value['price'] + ')'; 1305 } 1306 1307 html += '</option>'; 1308 } 1309 1310 html += ' </select>'; 1311 html += ' </div>'; 1312 html += '</div>'; 1313 } 1314 1315 if (option['type'] == 'text') { 1316 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1317 html += ' <label class="col-sm-2 control-label" for="input-option' + option['product_option_id'] + '">' + option['name'] + '</label>'; 1318 html += ' <div class="col-sm-10"><input type="text" name="option[' + option['product_option_id'] + ']" value="' + option['value'] + '" id="input-option' + option['product_option_id'] + '" class="form-control" /></div>'; 1319 html += '</div>'; 1320 } 1321 1322 if (option['type'] == 'textarea') { 1323 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1324 html += ' <label class="col-sm-2 control-label" for="input-option' + option['product_option_id'] + '">' + option['name'] + '</label>'; 1325 html += ' <div class="col-sm-10"><textarea name="option[' + option['product_option_id'] + ']" rows="5" id="input-option' + option['product_option_id'] + '" class="form-control">' + option['value'] + '</textarea></div>'; 1326 html += '</div>'; 1327 } 1328 1329 if (option['type'] == 'file') { 1330 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1331 html += ' <label class="col-sm-2 control-label">' + option['name'] + '</label>'; 1332 html += ' <div class="col-sm-10">'; 1333 html += ' <button type="button" id="button-upload' + option['product_option_id'] + '" data-loading-text="{{ text_loading }}" class="btn btn-default"><i class="fa fa-upload"></i> {{ button_upload }}</button>'; 1334 html += ' <input type="hidden" name="option[' + option['product_option_id'] + ']" value="' + option['value'] + '" id="input-option' + option['product_option_id'] + '" />'; 1335 html += ' </div>'; 1336 html += '</div>'; 1337 } 1338 1339 if (option['type'] == 'date') { 1340 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1341 html += ' <label class="col-sm-2 control-label" for="input-option' + option['product_option_id'] + '">' + option['name'] + '</label>'; 1342 html += ' <div class="col-sm-3"><div class="input-group date"><input type="text" name="option[' + option['product_option_id'] + ']" value="' + option['value'] + '" placeholder="' + option['name'] + '" data-date-format="YYYY-MM-DD" id="input-option' + option['product_option_id'] + '" class="form-control" /><span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span></div></div>'; 1343 html += '</div>'; 1344 } 1345 1346 if (option['type'] == 'datetime') { 1347 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1348 html += ' <label class="col-sm-2 control-label" for="input-option' + option['product_option_id'] + '">' + option['name'] + '</label>'; 1349 html += ' <div class="col-sm-3"><div class="input-group datetime"><input type="text" name="option[' + option['product_option_id'] + ']" value="' + option['value'] + '" placeholder="' + option['name'] + '" data-date-format="YYYY-MM-DD HH:mm" id="input-option' + option['product_option_id'] + '" class="form-control" /><span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span></div></div>'; 1350 html += '</div>'; 1351 } 1352 1353 if (option['type'] == 'time') { 1354 html += '<div class="form-group' + (option['required'] ? ' required' : '') + '">'; 1355 html += ' <label class="col-sm-2 control-label" for="input-option' + option['product_option_id'] + '">' + option['name'] + '</label>'; 1356 html += ' <div class="col-sm-3"><div class="input-group time"><input type="text" name="option[' + option['product_option_id'] + ']" value="' + option['value'] + '" placeholder="' + option['name'] + '" data-date-format="HH:mm" id="input-option' + option['product_option_id'] + '" class="form-control" /><span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span></div></div>'; 1357 html += '</div>'; 1358 } 1359 } 1360 1361 html += '</fieldset>'; 1362 1363 $('#option').html(html); 1364 1365 $('.date').datetimepicker({ 1366 language: '{{ datepicker }}', 1367 pickTime: false 1368 }); 1369 1370 $('.datetime').datetimepicker({ 1371 language: '{{ datepicker }}', 1372 pickDate: true, 1373 pickTime: true 1374 }); 1375 1376 $('.time').datetimepicker({ 1377 language: '{{ datepicker }}', 1378 pickDate: false 1379 }); 1380 } else { 1381 $('#option').html(''); 1382 } 1383 } 1384 }); 1385 1386 $('#button-product-add').on('click', function() { 1387 $.ajax({ 1388 url: '{{ catalog }}index.php?route=api/cart/add&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1389 type: 'post', 1390 data: $('#tab-product input[name=\'product_id\'], #tab-product input[name=\'quantity\'], #tab-product input[name^=\'option\'][type=\'text\'], #tab-product input[name^=\'option\'][type=\'hidden\'], #tab-product input[name^=\'option\'][type=\'radio\']:checked, #tab-product input[name^=\'option\'][type=\'checkbox\']:checked, #tab-product select[name^=\'option\'], #tab-product textarea[name^=\'option\']'), 1391 dataType: 'json', 1392 crossDomain: true, 1393 beforeSend: function() { 1394 $('#button-product-add').button('loading'); 1395 }, 1396 complete: function() { 1397 $('#button-product-add').button('reset'); 1398 }, 1399 success: function(json) { 1400 $('.alert-dismissible, .text-danger').remove(); 1401 $('.form-group').removeClass('has-error'); 1402 1403 if (json['error']) { 1404 if (json['error']['warning']) { 1405 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1406 } 1407 1408 if (json['error']['option']) { 1409 for (i in json['error']['option']) { 1410 var element = $('#input-option' + i.replace('_', '-')); 1411 1412 if (element.parent().hasClass('input-group')) { 1413 $(element).parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); 1414 } else { 1415 $(element).after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); 1416 } 1417 } 1418 } 1419 1420 if (json['error']['store']) { 1421 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['store'] + '</div>'); 1422 } 1423 1424 // Highlight any found errors 1425 $('.text-danger').parentsUntil('.form-group').parent().addClass('has-error'); 1426 } else { 1427 // Refresh products, vouchers and totals 1428 $('#button-refresh').trigger('click'); 1429 } 1430 }, 1431 error: function(xhr, ajaxOptions, thrownError) { 1432 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1433 } 1434 }); 1435 }); 1436 1437 // Voucher 1438 $('#button-voucher-add').on('click', function() { 1439 $.ajax({ 1440 url: '{{ catalog }}index.php?route=api/voucher/add&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1441 type: 'post', 1442 data: $('#tab-voucher input[type=\'text\'], #tab-voucher input[type=\'hidden\'], #tab-voucher input[type=\'radio\']:checked, #tab-voucher input[type=\'checkbox\']:checked, #tab-voucher select, #tab-voucher textarea'), 1443 dataType: 'json', 1444 crossDomain: true, 1445 beforeSend: function() { 1446 $('#button-voucher-add').button('loading'); 1447 }, 1448 complete: function() { 1449 $('#button-voucher-add').button('reset'); 1450 }, 1451 success: function(json) { 1452 $('.alert-dismissible, .text-danger').remove(); 1453 $('.form-group').removeClass('has-error'); 1454 1455 if (json['error']) { 1456 if (json['error']['warning']) { 1457 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1458 } 1459 1460 for (i in json['error']) { 1461 var element = $('#input-' + i.replace('_', '-')); 1462 1463 if (element.parent().hasClass('input-group')) { 1464 $(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>'); 1465 } else { 1466 $(element).after('<div class="text-danger">' + json['error'][i] + '</div>'); 1467 } 1468 } 1469 1470 // Highlight any found errors 1471 $('.text-danger').parentsUntil('.form-group').parent().addClass('has-error'); 1472 } else { 1473 $('input[name=\'from_name\']').val(''); 1474 $('input[name=\'from_email\']').val(''); 1475 $('input[name=\'to_name\']').val(''); 1476 $('input[name=\'to_email\']').val(''); 1477 $('textarea[name=\'message\']').val(''); 1478 $('input[name=\'amount\']').val('{{ voucher_min|escape('js') }}'); 1479 1480 // Refresh products, vouchers and totals 1481 $('#button-refresh').trigger('click'); 1482 } 1483 }, 1484 error: function(xhr, ajaxOptions, thrownError) { 1485 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1486 } 1487 }); 1488 }); 1489 1490 $('#cart').delegate('.btn-danger', 'click', function() { 1491 var node = this; 1492 1493 $.ajax({ 1494 url: '{{ catalog }}index.php?route=api/cart/remove&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1495 type: 'post', 1496 data: 'key=' + encodeURIComponent(this.value), 1497 dataType: 'json', 1498 crossDomain: true, 1499 beforeSend: function() { 1500 $(node).button('loading'); 1501 }, 1502 complete: function() { 1503 $(node).button('reset'); 1504 }, 1505 success: function(json) { 1506 $('.alert-dismissible, .text-danger').remove(); 1507 1508 // Check for errors 1509 if (json['error']) { 1510 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1511 } else { 1512 // Refresh products, vouchers and totals 1513 $('#button-refresh').trigger('click'); 1514 } 1515 }, 1516 error: function(xhr, ajaxOptions, thrownError) { 1517 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1518 } 1519 }); 1520 }); 1521 1522 $('#cart').delegate('.btn-primary', 'click', function() { 1523 var node = this; 1524 1525 // Refresh products, vouchers and totals 1526 $.ajax({ 1527 url: '{{ catalog }}index.php?route=api/cart/add&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1528 type: 'post', 1529 data: $('#cart input[name^=\'product\'][type=\'text\'], #cart input[name^=\'product\'][type=\'hidden\'], #cart input[name^=\'product\'][type=\'radio\']:checked, #cart input[name^=\'product\'][type=\'checkbox\']:checked, #cart select[name^=\'product\'], #cart textarea[name^=\'product\']'), 1530 dataType: 'json', 1531 crossDomain: true, 1532 beforeSend: function() { 1533 $(node).button('loading'); 1534 }, 1535 complete: function() { 1536 $(node).button('reset'); 1537 }, 1538 success: function(json) { 1539 $('.alert-dismissible, .text-danger').remove(); 1540 $('.form-group').removeClass('has-error'); 1541 1542 if (json['error'] && json['error']['warning']) { 1543 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1544 } 1545 1546 if (json['success']) { 1547 $('#content > .container-fluid').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1548 } 1549 }, 1550 error: function(xhr, ajaxOptions, thrownError) { 1551 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1552 } 1553 }).done(function() { 1554 $('#button-refresh').trigger('click'); 1555 }); 1556 }); 1557 1558 $('#button-cart').on('click', function() { 1559 $('a[href=\'#tab-payment\']').tab('show'); 1560 }); 1561 1562 // Payment Address 1563 $('select[name=\'payment_address\']').on('change', function() { 1564 $.ajax({ 1565 url: 'index.php?route=customer/customer/address&user_token={{ user_token }}&address_id=' + this.value, 1566 dataType: 'json', 1567 beforeSend: function() { 1568 $('select[name=\'payment_address\']').prop('disabled', true); 1569 }, 1570 complete: function() { 1571 $('select[name=\'payment_address\']').prop('disabled', false); 1572 }, 1573 success: function(json) { 1574 // Reset all fields 1575 $('#tab-payment input[type=\'text\'], #tab-payment input[type=\'text\'], #tab-payment textarea').val(''); 1576 $('#tab-payment select option').not('#tab-payment select[name=\'payment_address\']').removeAttr('selected'); 1577 $('#tab-payment input[type=\'checkbox\'], #tab-payment input[type=\'radio\']').removeAttr('checked'); 1578 1579 $('#tab-payment input[name=\'firstname\']').val(json['firstname']); 1580 $('#tab-payment input[name=\'lastname\']').val(json['lastname']); 1581 $('#tab-payment input[name=\'company\']').val(json['company']); 1582 $('#tab-payment input[name=\'address_1\']').val(json['address_1']); 1583 $('#tab-payment input[name=\'address_2\']').val(json['address_2']); 1584 $('#tab-payment input[name=\'city\']').val(json['city']); 1585 $('#tab-payment input[name=\'postcode\']').val(json['postcode']); 1586 $('#tab-payment select[name=\'country_id\']').val(json['country_id']); 1587 1588 payment_zone_id = json['zone_id']; 1589 1590 for (i in json['custom_field']) { 1591 $('#tab-payment select[name=\'custom_field[' + i + ']\']').val(json['custom_field'][i]); 1592 $('#tab-payment textarea[name=\'custom_field[' + i + ']\']').val(json['custom_field'][i]); 1593 $('#tab-payment input[name^=\'custom_field[' + i + ']\'][type=\'text\']').val(json['custom_field'][i]); 1594 $('#tab-payment input[name^=\'custom_field[' + i + ']\'][type=\'hidden\']').val(json['custom_field'][i]); 1595 $('#tab-payment input[name^=\'custom_field[' + i + ']\'][type=\'radio\'][value=\'' + json['custom_field'][i] + '\']').prop('checked', true); 1596 $('#tab-payment input[name^=\'custom_field[' + i + ']\'][type=\'checkbox\'][value=\'' + json['custom_field'][i] + '\']').prop('checked', true); 1597 1598 if (json['custom_field'][i] instanceof Array) { 1599 for (j = 0; j < json['custom_field'][i].length; j++) { 1600 $('#tab-payment input[name^=\'custom_field[' + i + ']\'][type=\'checkbox\'][value=\'' + json['custom_field'][i][j] + '\']').prop('checked', true); 1601 } 1602 } 1603 } 1604 1605 $('#tab-payment select[name=\'country_id\']').trigger('change'); 1606 }, 1607 error: function(xhr, ajaxOptions, thrownError) { 1608 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1609 } 1610 }); 1611 }); 1612 1613 var payment_zone_id = '{{ payment_zone_id }}'; 1614 1615 $('#tab-payment select[name=\'country_id\']').on('change', function() { 1616 $.ajax({ 1617 url: 'index.php?route=localisation/country/country&user_token={{ user_token }}&country_id=' + this.value, 1618 dataType: 'json', 1619 beforeSend: function() { 1620 $('#tab-payment select[name=\'country_id\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>'); 1621 }, 1622 complete: function() { 1623 $('#tab-payment .fa-spin').remove(); 1624 }, 1625 success: function(json) { 1626 if (json['postcode_required'] == '1') { 1627 $('#tab-payment input[name=\'postcode\']').closest('.form-group').addClass('required'); 1628 } else { 1629 $('#tab-payment input[name=\'postcode\']').closest('.form-group').removeClass('required'); 1630 } 1631 1632 html = '<option value="">{{ text_select }}</option>'; 1633 1634 if (json['zone'] && json['zone'] != '') { 1635 for (i = 0; i < json['zone'].length; i++) { 1636 html += '<option value="' + json['zone'][i]['zone_id'] + '"'; 1637 1638 if (json['zone'][i]['zone_id'] == payment_zone_id) { 1639 html += ' selected="selected"'; 1640 } 1641 1642 html += '>' + json['zone'][i]['name'] + '</option>'; 1643 } 1644 } else { 1645 html += '<option value="0" selected="selected">{{ text_none }}</option>'; 1646 } 1647 1648 $('#tab-payment select[name=\'zone_id\']').html(html); 1649 }, 1650 error: function(xhr, ajaxOptions, thrownError) { 1651 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1652 } 1653 }); 1654 }); 1655 1656 $('#tab-payment select[name=\'country_id\']').trigger('change'); 1657 1658 $('#button-payment-address').on('click', function() { 1659 $.ajax({ 1660 url: '{{ catalog }}index.php?route=api/payment/address&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1661 type: 'post', 1662 data: $('#tab-payment input[type=\'text\'], #tab-payment input[type=\'hidden\'], #tab-payment input[type=\'radio\']:checked, #tab-payment input[type=\'checkbox\']:checked, #tab-payment select, #tab-payment textarea'), 1663 dataType: 'json', 1664 crossDomain: true, 1665 beforeSend: function() { 1666 $('#button-payment-address').button('loading'); 1667 }, 1668 complete: function() { 1669 $('#button-payment-address').button('reset'); 1670 }, 1671 success: function(json) { 1672 $('.alert-dismissible, .text-danger').remove(); 1673 $('.form-group').removeClass('has-error'); 1674 1675 // Check for errors 1676 if (json['error']) { 1677 if (json['error']['warning']) { 1678 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1679 } 1680 1681 for (i in json['error']) { 1682 var element = $('#input-payment-' + i.replace('_', '-')); 1683 1684 if ($(element).parent().hasClass('input-group')) { 1685 $(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>'); 1686 } else { 1687 $(element).after('<div class="text-danger">' + json['error'][i] + '</div>'); 1688 } 1689 } 1690 1691 // Highlight any found errors 1692 $('.text-danger').parentsUntil('.form-group').parent().addClass('has-error'); 1693 } else { 1694 // Payment Methods 1695 $.ajax({ 1696 url: '{{ catalog }}index.php?route=api/payment/methods&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1697 dataType: 'json', 1698 crossDomain: true, 1699 beforeSend: function() { 1700 $('#button-payment-address').button('loading'); 1701 }, 1702 complete: function() { 1703 $('#button-payment-address').button('reset'); 1704 }, 1705 success: function(json) { 1706 if (json['error']) { 1707 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1708 } else { 1709 html = '<option value="">{{ text_select }}</option>'; 1710 1711 if (json['payment_methods']) { 1712 for (i in json['payment_methods']) { 1713 if (json['payment_methods'][i]['code'] == $('select[name=\'payment_method\'] option:selected').val()) { 1714 html += '<option value="' + json['payment_methods'][i]['code'] + '" selected="selected">' + json['payment_methods'][i]['title'] + '</option>'; 1715 } else { 1716 html += '<option value="' + json['payment_methods'][i]['code'] + '">' + json['payment_methods'][i]['title'] + '</option>'; 1717 } 1718 } 1719 } 1720 1721 $('select[name=\'payment_method\']').html(html); 1722 } 1723 }, 1724 error: function(xhr, ajaxOptions, thrownError) { 1725 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1726 } 1727 }).done(function() { 1728 // Refresh products, vouchers and totals 1729 $('#button-refresh').trigger('click'); 1730 1731 // If shipping required got to shipping tab else total tabs 1732 if ($('select[name=\'shipping_method\']').prop('disabled')) { 1733 $('a[href=\'#tab-total\']').tab('show'); 1734 } else { 1735 $('a[href=\'#tab-shipping\']').tab('show'); 1736 } 1737 }); 1738 } 1739 }, 1740 error: function(xhr, ajaxOptions, thrownError) { 1741 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1742 } 1743 }); 1744 }); 1745 1746 // Shipping Address 1747 $('select[name=\'shipping_address\']').on('change', function() { 1748 $.ajax({ 1749 url: 'index.php?route=customer/customer/address&user_token={{ user_token }}&address_id=' + this.value, 1750 dataType: 'json', 1751 beforeSend: function() { 1752 $('select[name=\'shipping_address\']').prop('disabled', true); 1753 }, 1754 complete: function() { 1755 $('select[name=\'shipping_address\']').prop('disabled', false); 1756 }, 1757 success: function(json) { 1758 // Reset all fields 1759 $('#tab-shipping input[type=\'text\'], #tab-shipping input[type=\'text\'], #tab-shipping textarea').val(''); 1760 $('#tab-shipping select option').not('#tab-shipping select[name=\'shipping_address\']').removeAttr('selected'); 1761 $('#tab-shipping input[type=\'checkbox\'], #tab-shipping input[type=\'radio\']').removeAttr('checked'); 1762 1763 $('#tab-shipping input[name=\'firstname\']').val(json['firstname']); 1764 $('#tab-shipping input[name=\'lastname\']').val(json['lastname']); 1765 $('#tab-shipping input[name=\'company\']').val(json['company']); 1766 $('#tab-shipping input[name=\'address_1\']').val(json['address_1']); 1767 $('#tab-shipping input[name=\'address_2\']').val(json['address_2']); 1768 $('#tab-shipping input[name=\'city\']').val(json['city']); 1769 $('#tab-shipping input[name=\'postcode\']').val(json['postcode']); 1770 $('#tab-shipping select[name=\'country_id\']').val(json['country_id']); 1771 1772 shipping_zone_id = json['zone_id']; 1773 1774 for (i in json['custom_field']) { 1775 $('#tab-shipping select[name=\'custom_field[' + i + ']\']').val(json['custom_field'][i]); 1776 $('#tab-shipping textarea[name=\'custom_field[' + i + ']\']').val(json['custom_field'][i]); 1777 $('#tab-shipping input[name^=\'custom_field[' + i + ']\'][type=\'text\']').val(json['custom_field'][i]); 1778 $('#tab-shipping input[name^=\'custom_field[' + i + ']\'][type=\'hidden\']').val(json['custom_field'][i]); 1779 $('#tab-shipping input[name^=\'custom_field[' + i + ']\'][type=\'radio\'][value=\'' + json['custom_field'][i] + '\']').prop('checked', true); 1780 $('#tab-shipping input[name^=\'custom_field[' + i + ']\'][type=\'checkbox\'][value=\'' + json['custom_field'][i] + '\']').prop('checked', true); 1781 1782 if (json['custom_field'][i] instanceof Array) { 1783 for (j = 0; j < json['custom_field'][i].length; j++) { 1784 $('#tab-shipping input[name^=\'custom_field[' + i + ']\'][type=\'checkbox\'][value=\'' + json['custom_field'][i][j] + '\']').prop('checked', true); 1785 } 1786 } 1787 } 1788 1789 $('#tab-shipping select[name=\'country_id\']').trigger('change'); 1790 }, 1791 error: function(xhr, ajaxOptions, thrownError) { 1792 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1793 } 1794 }); 1795 }); 1796 1797 var shipping_zone_id = '{{ shipping_zone_id }}'; 1798 1799 $('#tab-shipping select[name=\'country_id\']').on('change', function() { 1800 $.ajax({ 1801 url: 'index.php?route=localisation/country/country&user_token={{ user_token }}&country_id=' + this.value, 1802 dataType: 'json', 1803 beforeSend: function() { 1804 $('#tab-shipping select[name=\'country_id\']').prop('disabled', true); 1805 }, 1806 complete: function() { 1807 $('#tab-shipping select[name=\'country_id\']').prop('disabled', false); 1808 }, 1809 success: function(json) { 1810 if (json['postcode_required'] == '1') { 1811 $('#tab-shipping input[name=\'postcode\']').closest('.form-group').addClass('required'); 1812 } else { 1813 $('#tab-shipping input[name=\'postcode\']').closest('.form-group').removeClass('required'); 1814 } 1815 1816 html = '<option value="">{{ text_select }}</option>'; 1817 1818 if (json['zone'] && json['zone'] != '') { 1819 for (i = 0; i < json['zone'].length; i++) { 1820 html += '<option value="' + json['zone'][i]['zone_id'] + '"'; 1821 1822 if (json['zone'][i]['zone_id'] == shipping_zone_id) { 1823 html += ' selected="selected"'; 1824 } 1825 1826 html += '>' + json['zone'][i]['name'] + '</option>'; 1827 } 1828 } else { 1829 html += '<option value="0" selected="selected">{{ text_none }}</option>'; 1830 } 1831 1832 $('#tab-shipping select[name=\'zone_id\']').html(html); 1833 }, 1834 error: function(xhr, ajaxOptions, thrownError) { 1835 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1836 } 1837 }); 1838 }); 1839 1840 $('#tab-shipping select[name=\'country_id\']').trigger('change'); 1841 1842 $('#button-shipping-address').on('click', function() { 1843 $.ajax({ 1844 url: '{{ catalog }}index.php?route=api/shipping/address&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1845 type: 'post', 1846 data: $('#tab-shipping input[type=\'text\'], #tab-shipping input[type=\'hidden\'], #tab-shipping input[type=\'radio\']:checked, #tab-shipping input[type=\'checkbox\']:checked, #tab-shipping select, #tab-shipping textarea'), 1847 dataType: 'json', 1848 crossDomain: true, 1849 beforeSend: function() { 1850 $('#button-shipping-address').button('loading'); 1851 }, 1852 complete: function() { 1853 $('#button-shipping-address').button('reset'); 1854 }, 1855 success: function(json) { 1856 $('.alert-dismissible, .text-danger').remove(); 1857 $('.form-group').removeClass('has-error'); 1858 1859 // Check for errors 1860 if (json['error']) { 1861 if (json['error']['warning']) { 1862 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1863 } 1864 1865 for (i in json['error']) { 1866 var element = $('#input-shipping-' + i.replace('_', '-')); 1867 1868 if ($(element).parent().hasClass('input-group')) { 1869 $(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>'); 1870 } else { 1871 $(element).after('<div class="text-danger">' + json['error'][i] + '</div>'); 1872 } 1873 } 1874 1875 // Highlight any found errors 1876 $('.text-danger').parentsUntil('.form-group').parent().addClass('has-error'); 1877 } else { 1878 // Shipping Methods 1879 var request = $.ajax({ 1880 url: '{{ catalog }}index.php?route=api/shipping/methods&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1881 dataType: 'json', 1882 beforeSend: function() { 1883 $('#button-shipping-address').button('loading'); 1884 }, 1885 complete: function() { 1886 $('#button-shipping-address').button('reset'); 1887 }, 1888 success: function(json) { 1889 if (json['error']) { 1890 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1891 } else { 1892 // Shipping Methods 1893 html = '<option value="">{{ text_select }}</option>'; 1894 1895 if (json['shipping_methods']) { 1896 for (i in json['shipping_methods']) { 1897 html += '<optgroup label="' + json['shipping_methods'][i]['title'] + '">'; 1898 1899 if (!json['shipping_methods'][i]['error']) { 1900 for (j in json['shipping_methods'][i]['quote']) { 1901 if (json['shipping_methods'][i]['quote'][j]['code'] == $('select[name=\'shipping_method\'] option:selected').val()) { 1902 html += '<option value="' + json['shipping_methods'][i]['quote'][j]['code'] + '" selected="selected">' + json['shipping_methods'][i]['quote'][j]['title'] + ' - ' + json['shipping_methods'][i]['quote'][j]['text'] + '</option>'; 1903 } else { 1904 html += '<option value="' + json['shipping_methods'][i]['quote'][j]['code'] + '">' + json['shipping_methods'][i]['quote'][j]['title'] + ' - ' + json['shipping_methods'][i]['quote'][j]['text'] + '</option>'; 1905 } 1906 } 1907 } else { 1908 html += '<option value="" style="color: #F00;" disabled="disabled">' + json['shipping_method'][i]['error'] + '</option>'; 1909 } 1910 1911 html += '</optgroup>'; 1912 } 1913 } 1914 1915 $('select[name=\'shipping_method\']').html(html); 1916 } 1917 }, 1918 error: function(xhr, ajaxOptions, thrownError) { 1919 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1920 } 1921 }).done(function() { 1922 // Refresh products, vouchers and totals 1923 $('#button-refresh').trigger('click'); 1924 1925 $('a[href=\'#tab-total\']').tab('show'); 1926 }); 1927 } 1928 }, 1929 error: function(xhr, ajaxOptions, thrownError) { 1930 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1931 } 1932 }); 1933 }); 1934 1935 // Shipping Method 1936 $('#button-shipping-method').on('click', function() { 1937 $.ajax({ 1938 url: '{{ catalog }}index.php?route=api/shipping/method&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1939 type: 'post', 1940 data: 'shipping_method=' + $('select[name=\'shipping_method\'] option:selected').val(), 1941 dataType: 'json', 1942 crossDomain: true, 1943 beforeSend: function() { 1944 $('#button-shipping-method').button('loading'); 1945 }, 1946 complete: function() { 1947 $('#button-shipping-method').button('reset'); 1948 }, 1949 success: function(json) { 1950 $('.alert-dismissible, .text-danger').remove(); 1951 $('.form-group').removeClass('has-error'); 1952 1953 if (json['error']) { 1954 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1955 1956 // Highlight any found errors 1957 $('select[name=\'shipping_method\']').closest('.form-group').addClass('has-error'); 1958 } 1959 1960 if (json['success']) { 1961 $('#content > .container-fluid').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1962 1963 // Refresh products, vouchers and totals 1964 $('#button-refresh').trigger('click'); 1965 } 1966 }, 1967 error: function(xhr, ajaxOptions, thrownError) { 1968 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1969 } 1970 }); 1971 }); 1972 1973 // Payment Method 1974 $('#button-payment-method').on('click', function() { 1975 $.ajax({ 1976 url: '{{ catalog }}index.php?route=api/payment/method&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 1977 type: 'post', 1978 data: 'payment_method=' + $('select[name=\'payment_method\'] option:selected').val(), 1979 dataType: 'json', 1980 crossDomain: true, 1981 beforeSend: function() { 1982 $('#button-payment-method').button('loading'); 1983 }, 1984 complete: function() { 1985 $('#button-payment-method').button('reset'); 1986 }, 1987 success: function(json) { 1988 $('.alert-dismissible, .text-danger').remove(); 1989 $('.form-group').removeClass('has-error'); 1990 1991 if (json['error']) { 1992 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 1993 1994 // Highlight any found errors 1995 $('select[name=\'payment_method\']').closest('.form-group').addClass('has-error'); 1996 } 1997 1998 if (json['success']) { 1999 $('#content > .container-fluid').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2000 2001 // Refresh products, vouchers and totals 2002 $('#button-refresh').trigger('click'); 2003 } 2004 }, 2005 error: function(xhr, ajaxOptions, thrownError) { 2006 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 2007 } 2008 }); 2009 }); 2010 2011 // Coupon 2012 $('#button-coupon').on('click', function() { 2013 $.ajax({ 2014 url: '{{ catalog }}index.php?route=api/coupon&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 2015 type: 'post', 2016 data: 'coupon=' + $('input[name=\'coupon\']').val(), 2017 dataType: 'json', 2018 crossDomain: true, 2019 beforeSend: function() { 2020 $('#button-coupon').button('loading'); 2021 }, 2022 complete: function() { 2023 $('#button-coupon').button('reset'); 2024 }, 2025 success: function(json) { 2026 $('.alert-dismissible, .text-danger').remove(); 2027 $('.form-group').removeClass('has-error'); 2028 2029 if (json['error']) { 2030 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2031 2032 // Highlight any found errors 2033 $('input[name=\'coupon\']').closest('.form-group').addClass('has-error'); 2034 } 2035 2036 if (json['success']) { 2037 $('#content > .container-fluid').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2038 2039 // Refresh products, vouchers and totals 2040 $('#button-refresh').trigger('click'); 2041 } 2042 }, 2043 error: function(xhr, ajaxOptions, thrownError) { 2044 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 2045 } 2046 }); 2047 }); 2048 2049 // Voucher 2050 $('#button-voucher').on('click', function() { 2051 $.ajax({ 2052 url: '{{ catalog }}index.php?route=api/voucher&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 2053 type: 'post', 2054 data: 'voucher=' + $('input[name=\'voucher\']').val(), 2055 dataType: 'json', 2056 crossDomain: true, 2057 beforeSend: function() { 2058 $('#button-voucher').button('loading'); 2059 }, 2060 complete: function() { 2061 $('#button-voucher').button('reset'); 2062 }, 2063 success: function(json) { 2064 $('.alert-dismissible, .text-danger').remove(); 2065 $('.form-group').removeClass('has-error'); 2066 2067 if (json['error']) { 2068 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2069 2070 // Highlight any found errors 2071 $('input[name=\'voucher\']').closest('.form-group').addClass('has-error'); 2072 } 2073 2074 if (json['success']) { 2075 $('#content > .container-fluid').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2076 2077 // Refresh products, vouchers and totals 2078 $('#button-refresh').trigger('click'); 2079 } 2080 }, 2081 error: function(xhr, ajaxOptions, thrownError) { 2082 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 2083 } 2084 }); 2085 }); 2086 2087 // Reward 2088 $('#button-reward').on('click', function() { 2089 $.ajax({ 2090 url: '{{ catalog }}index.php?route=api/reward&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 2091 type: 'post', 2092 data: 'reward=' + $('input[name=\'reward\']').val(), 2093 dataType: 'json', 2094 crossDomain: true, 2095 beforeSend: function() { 2096 $('#button-reward').button('loading'); 2097 }, 2098 complete: function() { 2099 $('#button-reward').button('reset'); 2100 }, 2101 success: function(json) { 2102 $('.alert-dismissible, .text-danger').remove(); 2103 $('.form-group').removeClass('has-error'); 2104 2105 if (json['error']) { 2106 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2107 2108 // Highlight any found errors 2109 $('input[name=\'reward\']').closest('.form-group').addClass('has-error'); 2110 } 2111 2112 if (json['success']) { 2113 $('#content > .container-fluid').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2114 2115 // Refresh products, vouchers and totals 2116 $('#button-refresh').trigger('click'); 2117 } 2118 }, 2119 error: function(xhr, ajaxOptions, thrownError) { 2120 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 2121 } 2122 }); 2123 }); 2124 2125 // Affiliate 2126 $('input[name=\'affiliate\']').autocomplete({ 2127 'source': function(request, response) { 2128 $.ajax({ 2129 url: 'index.php?route=customer/customer/autocomplete&user_token={{ user_token }}&filter_affiliate=1&filter_name=' + encodeURIComponent(request), 2130 dataType: 'json', 2131 success: function(json) { 2132 json.unshift({ 2133 customer_id: 0, 2134 name: '{{ text_none }}' 2135 }); 2136 2137 response($.map(json, function(item) { 2138 return { 2139 label: item['name'], 2140 value: item['customer_id'] 2141 } 2142 })); 2143 } 2144 }); 2145 }, 2146 'select': function(item) { 2147 $('input[name=\'affiliate\']').val(item['label']); 2148 $('input[name=\'affiliate_id\']').val(item['value']); 2149 } 2150 }); 2151 2152 // Checkout 2153 $('#button-save').on('click', function() { 2154 if ($('input[name=\'order_id\']').val() == 0) { 2155 var url = '{{ catalog }}index.php?route=api/order/add&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(); 2156 } else { 2157 var url = '{{ catalog }}index.php?route=api/order/edit&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val() + '&order_id=' + $('input[name=\'order_id\']').val(); 2158 } 2159 2160 $.ajax({ 2161 url: url, 2162 type: 'post', 2163 data: $('select[name=\'payment_method\'] option:selected, select[name=\'shipping_method\'] option:selected, #tab-total select[name=\'order_status_id\'], #tab-total select, textarea[name=\'comment\'], input[name=\'affiliate_id\']'), 2164 dataType: 'json', 2165 crossDomain: true, 2166 beforeSend: function() { 2167 $('#button-save').button('loading'); 2168 }, 2169 complete: function() { 2170 $('#button-save').button('reset'); 2171 }, 2172 success: function(json) { 2173 $('.alert-dismissible, .text-danger').remove(); 2174 2175 if (json['error']) { 2176 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2177 } 2178 2179 if (json['success']) { 2180 $('#content > .container-fluid').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2181 } 2182 2183 if (json['order_id']) { 2184 $('input[name=\'order_id\']').val(json['order_id']); 2185 } 2186 }, 2187 error: function(xhr, ajaxOptions, thrownError) { 2188 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 2189 } 2190 }); 2191 }); 2192 2193 $('#content').delegate('button[id^=\'button-upload\'], button[id^=\'button-custom-field\'], button[id^=\'button-payment-custom-field\'], button[id^=\'button-shipping-custom-field\']', 'click', function() { 2194 var node = this; 2195 2196 $('#form-upload').remove(); 2197 2198 $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>'); 2199 2200 $('#form-upload input[name=\'file\']').trigger('click'); 2201 2202 if (typeof timer != 'undefined') { 2203 clearInterval(timer); 2204 } 2205 2206 timer = setInterval(function() { 2207 if ($('#form-upload input[name=\'file\']').val() != '') { 2208 clearInterval(timer); 2209 2210 $.ajax({ 2211 url: 'index.php?route=tool/upload/upload&user_token={{ user_token }}', 2212 type: 'post', 2213 dataType: 'json', 2214 data: new FormData($('#form-upload')[0]), 2215 cache: false, 2216 contentType: false, 2217 processData: false, 2218 beforeSend: function() { 2219 $(node).button('loading'); 2220 }, 2221 complete: function() { 2222 $(node).button('reset'); 2223 }, 2224 success: function(json) { 2225 $(node).parent().find('.text-danger').remove(); 2226 2227 if (json['error']) { 2228 $(node).parent().find('input[type=\'hidden\']').after('<div class="text-danger">' + json['error'] + '</div>'); 2229 } 2230 2231 if (json['success']) { 2232 alert(json['success']); 2233 } 2234 2235 if (json['code']) { 2236 $(node).parent().find('input[type=\'hidden\']').val(json['code']); 2237 } 2238 }, 2239 error: function(xhr, ajaxOptions, thrownError) { 2240 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 2241 } 2242 }); 2243 } 2244 }, 500); 2245 }); 2246 2247 $('.date').datetimepicker({ 2248 language: '{{ datepicker }}', 2249 pickTime: false 2250 }); 2251 2252 $('.datetime').datetimepicker({ 2253 language: '{{ datepicker }}', 2254 pickDate: true, 2255 pickTime: true 2256 }); 2257 2258 $('.time').datetimepicker({ 2259 language: '{{ datepicker }}', 2260 pickDate: false 2261 }); 2262 //--></script> 2263 <script type="text/javascript"><!-- 2264 // Sort the custom fields 2265 $('#tab-customer .form-group[data-sort]').detach().each(function() { 2266 if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#tab-customer .form-group').length) { 2267 $('#tab-customer .form-group').eq($(this).attr('data-sort')).before(this); 2268 } 2269 2270 if ($(this).attr('data-sort') > $('#tab-customer .form-group').length) { 2271 $('#tab-customer .form-group:last').after(this); 2272 } 2273 2274 if ($(this).attr('data-sort') < -$('#tab-customer .form-group').length) { 2275 $('#tab-customer .form-group:first').before(this); 2276 } 2277 }); 2278 2279 // Sort the custom fields 2280 $('#tab-payment .form-group[data-sort]').detach().each(function() { 2281 if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#tab-payment .form-group').length) { 2282 $('#tab-payment .form-group').eq($(this).attr('data-sort')).before(this); 2283 } 2284 2285 if ($(this).attr('data-sort') > $('#tab-payment .form-group').length) { 2286 $('#tab-payment .form-group:last').after(this); 2287 } 2288 2289 if ($(this).attr('data-sort') < -$('#tab-payment .form-group').length) { 2290 $('#tab-payment .form-group:first').before(this); 2291 } 2292 }); 2293 2294 $('#tab-shipping .form-group[data-sort]').detach().each(function() { 2295 if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#tab-shipping .form-group').length) { 2296 $('#tab-shipping .form-group').eq($(this).attr('data-sort')).before(this); 2297 } 2298 2299 if ($(this).attr('data-sort') > $('#tab-shipping .form-group').length) { 2300 $('#tab-shipping .form-group:last').after(this); 2301 } 2302 2303 if ($(this).attr('data-sort') < -$('#tab-shipping .form-group').length) { 2304 $('#tab-shipping .form-group:first').before(this); 2305 } 2306 }); 2307 2308 // Add all products to the cart using the api 2309 $('#button-refresh').on('click', function() { 2310 $.ajax({ 2311 url: '{{ catalog }}index.php?route=api/cart/products&api_token={{ api_token }}&store_id=' + $('select[name=\'store_id\'] option:selected').val(), 2312 dataType: 'json', 2313 crossDomain: true, 2314 beforeSend: function() { 2315 $('#button-refresh').button('loading'); 2316 }, 2317 complete: function() { 2318 $('#button-refresh').button('reset'); 2319 }, 2320 success: function(json) { 2321 $('.alert-dismissible').remove(); 2322 2323 // Check for errors 2324 if (json['error']) { 2325 if (json['error']['warning']) { 2326 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2327 } 2328 2329 if (json['error']['stock']) { 2330 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['stock'] + '</div>'); 2331 } 2332 2333 if (json['error']['minimum']) { 2334 for (i in json['error']['minimum']) { 2335 $('#content > .container-fluid').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['minimum'][i] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 2336 } 2337 } 2338 } 2339 2340 var shipping = false; 2341 2342 html = ''; 2343 2344 if (json['products'].length) { 2345 for (i = 0; i < json['products'].length; i++) { 2346 product = json['products'][i]; 2347 2348 html += '<tr>'; 2349 html += ' <td class="text-left">' + product['name'] + ' ' + (!product['stock'] ? '<span class="text-danger">***</span>' : '') + '<br />'; 2350 html += ' <input type="hidden" name="product[' + i + '][product_id]" value="' + product['product_id'] + '" />'; 2351 2352 if (product['option']) { 2353 for (j = 0; j < product['option'].length; j++) { 2354 option = product['option'][j]; 2355 2356 html += ' - <small>' + option['name'] + ': ' + option['value'] + '</small><br />'; 2357 2358 if (option['type'] == 'select' || option['type'] == 'radio' || option['type'] == 'image') { 2359 html += '<input type="hidden" name="product[' + i + '][option][' + option['product_option_id'] + ']" value="' + option['product_option_value_id'] + '" />'; 2360 } 2361 2362 if (option['type'] == 'checkbox') { 2363 html += '<input type="hidden" name="product[' + i + '][option][' + option['product_option_id'] + '][]" value="' + option['product_option_value_id'] + '" />'; 2364 } 2365 2366 if (option['type'] == 'text' || option['type'] == 'textarea' || option['type'] == 'file' || option['type'] == 'date' || option['type'] == 'datetime' || option['type'] == 'time') { 2367 html += '<input type="hidden" name="product[' + i + '][option][' + option['product_option_id'] + ']" value="' + option['value'] + '" />'; 2368 } 2369 } 2370 } 2371 2372 html += '</td>'; 2373 html += ' <td class="text-left">' + product['model'] + '</td>'; 2374 html += ' <td class="text-right"><div class="input-group btn-block" style="max-width: 200px;"><input type="text" name="product[' + i + '][quantity]" value="' + product['quantity'] + '" class="form-control" /><span class="input-group-btn"><button type="button" data-toggle="tooltip" title="{{ button_refresh }}" data-loading-text="{{ text_loading }}" class="btn btn-primary"><i class="fa fa-refresh"></i></button></span></div></td>'; 2375 html += ' <td class="text-right">' + product['price'] + '</td>'; 2376 html += ' <td class="text-right">' + product['total'] + '</td>'; 2377 html += ' <td class="text-center" style="width: 3px;"><button type="button" value="' + product['cart_id'] + '" data-toggle="tooltip" title="{{ button_remove }}" data-loading-text="{{ text_loading }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>'; 2378 html += '</tr>'; 2379 2380 if (product['shipping'] != 0) { 2381 shipping = true; 2382 } 2383 } 2384 } 2385 2386 if (!shipping) { 2387 $('select[name=\'shipping_method\'] option').removeAttr('selected'); 2388 $('select[name=\'shipping_method\']').prop('disabled', true); 2389 $('#button-shipping-method').prop('disabled', true); 2390 } else { 2391 $('select[name=\'shipping_method\']').prop('disabled', false); 2392 $('#button-shipping-method').prop('disabled', false); 2393 } 2394 2395 if (json['vouchers'].length) { 2396 for (i in json['vouchers']) { 2397 voucher = json['vouchers'][i]; 2398 2399 html += '<tr>'; 2400 html += ' <td class="text-left">' + voucher['description']; 2401 html += ' <input type="hidden" name="voucher[' + i + '][code]" value="' + voucher['code'] + '" />'; 2402 html += ' <input type="hidden" name="voucher[' + i + '][description]" value="' + voucher['description'] + '" />'; 2403 html += ' <input type="hidden" name="voucher[' + i + '][from_name]" value="' + voucher['from_name'] + '" />'; 2404 html += ' <input type="hidden" name="voucher[' + i + '][from_email]" value="' + voucher['from_email'] + '" />'; 2405 html += ' <input type="hidden" name="voucher[' + i + '][to_name]" value="' + voucher['to_name'] + '" />'; 2406 html += ' <input type="hidden" name="voucher[' + i + '][to_email]" value="' + voucher['to_email'] + '" />'; 2407 html += ' <input type="hidden" name="voucher[' + i + '][voucher_theme_id]" value="' + voucher['voucher_theme_id'] + '" />'; 2408 html += ' <input type="hidden" name="voucher[' + i + '][message]" value="' + voucher['message'] + '" />'; 2409 html += ' <input type="hidden" name="voucher[' + i + '][amount]" value="' + voucher['amount'] + '" />'; 2410 html += ' </td>'; 2411 html += ' <td class="text-left"></td>'; 2412 html += ' <td class="text-right">1</td>'; 2413 html += ' <td class="text-right">' + voucher['price'] + '</td>'; 2414 html += ' <td class="text-right">' + voucher['price'] + '</td>'; 2415 html += ' <td class="text-center" style="width: 3px;"><button type="button" value="' + voucher['code'] + '" data-toggle="tooltip" title="{{ button_remove }}" data-loading-text="{{ text_loading }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>'; 2416 html += '</tr>'; 2417 } 2418 } 2419 2420 if (!json['products'].length && !json['vouchers'].length) { 2421 html += '<tr>'; 2422 html += ' <td colspan="6" class="text-center">{{ text_no_results }}</td>'; 2423 html += '</tr>'; 2424 } 2425 2426 $('#cart').html(html); 2427 2428 // Totals 2429 html = ''; 2430 2431 if (json['products'].length) { 2432 for (i = 0; i < json['products'].length; i++) { 2433 product = json['products'][i]; 2434 2435 html += '<tr>'; 2436 html += ' <td class="text-left">' + product['name'] + ' ' + (!product['stock'] ? '<span class="text-danger">***</span>' : '') + '<br />'; 2437 2438 if (product['option']) { 2439 for (j = 0; j < product['option'].length; j++) { 2440 option = product['option'][j]; 2441 2442 html += ' - <small>' + option['name'] + ': ' + option['value'] + '</small><br />'; 2443 } 2444 } 2445 2446 html += ' </td>'; 2447 html += ' <td class="text-left">' + product['model'] + '</td>'; 2448 html += ' <td class="text-right">' + product['quantity'] + '</td>'; 2449 html += ' <td class="text-right">' + product['price'] + '</td>'; 2450 html += ' <td class="text-right">' + product['total'] + '</td>'; 2451 html += '</tr>'; 2452 } 2453 } 2454 2455 if (json['vouchers'].length) { 2456 for (i in json['vouchers']) { 2457 voucher = json['vouchers'][i]; 2458 2459 html += '<tr>'; 2460 html += ' <td class="text-left">' + voucher['description'] + '</td>'; 2461 html += ' <td class="text-left"></td>'; 2462 html += ' <td class="text-right">1</td>'; 2463 html += ' <td class="text-right">' + voucher['amount'] + '</td>'; 2464 html += ' <td class="text-right">' + voucher['amount'] + '</td>'; 2465 html += '</tr>'; 2466 } 2467 } 2468 2469 if (json['totals'].length) { 2470 for (i in json['totals']) { 2471 total = json['totals'][i]; 2472 2473 html += '<tr>'; 2474 html += ' <td class="text-right" colspan="4">' + total['title'] + ':</td>'; 2475 html += ' <td class="text-right">' + total['text'] + '</td>'; 2476 html += '</tr>'; 2477 } 2478 } 2479 2480 if (!json['totals'].length && !json['products'].length && !json['vouchers'].length) { 2481 html += '<tr>'; 2482 html += ' <td colspan="5" class="text-center">{{ text_no_results }}</td>'; 2483 html += '</tr>'; 2484 } 2485 2486 $('#total').html(html); 2487 }, 2488 error: function(xhr, ajaxOptions, thrownError) { 2489 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 2490 } 2491 }); 2492 }); 2493 //--></script></div> 2494 {{ footer }}