Beispiel #1
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Inv the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Inv::model()->with(array('exp' => array('pays', 'department' => array('departmentProps'), 'client' => array('clientProps')), 'invd' => array('product0' => array('it0'))))->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #2
0
private function paystate($criteria)
{	
                    if($this->state_pay==1)
                  {
                     $payment_table   = Pay::model()->tableName();
                   $paid_status_sql = "(select CASE WHEN (select sum(amount) from $payment_table where $payment_table.exp_id = t.id) >0 THEN 1 ELSE 0 END)";
                  }
                   else if($this->state_pay==2)
                  {
                    $payment_table   = Pay::model()->tableName();
                      $paid_status_sql = "(select CASE WHEN ((t.amount>(select sum(amount) from $payment_table where $payment_table.exp_id = t.id))OR((select sum(amount) from $payment_table where $payment_table.exp_id = t.id)IS NULL)) THEN 2 ELSE 0 END)";
                  }
                  else if($this->state_pay==3)
                  {
                     $payment_table   = Inv::model()->tableName();
                     $paid_status_sql = "(select CASE WHEN (select sum(amount) from $payment_table where $payment_table.exp_id = t.id) >0 THEN 3 ELSE 0 END)";
                  }
                   else if($this->state_pay==4)
                  {
                    $payment_table   = Inv::model()->tableName();
                       $paid_status_sql = "(select CASE WHEN ((t.amount>(select sum(amount) from $payment_table where $payment_table.exp_id = t.id))OR((select sum(amount) from $payment_table where $payment_table.exp_id = t.id)IS NULL)) THEN 4 ELSE 0 END)";
                  }
 
                   $criteria->select = array(
                        '*',
                        $paid_status_sql." as state_pay",
                    );
//                        $criteria->addCondition(" (".$paid_status_sql.") =".$this->state_pay);
                      $criteria->compare($paid_status_sql, $this->state_pay); 
}
Beispiel #3
0
 public function actionAjaxInv()
 {
     $val1 = $_POST['val_id'];
     sscanf($val1, "js:_id=%d;_pay=%d;", $id, $pay);
     if ($id == null) {
         echo "R:" . $val1;
         return;
     }
     $ret .= "";
     $dataReader = Inv::model()->with(array('invd' => array('with' => array('product0'), 'together' => true)))->findAll('t.exp_id=:id', array(':id' => $id));
     //                var_dump($dataReader);
     //                return;
     $ret .= "<table class='acctable'>";
     $ret .= "<tr><th>№</th>" . "<th>Товар</th>" . "<th>Колич.</th>" . "<th>Цена</th>" . "<th>Сумма</th>" . "<th>Со скид.</th>" . "<th>%</th>" . "<th>НДС</th>" . "<th>Всего</th></tr>";
     foreach ($dataReader as $row) {
         $ret .= "<tr class='ord'><td>" . $row['id'] . "</td><td colspan='2'>" . $row['name'] . "</td><td colspan='3'>" . Yii::app()->dateFormatter->formatDateTime($row['date'], 'short', null) . "</td><td colspan='3'>" . Yii::app()->numberFormatter->formatCurrency($row['amount'], '') . "</td></tr>\n";
         $resa = 0;
         $resb = 0;
         $rest = 0;
         foreach ($row->invd as $rowi) {
             $ret .= "<tr><td>" . $rowi['id'] . "</td><td style='text-align:left;'>" . $rowi->product0['tnam'] . "</td>\n";
             $sumka = $rowi['amount'] * $rowi['price'];
             $ret .= "<td style='text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($rowi['amount'], '') . "</td>\n";
             $ret .= "<td style='text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($rowi['price'], '') . "</td>\n";
             $ret .= "<td style='text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($sumka, '') . "</td>\n";
             $ret .= "<td style='text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($rowi['total'], '') . "</td>\n";
             if ($sumka == $rowi['total']) {
                 $rate = 0;
             } else {
                 $rate = ($sumka - $rowi['total']) / $sumka;
             }
             $ret .= "<td style='text-align:right;'>" . Yii::app()->numberFormatter->formatPercentage($rate, '') . "</td>\n";
             $ret .= "<td style='text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($rowi['vat'], '') . "</td>\n";
             $ret .= "<td style='text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($rowi['total'] + $rowi['vat'], '') . "</td></tr>\n";
             $resa += $sumka;
             $resb += $rowi['total'];
             $rest += $rowi['total'] + $rowi['vat'];
         }
         $ret .= "<tr class='ord'><td colspan='4'>Итого:</td>" . "<td style='font-weight: bold;text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($resa, '') . "</td>" . "<td style='font-weight: bold;text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($resb, '') . "</td>" . "<td colspan='3' style='font-weight: bold;text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($rest, '') . "</td>" . "</tr>\n";
     }
     $ret .= "</table>\n";
     echo $ret;
 }
Beispiel #4
0
        }
    }
    function index()
    {
        $webtitle = $GLOBALS['_LANG']['la_webtitle'];
        //处理你现在的位置
        $nowaddress = $GLOBALS['_LANG']['u_address'] . '<a href="' . BASE_WEBURL . '/">' . $GLOBALS['_LANG']['home'] . '</a> > <a href="' . BASE_WEBURL . '/?invite.html">' . $GLOBALS['_LANG']['la_webtitle'] . '</a>';
        //查询一级菜单分类数量
        $sqlQuery = " SELECT inv_id, inv_position , inv_addtime   FROM  " . SQL_PREFIX . "invite   WHERE  inv_delete = 0 AND inv_enabled = 1 GROUP BY  inv_id ORDER BY inv_addtime DESC, `inv_id` LIMIT  0 , 18 ";
        $info = $GLOBALS['MySql']->selectInfo($sqlQuery);
        //var_dump($info);
        $GLOBALS['Templ']->assign('webtitle', $webtitle);
        $GLOBALS['Templ']->assign('nowaddress', $nowaddress);
        $GLOBALS['Templ']->assign('info', $info);
        $GLOBALS['Templ']->display('invindex_tpl.html', $cache_id);
    }
}
$Inv = new Inv();
if ($GLOBALS['Webur']->getval["act"] == 'list') {
    $Inv->infolist();
} else {
    if ($GLOBALS['Webur']->getval["type"] == 'search') {
        $Inv->infolist();
    } else {
        if (intval($GLOBALS['Webur']->getval["idval"]) != '') {
            $Inv->detail();
        } else {
            $Inv->index();
        }
    }
}
Beispiel #5
0
 private function updatedocs($docs, &$info)
 {
     /* 
      * отбор загруженных на этапе считывания документов из tmp_doc
      */
     $sql = "SELECT a.* ," . " c.id AS c_id, d.id AS d_id, t.id AS t_id, m.id AS m_id, b.id AS b_id, bb.id AS bb_id " . " FROM ((((((tmp_doc a LEFT JOIN  client_id c ON a.ccli=c.ckey AND c.db=1)" . " LEFT JOIN  department_id d ON a.cfir=d.ckey AND c.db=1)" . " LEFT JOIN  client_id t ON a.transport=t.ckey AND c.db=1)" . " LEFT JOIN  bank b ON a.dbank=b.longname)" . " LEFT JOIN  bank bb ON a.cbank=bb.longname)" . " LEFT JOIN  account m ON a.man=m.id)" . " WHERE a.user="******"bid:".$value['b_id']."bbid:".$value['bb_id']."re:".$rr."<hr>";
                     if ($rr) {
                         if ($id > 0) {
                             $jj++;
                             $resdoc[] = array('t' => 0, 's' => 0, 'n' => $group->id);
                         } else {
                             $resdoc[] = array('t' => 0, 's' => 1, 'n' => $group->id);
                             $j++;
                         }
                         $this->updatedocstr($value['id'], $group->id, 0);
                         $this->updatecomment($value['id'], $group->id);
                     }
                 }
             } else {
                 $oid = (int) $value['expid'];
                 $iid = (int) $value['docid'];
                 $fid = $docs[$value['id']];
                 if ($fid === null) {
                     $oid = 0;
                     $iid = 0;
                 } else {
                     $iid = $fid[1];
                     $oid = $fid[0];
                 }
                 $group = NULL;
                 if ($iid > 0) {
                     $group = Inv::model()->findByPk($iid);
                     if ($group == null) {
                         continue;
                     }
                     Invd::model()->deleteAll('inv=' . $iid);
                 }
                 if ($group === null) {
                     if ($oid > 0) {
                         $group = new Inv();
                     } else {
                         continue;
                     }
                 }
                 $group->name = $value['tnum'];
                 $group->amount = $value['bsum'];
                 $group->date = $value['ddat'];
                 $group->client_id = $value['t_id'];
                 $group->exp_id = $oid;
                 if ($group->save()) {
                     if ($iid > 0) {
                         $ii++;
                         $resdoc[] = array('t' => 1, 's' => 0, 'n' => $group->id);
                     } else {
                         $resdoc[] = array('t' => 1, 's' => 1, 'n' => $group->id);
                         $i++;
                     }
                     $this->updatedocstr($value['id'], $group->id, 1);
                 }
             }
         }
     }
     $info[] = 'Создано новых счетов:' . $j;
     $info[] = 'Создано новых накладных:' . $i;
     $info[] = 'Отредактикровано счетов:' . $jj;
     $info[] = 'Отредактикровано накладных:' . $ii;
     //                            $info['doc']=$resdoc;
 }