protected function getContent() { // Inicializa assistente de formulário $form = new Form("myDetail"); // Prepara formulário de inserção/atualização de dados $dataArr['ajax'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => true]]; $dataArr['id'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => $this->data->id]]; // Verifica cenários baseado no status e responsável if ($_SESSION['webLogin']) { switch ($_SESSION['webLogin']->getUserID()) { case $this->data->buyer: // Comprador if ($this->data->status == Config::read('order.status')['sent']) { $dataArr['status'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => Config::read('order.status')['received']]]; $dataArr['tracking'] = ["type" => Config::read('form.input'), "data" => (object) ["text" => Text::read('form.tracking'), "value" => $this->data->tracking, "disabled" => true]]; $dataArr['btnStat'] = ["type" => Config::read('form.submit'), "data" => (object) ["text" => Text::read('order.status')['received'], "class" => "success btn-lg", "icon" => "glyphicon-envelope"]]; } break; case $this->data->vendor: // Vendedor if ($this->data->status == Config::read('order.status')['paid'] || $this->data->status == Config::read('order.status')['sent']) { $dataArr['status'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => Config::read('order.status')['sent']]]; $dataArr['tracking'] = ["type" => Config::read('form.input'), "data" => (object) ["text" => Text::read('form.tracking'), "value" => $this->data->tracking, "length" => 13]]; $dataArr['btnStat'] = ["type" => Config::read('form.submit'), "data" => (object) ["text" => Text::read('order.status')['sent'], "class" => "success btn-lg", "icon" => "glyphicon-send"]]; } break; } } $detailForm = $form->createForm($dataArr); unset($dataArr); ob_start(); ?> <!-- STATUS //--> <div class="row"> <div class="col-md-8 col-md-offset-2"> <div class="stepwizard"> <div class="stepwizard-row setup-panel"> <?php foreach (Config::read('order.status') as $key => $status) { $i++; ?> <div class="stepwizard-step"> <a href="#step-<?php echo $i; ?> " type="button" class="btn btn-<?php echo !$disabled ? Config::read('order.status.state')[$key] : "default"; ?> btn-circle" <?php echo $disabled; ?> ><?php echo $i; ?> </a> <?php if ($disabled) { ?> <p><?php echo Text::read('order.status')[$key]; ?> </p> <?php } else { ?> <b><p><?php echo Text::read('order.status')[$key]; ?> </p></b> <?php } ?> </div> <?php // Desabilita status superiores if ($this->data->status == $status) { $disabled = 'disabled="disabled"'; } } ?> </div> </div> </div> </div> <div class="container"> <div class="row cadastro"> <div class="col-md-8 col-md-offset-2"> <fieldset> <legend><span class="glyphicon glyphicon-th-list"></span> <?php echo Text::read('form.product'); ?> </legend> <div class="row"> <div class="col-md-4 text-center"> <?php if ($this->data->product->photos[0]) { ?> <img style="width:200px;" src="<?php echo Config::read('url.photos') . '/' . $this->data->product->album . '/small-' . $this->data->product->photos[0]->url; ?> " draggable="false"> <?php } ?> </div> <div class="col-md-6"> <h4><?php echo $this->data->product->name; ?> </h4> <p><?php echo $this->data->product->text; ?> </p> </div> </div> </fieldset> <br /> <fieldset> <legend><span class="glyphicon glyphicon-th-list"></span> <?php echo Text::read('form.detail'); ?> </legend> <div class="col-md-6"> <?php echo OrderDetailView::prepareOrderCard($this->data); ?> </div> </fieldset> <br /> <fieldset> <legend><span class="glyphicon glyphicon-home"></span> <?php echo Text::read('form.shipping.address'); ?> </legend> <div class="col-md-6"> <?php echo OrderDetailView::prepareAddressCard($this->data); ?> </div> </fieldset> <br /> <?php echo $detailForm; ?> </div> </div> </div> <?php return ob_get_clean(); }
protected function getContent() { // Inicializa assistente de formulário $form = new Form("myDetail"); if (!$this->data->status) { $this->data->statusText = Text::read('product.status')['new']; } // Prepara formulário de inserção/atualização de dados $dataArr['ajax'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => true]]; $dataArr['id'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => $this->data->id]]; $productForm = $form->createFormFields($dataArr); unset($dataArr); $dataArr['shipping'] = ["type" => Config::read('form.radio'), "data" => (object) ["value" => Config::read('combo.shipping'), "text" => Text::read('form.shipping'), "checked" => 1]]; $shippingForm = $form->createFormFields($dataArr); unset($dataArr); ob_start(); ?> <fieldset> <legend><span class="glyphicon glyphicon-th-list"></span> <?php echo Text::read('form.product'); ?> </legend> <div class="row"> <div class="col-md-4 text-center"> <?php if ($this->data->photos[0]) { ?> <img style="width:200px;" src="<?php echo Config::read('url.photos') . '/' . $this->data->album . '/small-' . $this->data->photos[0]->url; ?> " draggable="false"> <?php } ?> </div> <div class="col-md-6"> <h4><?php echo $this->data->name; ?> </h4> <p><?php echo $this->data->text; ?> </p> </div> </div> </fieldset> <br /> <?php echo $productForm; ?> <fieldset> <legend><span class="glyphicon glyphicon-home"></span> <?php echo Text::read('form.shipping.address'); ?> </legend> <div id="addressCard" class="col-md-6"> <?php echo OrderDetailView::prepareAddressCard($this->data); ?> </div> <div class="col-md-6"> <a id="newAddress" class="btn btn-lg btn-info pull-right" href="#">+ Novo endereço de entrega</a> </div> </fieldset> <br /> <fieldset> <legend><span class="glyphicon glyphicon-piggy-bank"></span> <?php echo Text::read('form.price'); ?> </legend> <div class="col-md-4"> <?php echo $shippingForm; ?> </div> <div class="col-md-4"> <div class="row"> <div class="col-md-6"><b>Valor:</b></div> <div class="col-md-6">R$ <?php echo $this->data->price; ?> </div> </div> <div class="row"> <div class="col-md-6"><b>(-) Desconto:</b></div> <div class="col-md-6">R$ <?php echo $this->data->discount; ?> </div> </div> <div class="row"> <div class="col-md-6"><b>(+) Frete:</b></div> <div class="col-md-6">R$ 0,00</div> </div> <p>________________________________</p> <div class="row"> <div class="col-md-6"><b>TOTAL:</b></div> <div class="col-md-6">R$ <?php echo $this->data->price - $this->data->discount; ?> </div> </div> </div> </fieldset> <br /> <?php $globalForm = ob_get_clean(); $dataArr['btnPay'] = ["type" => Config::read('form.submit'), "data" => (object) ["text" => Text::read('form.save'), "class" => "success btn-lg", "icon" => "glyphicon-floppy-disk"]]; $detailForm = $form->createForm($dataArr, $globalForm); unset($dataArr); ob_start(); ?> <!-- STATUS //--> <div class="row"> <div class="col-md-8 col-md-offset-2"> <div class="stepwizard"> <div class="stepwizard-row setup-panel"> <div class="stepwizard-step"> <a href="#step-1" type="button" class="btn btn-primary btn-circle">1</a> <p>Dados de Entrega</p> </div> <div class="stepwizard-step"> <a href="#step-2" type="button" class="btn btn-default btn-circle" disabled="disabled">2</a> <p>Pagamento</p> </div> <div class="stepwizard-step"> <a href="#step-3" type="button" class="btn btn-default btn-circle" disabled="disabled">3</a> <p>Conclusão do Pedido</p> </div> </div> </div> </div> </div> <div class="container"> <div class="row cadastro"> <div class="col-md-8 col-md-offset-2"> <?php echo $detailForm; ?> </div> </div> </div> <!-- MODAL //--> <div class="modal fade" id="myShippingAddressModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4><?php echo Text::read('form.shipping.address'); ?> </h4> </div> <div class="modal-body"> <form id="myShippingAddress" method="POST" action="<?php echo Config::read('page.url.order.shipping.address'); ?> " class="form"> <?php echo $this->addressView->getContent(); ?> </form> </div> <div class="modal-footer"> <button type="button" id="sendShippingAddress" class="btn btn-primary"><?php echo Text::read('form.save'); ?> </button> </div> </div> </div> </div> <?php return ob_get_clean(); }
protected function ajaxCallbackForShippingAddress() { // Executa validações dos campos no Formulário $validation = $this->executeAddressFormValidation(); if ($validation['error']) { // Mensagem de erro devido a validação de campos $json['message']['type'] = "error"; $json['message']['text'] = Text::read('message.error'); } else { $json['message']['type'] = "success"; $json['message']['text'] = "Endereço de entrega atualizado"; $json['addressDetail'] = OrderDetailView::prepareAddressCard($this->myView->data); } // Recupera mensagens de erro individuais e envia para JSON $json['validation'] = $validation['messages']; return $json; }