|
@@ -0,0 +1,323 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Option\Lib;
|
|
|
+
|
|
|
+use Dever;
|
|
|
+
|
|
|
+class Agreement
|
|
|
+{
|
|
|
+ private $font_size = 12;
|
|
|
+
|
|
|
+
|
|
|
+ public function show_api()
|
|
|
+ {
|
|
|
+ $p = Dever::input('p');
|
|
|
+ if (!$p) {
|
|
|
+ Dever::alert('传入参数有误');
|
|
|
+ }
|
|
|
+ $p = Dever::json_decode(Dever::decode($p));
|
|
|
+ if (!$p) {
|
|
|
+ Dever::alert('传入参数有误');
|
|
|
+ }
|
|
|
+ $source = $p['source'];
|
|
|
+ if ($source == 2) {
|
|
|
+
|
|
|
+ $aid = Dever::load('passport/user')->check(false);
|
|
|
+ $aid = 18;
|
|
|
+ if (!$aid || $aid <= 0) {
|
|
|
+ Dever::alert('请先登录');
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Dever::load('manage/auth')->init();
|
|
|
+ $aid = false;
|
|
|
+ }
|
|
|
+ $agreement_id = $p['agreement_id'];
|
|
|
+ $status = $p['status'];
|
|
|
+ $id = $p['id'];
|
|
|
+
|
|
|
+ if ($status == 1) {
|
|
|
+ $info = Dever::db('option/account')->find($id);
|
|
|
+ $info['aid'] = $id;
|
|
|
+ $info['create_state'] = 2;
|
|
|
+ } elseif ($status == 2) {
|
|
|
+ $info = Dever::db('option/agreement')->find($id);
|
|
|
+ if (!$info) {
|
|
|
+ Dever::alert('未生成合同');
|
|
|
+ }
|
|
|
+ $info['create_state'] = 1;
|
|
|
+ $agreement_id = $info['agreement_id'];
|
|
|
+ }
|
|
|
+ $agreement = Dever::db('setting/agreement')->find($agreement_id);
|
|
|
+ if (!$agreement) {
|
|
|
+ Dever::alert('合同模板不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($aid && $aid != $info['aid']) {
|
|
|
+ Dever::alert('您没有权限查看');
|
|
|
+ }
|
|
|
+
|
|
|
+ $method = 'pdf_' . $agreement['type'];
|
|
|
+ return $this->$method($agreement, $info);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function location_api()
|
|
|
+ {
|
|
|
+ Dever::load('manage/auth')->init();
|
|
|
+ $id = Dever::input('id');
|
|
|
+ $info = Dever::db('option/agreement')->find($id);
|
|
|
+ $info = $this->name($info['agreement_id'], $info, 2, 3);
|
|
|
+
|
|
|
+ Dever::location($info[1]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function name($agreement, $info, $status = -1, $source = 1)
|
|
|
+ {
|
|
|
+ if (is_numeric($agreement)) {
|
|
|
+ $agreement = Dever::db('setting/agreement')->find($agreement);
|
|
|
+ }
|
|
|
+ $name = $agreement['name'];
|
|
|
+ if (strstr($name, '{name}')) {
|
|
|
+ $name = str_replace('{name}', $info['name'], $name);
|
|
|
+ }
|
|
|
+ if (strstr($name, '{date}')) {
|
|
|
+ if (isset($info['sdate'])) {
|
|
|
+ $sdate = date('Y年m月d日', $info['sdate']);
|
|
|
+ } else {
|
|
|
+ $sdate = date('Y年m月d日');
|
|
|
+ }
|
|
|
+ $name = str_replace('{date}', $sdate, $name);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($status > 0) {
|
|
|
+ $param = array();
|
|
|
+ $param['source'] = $source;
|
|
|
+ $param['status'] = $status;
|
|
|
+ $param['id'] = $info['id'];
|
|
|
+ $param['agreement_id'] = $agreement['id'];
|
|
|
+ $param = Dever::encode(Dever::json_encode($param));
|
|
|
+ $link = Dever::url('option/lib/agreement.show?p=' . $param);
|
|
|
+ if ($source == 1) {
|
|
|
+
|
|
|
+
|
|
|
+ $name = '<a href="'.$link.'" target="_blank">'.$name.'</a>';
|
|
|
+ } else {
|
|
|
+ return array($name, $link);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $name;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function up($account)
|
|
|
+ {
|
|
|
+ $agreement = Dever::db('setting/agreement')->find(array('type' => 6));
|
|
|
+ if (!$agreement) {
|
|
|
+ Dever::alert('协议模板不存在');
|
|
|
+ }
|
|
|
+ $qdate = time();
|
|
|
+ $sdate = $qdate;
|
|
|
+ $edate = strtotime('+3 year', $sdate);
|
|
|
+ $where['aid'] = $account['id'];
|
|
|
+ $where['agreement_id'] = $agreement['id'];
|
|
|
+
|
|
|
+ $info = Dever::db('option/agreement')->find($where);
|
|
|
+
|
|
|
+ $where['order_num'] = $this->getOrderId();
|
|
|
+ $where['agreement_name'] = $this->name($agreement, $account);
|
|
|
+ $where['sign'] = $account['sign'];
|
|
|
+ $where['name'] = $account['name'];
|
|
|
+ $where['mobile'] = $account['mobile'];
|
|
|
+ $where['idcard'] = $account['idcard'];
|
|
|
+ $where['idcard_front'] = $account['idcard_front'];
|
|
|
+ $where['idcard_back'] = $account['idcard_back'];
|
|
|
+ $where['address'] = '';
|
|
|
+ $where['status'] = 2;
|
|
|
+ $where['udate'] = $where['cdate'] = time();
|
|
|
+ $where['qdate'] = $qdate;
|
|
|
+ $where['sdate'] = $sdate;
|
|
|
+ $where['edate'] = $edate;
|
|
|
+
|
|
|
+ $method = 'content_' . $agreement['type'];
|
|
|
+
|
|
|
+ if ($info) {
|
|
|
+ $up['content'] = Dever::array_encode($this->$method($agreement, $info));
|
|
|
+ $up['where_id'] = $info['id'];
|
|
|
+ $state = Dever::db('option/agreement')->update($up);
|
|
|
+ } else {
|
|
|
+ $up = $where;
|
|
|
+ $up['content'] = Dever::array_encode($this->$method($agreement, $account));
|
|
|
+ $state = Dever::db('option/agreement')->insert($up);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function upContent($id)
|
|
|
+ {
|
|
|
+ $state = false;
|
|
|
+ $info = Dever::db('option/agreement')->find($id);
|
|
|
+ if ($info) {
|
|
|
+ $agreement = Dever::db('setting/agreement')->find($info['agreement_id']);
|
|
|
+
|
|
|
+ if ($agreement) {
|
|
|
+ $method = 'content_' . $agreement['type'];
|
|
|
+ $up = array();
|
|
|
+ $up['content'] = Dever::array_encode($this->$method($agreement, $info));
|
|
|
+ $up['where_id'] = $info['id'];
|
|
|
+ $state = Dever::db('option/agreement')->update($up);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $state;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function drop($id)
|
|
|
+ {
|
|
|
+ $info = Dever::db('option/agreement')->find($id);
|
|
|
+ if ($info) {
|
|
|
+ $agreement = Dever::db('setting/agreement')->find($info['agreement_id']);
|
|
|
+
|
|
|
+ if ($agreement) {
|
|
|
+ $state = Dever::db('option/agreement')->update(array('where_id' => $info['id'], 'status' => 3));
|
|
|
+ if ($state) {
|
|
|
+
|
|
|
+ unset($info['id']);
|
|
|
+ unset($info['cdate']);
|
|
|
+ unset($info['sdate']);
|
|
|
+ unset($info['edate']);
|
|
|
+ unset($info['qdate']);
|
|
|
+ unset($info['sign']);
|
|
|
+ $member = Dever::db('option/account')->find($info['aid']);
|
|
|
+
|
|
|
+ $info['name'] = $member['name'];
|
|
|
+ $info['idcard'] = $member['idcard'];
|
|
|
+ $info['mobile'] = $member['mobile'];
|
|
|
+
|
|
|
+ $info['sign'] = '';
|
|
|
+ $info['status'] = 1;
|
|
|
+ Dever::db('option/agreement')->insert($info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 生成订单号
|
|
|
+ *
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getOrderId()
|
|
|
+ {
|
|
|
+ $where['order_num'] = Dever::order('AG');
|
|
|
+ $state = Dever::db('option/agreement')->one($where);
|
|
|
+ if (!$state) {
|
|
|
+ return $where['order_num'];
|
|
|
+ } else {
|
|
|
+ return $this->getOrderId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function content($name, $content)
|
|
|
+ {
|
|
|
+ return array('name' => $name, 'content' => $content);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function content_6($agreement, $info)
|
|
|
+ {
|
|
|
+ $content = array();
|
|
|
+ $content[] = $this->content('', ' 承诺人曾与中食民安(北京)科技有限公司(以下简称“中食民安”)签订《中食民安(北京)科技有限公司代理商合作协议》,为便于更好的工作,承诺人自愿成为中食民安的市场管理培训师并销售产品,为更好的开展相关工作,承诺如下:');
|
|
|
+
|
|
|
+ $content[] = $this->content('一、我知悉相关定义', '市场管理培训师(以下简称培训师):是培训和辅导其管理区域内其他代理商,在进行销售渠道的拓展、营销推广技巧、公司政策的传达和讲解的辅导后,达到提升销售额、完成业绩指标,并对其他代理商进行监督和管理的身份。');
|
|
|
+
|
|
|
+ $content[] = $this->content('二、我确认培训师与被培训人的关系', '1、培训师管理区域与《中食民安(北京)科技有限公司代理商合作协议》中授权区域保持一致。
|
|
|
+ 2、被培训人:指每个培训师管理区域内的其他代理,被培训人以中食民安规定方式签订《中食民安(北京)科技有限公司代理商合作协议》,即视为被培训人同意成为并自愿接受培训师的培训和管理。');
|
|
|
+
|
|
|
+ $content[] = $this->content('三、培训师及被培训人的权利和义务', '1、培训师的权利
|
|
|
+ 1)培训师的服务费,按周结算,具体服务费标准与培训内容、培训时间另行约定;
|
|
|
+ 2)管理和被管理关系存续期间,根据实际的培训情况、政策讲解的掌握、业绩完成情况,进行综合评定,评定标准见《市场管理培训费》,完成考核的培训师在每个奖励周期相应收益(包括物质和荣誉奖励,愿意服从中食民安根据实际完成情况及市场状态等定期或不定期调整奖励内容及标准)
|
|
|
+ 2、培训师的义务
|
|
|
+ 1)及时传达中食民安各项新颁布的通知、公告等各类文件并将内容解读清楚;
|
|
|
+ 2)每周不少于三次,对被培训人进行业务培训,包括社群的建立、销售技巧、销售渠道拓展、客户服务、如何办理沙龙等;
|
|
|
+ 3)随时帮助被培训人解决实际销售中遇到的任何问题。
|
|
|
+ 3、被培训人的义务
|
|
|
+ 1)督促并指导被培训人按照中食民安要求进行招商活动,接受中食民安监管;
|
|
|
+ 2)督促并指导被培训人在培训师的培训指导下,积极开拓市场,努力完成业绩。
|
|
|
+ ');
|
|
|
+
|
|
|
+ $content[] = $this->content('四、其它', '1、培训师与被培训人,合作过程中出现任何争议,可申请中食民安进行协调;
|
|
|
+ 2、本承诺书作为《中食民安(北京)科技有限公司代理商合作协议》的附件,是《中食民安(北京)科技有限公司代理商合作协议》的不可分割部分,我愿意遵守。
|
|
|
+ ');
|
|
|
+
|
|
|
+ return $content;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function pdf_6($agreement, $info)
|
|
|
+ {
|
|
|
+ $base = Dever::db('setting/base')->find();
|
|
|
+
|
|
|
+ if (isset($info['qdate']) && $info['qdate']) {
|
|
|
+ $qdate = date('Y年m月d日', $info['qdate']);
|
|
|
+ } else {
|
|
|
+ $qdate = date('Y年m月d日');
|
|
|
+ }
|
|
|
+ $name = $this->name($agreement, $info);
|
|
|
+
|
|
|
+ $pdf = Dever::load('pdf/lib/core')->init();
|
|
|
+ $pdf->SetTitle($name);
|
|
|
+ $pdf->setCellHeightRatio(1.8);
|
|
|
+ $pdf->setCellPaddings(10, 0, 10, 0);
|
|
|
+ $pdf->font(18, 'B');
|
|
|
+ $pdf->center('市场管理培训师承诺书');
|
|
|
+ $pdf->br();
|
|
|
+ $pdf->font($this->font_size, 'B');
|
|
|
+ $pdf->left('承诺人:' . $info['name']);
|
|
|
+ $pdf->left('身份证号:' . $info['idcard']);
|
|
|
+ $pdf->left('电话:' . $info['mobile']);
|
|
|
+ $pdf->br(2);
|
|
|
+
|
|
|
+ if (isset($info['content']) && $info['content']) {
|
|
|
+ $info['content'] = Dever::array_decode($info['content']);
|
|
|
+ foreach($info['content'] as $k => $v) {
|
|
|
+ $pdf->content($v['name'], $v['content'], $this->font_size);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $method = 'content_' . $agreement['type'];
|
|
|
+ $content = $this->$method($agreement, $info);
|
|
|
+
|
|
|
+ foreach ($content as $k => $v) {
|
|
|
+ $pdf->content($v['name'], $v['content'], $this->font_size);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($info['create_state']) && $info['create_state'] == 1) {
|
|
|
+ $up = array();
|
|
|
+ $up['content'] = Dever::array_encode($content);
|
|
|
+ $up['where_id'] = $info['id'];
|
|
|
+ $state = Dever::db('option/agreement')->update($up);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $pdf->center(' 承诺人:');
|
|
|
+ $pdf->center(' 日期:' . $qdate);
|
|
|
+
|
|
|
+ $pic = Dever::pic($base['agreement_sign']);
|
|
|
+
|
|
|
+ $cx = $pdf->GetX();
|
|
|
+ $cy = $pdf->GetY();
|
|
|
+
|
|
|
+ $x = $cx - 50;
|
|
|
+ $y = $cy - 15;
|
|
|
+
|
|
|
+ if ($info['sign']) {
|
|
|
+ $info['sign'] = Dever::pic($info['sign']);
|
|
|
+ if (strstr($info['sign'], 'http')) {
|
|
|
+ $pdf->Image($info['sign'], $x, $y, 20, 20);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $pdf->out($name);
|
|
|
+ }
|
|
|
+}
|