File: /www/wwwroot/oa.sanjiangapp.com/app/crm/contract/view/view.html.php
<?php
/**
* The view view file of contract module of ZDOO.
*
* @copyright Copyright 2009-2018 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package contract
* @version $Id$
* @link http://www.zdoo.com
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../../sys/common/view/kindeditor.html.php';?>
<div id='mainTitle' class='clearfix'>
<div class='btn-toolbar pull-left'>
<?php if(!isonlybody()):?>
<?php echo html::a($browseLink, '<i class="icon icon-back icon-sm"></i> ' . $lang->goback, "class='btn btn-back'");?>
<div class="divider"></div>
<?php endif;?>
<div class="page-title">
<span class="label label-id"><?php echo $contract->id?></span>
<span class="text" title='<?php echo $contract->name;?>'><?php echo $contract->name;?></span>
</div>
</div>
</div>
<div class="main-row">
<div class='main-col col-8'>
<div class='panel panel-block table-row'>
<div class='panel-heading'><strong><?php echo $lang->$moduleType->items;?></strong></div>
<div class='panel-body'>
<?php echo $contract->items;?>
<div><?php echo $this->fetch('file', 'printFiles', array('files' => $contract->files, 'fieldset' => 'false'))?></div>
</div>
</div>
<?php if(!empty($contract->tradeList)):?>
<div class='panel panel-block table-row'>
<div class='panel-heading'>
<strong class='title'><?php echo $lang->$moduleType->tradeList;?></strong>
</div>
<table class='table table-borderless table-fixed'>
<thead>
<tr class='text-center'>
<th class='w-90px'><?php echo $lang->trade->date;?></th>
<th class='w-100px'><?php echo $lang->trade->depositor;?></th>
<th class='w-60px'><?php echo $lang->trade->type;?></th>
<th class='w-140px'><?php echo $lang->trade->trader;?></th>
<th class='w-100px text-right'><?php echo $lang->trade->money;?></th>
<th class='w-80px'><?php echo $lang->trade->dept;?></th>
<th class='w-80px'><?php echo $lang->contract->handlers;?></th>
<th class='w-100px'><?php echo $lang->trade->product . $lang->slash . $lang->trade->category;?></th>
<th><?php echo $lang->trade->desc;?></th>
</tr>
</thead>
<?php foreach($contract->tradeList as $trade):?>
<tr class='text-center text-middle'>
<?php
$depositor = zget($depositorList, $trade->depositor, '');
$trader = zget($allCustomers, $trade->trader, '');
$dept = zget($deptList, $trade->dept, '');
$handlers = '';
foreach(explode(',', $trade->handlers) as $handler) $handlers .= zget($users, $handler) . ' ';
$product = zget($products, $trade->product, '');
$category = zget($categories, $trade->category, '');
?>
<td><?php echo formatTime($trade->date, DT_DATE1);?></td>
<td class='text-ellipsis' title='<?php echo $depositor;?>'><?php echo $depositor;?></td>
<td><?php echo $lang->trade->typeList[$trade->type];?></td>
<td class='text-left text-ellipsis' title='<?php echo $trader;?>'><?php echo $trader;?></td>
<td class='text-right'><?php echo zget($currencySign, $trade->currency) . formatMoney($trade->money);?></td>
<td class='text-ellipsis' title='<?php echo $dept;?>'><?php echo $dept;?></td>
<td class='text-ellipsis' title='<?php echo $handlers;?>'><?php echo $handlers;?></td>
<td class='text-ellipsis' title='<?php echo $product . $lang->slash . $category;?>'><?php echo $product . $lang->slash . $category;?></td>
<td class='text-left'><div title="<?php echo $trade->desc;?>" class='text-ellipsis'><?php echo $trade->desc;?><div></td>
</tr>
<?php endforeach;?>
</table>
</div>
<?php endif;?>
<?php echo $this->printExtendFields($contract, 'div', "position=left&inCell=1&inForm=0");?>
<?php echo $this->fetch('action', 'history', "objectType={$moduleType}&objectID={$contract->id}")?>
<div class='main-actions'>
<div class='btn-toolbar'>
<?php commonModel::printBack($browseLink);?>
<div class='divider'></div>
<?php echo $this->buildOperateMenu($contract, 'view');?>
<?php echo html::a('#commentBox', $lang->comment, "class='btn btn-default universal' onclick=setComment()");?>
<div class='divider'></div>
<?php commonModel::printRPN($preAndNext);?>
</div>
</div>
<div id='commentBox' class='hide panel panel-block'>
<div class='panel-heading'><strong><?php echo $lang->comment;?></strong></div>
<div class='panel-body'>
<form id='commentForm' method='post' action='<?php echo inlink('edit', "contractID={$contract->id}&comment=true")?>'>
<div class='form-group'><?php echo html::textarea('remark', '',"rows='5' class='w-p100'");?></div>
<div class='form-actions'><?php echo html::submitButton() . html::commonButton($lang->cancel, 'btn btn-back', "onClick=setComment()");?></div>
</form>
</div>
</div>
</div>
<div class='side-col col-4'>
<div class='panel panel-block'>
<div class='panel-heading'>
<strong class='title'><?php echo $lang->basicInfo;?></strong>
</div>
<div class='panel-body'>
<table class='table table-data'>
<tr>
<th class='w-60px'><?php echo $lang->$moduleType->code;?></th>
<td><?php echo $contract->code;?></td>
</tr>
<tr>
<th class='w-60px'><?php echo $lang->$moduleType->customer;?></th>
<td>
<?php $customerName = !empty($customer->name) ? $customer->name : $contract->customer;?>
<?php if(!commonModel::printLink("crm.{$customerType}", 'view', "customerID={$contract->customer}", $customerName)) echo $customerName;?>
</td>
</tr>
<?php if($moduleType == 'contract'):?>
<tr>
<th><?php echo $lang->$moduleType->order;?></th>
<td>
<?php foreach($orders as $order):?>
<?php $orderTitle = !empty($order->title) ? $order->title : $order->id;?>
<div><?php if(!commonModel::printLink('crm.order', 'view', "orderID={$order->id}", $orderTitle)) echo $orderTitle;?></div>
<?php endforeach;?>
</td>
</tr>
<?php $contractProducts = explode(',', trim($contract->product, ','));?>
<?php if(!empty($contractProducts)):?>
<tr>
<th><?php echo $lang->order->product;?></th>
<td>
<?php foreach($contractProducts as $productID):?>
<span><?php echo zget($products, $productID, '');?> </span>
<?php endforeach;?>
</td>
</tr>
<?php endif;?>
<?php endif;?>
<tr>
<th><?php echo $lang->$moduleType->amount;?></th>
<td><?php echo zget($currencySign, $contract->currency, '') . formatMoney($contract->amount);?></td>
</tr>
<?php if($contract->return == 'doing'):?>
<tr>
<th><?php echo $lang->$moduleType->unReturn;?></th>
<td><?php echo formatMoney($contract->unReturn) ? (zget($currencySign, $contract->currency, '') . formatMoney($contract->unReturn)) : 0;?></td>
</tr>
<?php endif;?>
<?php if($moduleType == 'contract'):?>
<tr>
<th class='w-70px'><?php echo $lang->$moduleType->delivery;?></th>
<td><?php echo $lang->$moduleType->deliveryList[$contract->delivery];?></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->$moduleType->return;?></th>
<td><?php echo $lang->$moduleType->returnList[$contract->return];?></td>
</tr>
<tr>
<th><?php echo $lang->$moduleType->status;?></th>
<td><?php echo $lang->$moduleType->statusList[$contract->status];?></td>
</tr>
<tr>
<th><?php echo $lang->$moduleType->contact;?></th>
<td><?php if(isset($contacts[$contract->contact]) and trim($contacts[$contract->contact]) != "") echo html::a($this->createLink('contact', 'view', "contactID={$contract->contact}"), $contacts[$contract->contact]);?></td>
</tr>
<?php if($moduleType == 'contract'):?>
<tr>
<th><?php echo $lang->$moduleType->address;?></th>
<td><?php echo zget($addresses, $contract->address, '');?></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->$moduleType->begin;?></th>
<td><?php echo formatTime($contract->begin, DT_DATE1);?></td>
</tr>
<tr>
<th><?php echo $lang->$moduleType->end;?></th>
<td><?php echo formatTime($contract->end, DT_DATE1);?></td>
</tr>
<?php if($moduleType == 'contract'):?>
<tr>
<th><?php echo $lang->$moduleType->handlers;?></th>
<td>
<?php
foreach(explode(',', $contract->handlers) as $handler)
{
if($handler and isset($users[$handler])) echo $users[$handler] . ' ';
}
?>
</td>
</tr>
<?php endif;?>
</table>
</div>
</div>
<?php if($moduleType == 'contract' && $members):?>
<div class='panel panel-block'>
<div class='panel-body'>
<table id='memberTable' class='table table-borderless table-fixed'>
<thead>
<tr class='text-center'>
<th class='text-left'><?php echo $lang->$moduleType->team->common . $lang->$moduleType->team->account;?></th>
<th class='w-90px'><?php echo $lang->$moduleType->team->contribution;?></th>
<th class='w-90px'><?php echo $lang->$moduleType->team->rate;?></th>
<th class='w-90px'><?php echo $lang->$moduleType->team->status;?></th>
</tr>
</thead>
<tbody>
<?php foreach($members as $member):?>
<tr class='text-center'>
<td class='text-left'><?php echo zget($users, $member->account);?></td>
<td><?php echo $member->contribution == 0 ? '' : $member->contribution;?></td>
<td><?php echo $member->rate == 0 ? '' : $member->rate;?></td>
<td class='team-<?php echo $member->status;?>'>
<?php
$status = zget($lang->$moduleType->team->statusList, $member->status);
$canConfirm = $member->account == $this->app->user->account && commonModel::hasPriv('crm.contract', 'confirmTeam');
if($member->status == 'wait' && $canConfirm)
{
echo html::a(inlink('confirmTeam', "contractID={$contract->id}&status=accept"), $lang->$moduleType->team->accept, "class='btn btn-xs jsoner'");
echo html::a(inlink('confirmTeam', "contractID={$contract->id}&status=reject"), $lang->$moduleType->team->reject, "class='btn btn-xs jsoner'");
}
elseif($member->status == 'reject' && $canConfirm)
{
echo html::a(inlink('confirmTeam', "contractID={$contract->id}"), $status);
}
else
{
echo $status;
}
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
<?php endif;?>
<?php if(!empty($contract->returnList)):?>
<div class='panel panel-block'>
<div class='panel-body'>
<table class='table table-borderless table-fixed'>
<thead>
<tr class='text-center'>
<th class='w-80px text-left'><?php echo $lang->$moduleType->returnRecords;?></th>
<th class='w-80px'><?php echo $lang->$moduleType->returnedBy;?></th>
<th class='text-right'><?php echo $lang->$moduleType->amount;?></th>
<th class='w-60px'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?php foreach($contract->returnList as $return):?>
<tr class='text-center'>
<td><?php echo formatTime($return->returnedDate, DT_DATE1);?></td>
<td><?php echo zget($users, $return->returnedBy, $return->returnedBy);?></td>
<td class='text-right'><?php echo zget($currencySign, $return->currency, '') . formatMoney($return->amount);?></td>
<td>
<?php commonModel::printLink($moduleType, 'editReturn', "id=$return->id", "<i class='icon-pencil'></i>", "data-toggle='modal' title='{$lang->edit}'");?>
<?php commonModel::printLink($moduleType, 'deleteReturn', "id=$return->id", "<i class='icon-remove'></i>", "class='deleter' title='{$lang->delete}'");?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
<?php endif;?>
<?php if($moduleType == 'contract' && !empty($contract->deliveryList)):?>
<div class='panel panel-block'>
<div class='panel-body'>
<table class='table table-borderless table-fixed'>
<thead>
<tr class='text-center'>
<th class='w-80px text-left'><?php echo $lang->$moduleType->deliveryRecords;?></th>
<th class='w-80px'><?php echo $lang->$moduleType->deliveredBy;?></th>
<th><?php echo $lang->comment;?></th>
<th class='w-50px'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?php foreach($contract->deliveryList as $delivery):?>
<tr class='text-center'>
<td><?php echo formatTime($delivery->deliveredDate, DT_DATE1);?></td>
<td><?php echo zget($users, $delivery->deliveredBy, $delivery->deliveredBy);?></td>
<td class='c-name' title='<?php echo $delivery->comment;?>'><?php echo $delivery->comment;?></td>
<td>
<?php commonModel::printLink($moduleType, 'editDelivery', "id=$delivery->id", "<i class='icon-pencil'></i>", "data-toggle='modal' title='{$lang->edit}'");?>
<?php commonModel::printLink($moduleType, 'deleteDelivery', "id=$delivery->id", "<i class='icon-remove'></i>", "class='deleter' title='{$lang->delete}'");?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
<?php endif;?>
<div class='panel panel-block'>
<div class='panel-heading'>
<strong><?php echo $lang->$moduleType->lifetime;?></strong>
</div>
<div class='panel-body'>
<table class='table table-data' id='contractLife'>
<tr>
<th class='w-60px'><?php echo $lang->$moduleType->createdBy;?></th>
<td><?php echo zget($users, $contract->createdBy, $contract->createdBy) . $lang->at . formatTime($contract->createdDate, DT_DATETIME1);?></td>
</tr>
<tr>
<th><?php echo $lang->$moduleType->signedBy;?></th>
<td><?php if($contract->signedBy) echo zget($users, $contract->signedBy, $contract->signedBy) . $lang->at . formatTime($contract->signedDate, DT_DATE1);?></td>
</tr>
<?php if($moduleType == 'contract'):?>
<tr>
<th><?php echo $lang->$moduleType->deliveredBy;?></th>
<td><?php if($contract->deliveredBy) echo zget($users, $contract->deliveredBy, $contract->deliveredBy) . $lang->at . formatTime($contract->deliveredDate, DT_DATE1);?></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->$moduleType->returnedBy;?></th>
<td><?php if($contract->returnedBy) echo zget($users, $contract->returnedBy, $contract->returnedBy) . $lang->at . formatTime($contract->returnedDate, DT_DATE1);?></td>
</tr>
<tr>
<th><?php echo $lang->$moduleType->finishedBy;?></th>
<td><?php if($contract->finishedBy) echo zget($users, $contract->finishedBy, $contract->finishedBy) . $lang->at . formatTime($contract->finishedDate, DT_DATE1);?></td>
</tr>
<tr>
<th><?php echo $lang->$moduleType->canceledBy;?></th>
<td><?php if($contract->canceledBy) echo zget($users, $contract->canceledBy, $contract->canceledBy) . $lang->at . formatTime($contract->canceledDate, DT_DATE1);?></td>
</tr>
<tr>
<th><?php echo $lang->$moduleType->editedBy;?></th>
<td><?php if($contract->editedBy) echo zget($users, $contract->editedBy, $contract->editedBy) . $lang->at . formatTime($contract->editedDate, DT_DATETIME1);?></td>
</tr>
</table>
</div>
</div>
<?php echo $this->printExtendFields($contract, 'div', "position=right&inCell=1&inForm=0");?>
</div>
</div>
<?php if($moduleType == 'contract'):?>
<script>
<?php helper::import('../js/team.js');?>
</script>
<?php endif;?>
<?php include '../../common/view/footer.html.php';?>