Example #1
0
 protected function _veiculo($data)
 {
     $this->_veiculo->newRow();
     $this->_veiculo->setPlaca($data->placa);
     $this->_veiculo->setIdEmpresa(Auth_Session_User::getInstance()->getIdEmpresa());
     $exists = $this->_veiculo->exists();
     $this->_veiculo->setRenavam($data->renavam)->setChassi($data->numeroChassi)->setDescricao($data->placa);
     if (!$exists) {
         $this->_veiculo->insert();
     } else {
         $this->_veiculo->update();
     }
     return $this->_veiculo->getId();
 }
Example #2
0
 public function importXls($fileName = '')
 {
     $cnpj = '';
     $_pessoa = new Ca_Model_Pessoa_Mapper();
     $_pessoa->setCodigo($cnpj)->retrieve();
     $idCliente = $_pessoa->getId();
     if (!$fileName) {
         $fileName = APPLICATION_PATH . '/modules/vendas/contexts/Vsp/tokio.xls';
     }
     $objReader = ZendT_Excel_IOFactory::createReader('Excel5');
     $objPHPExcel = $objReader->load($fileName);
     $data = $objPHPExcel->getSheet()->toArray(null, true, true, true);
     if (count($data) > 0) {
         $_pedido = new Vendas_DataView_Pedido_MapperView();
         $_veiculo = new Frota_DataView_Veiculo_MapperView();
         unset($data[0]);
         foreach ($data as $row) {
             $_veiculo->newRow()->setPlaca($row['D']);
             if ($_veiculo->exists()) {
                 $_veiculo->setDescricao($row['C'])->setChassi($row['E'])->setChassi()->update();
             } else {
                 $_veiculo->setDescricao($row['C'])->setChassi($row['E'])->setChassi()->insert();
             }
             $_pedido->newRow()->setIdCliente($idCliente)->setDtEmis($row['A'])->setSinistro($row['B'])->setIdVeiculo($_veiculo->getId());
             if (!$_pedido->exists()) {
                 $_pedido->insert();
             }
         }
     }
     echo '<pre>';
     print_r($data);
     echo '</pre>';
 }