Commit 524e81d3 by 朱继来

fix

parents 4422d7a0 96e8a533
Showing with 1423 additions and 382 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -732,10 +732,10 @@ Class AddOrderController extends Controller
array_shift($excel); // 删除第一行
// 推送到API
$data['data'] = $excel;
$data['operator_id'] = $request->user->userId;
$data['type'] = 3; // 后台批量添加标记
$data['uid'] = $request->input('user_id');
$data['data'] = $excel;
$data['operator_id'] = $request->user->userId;
$data['type'] = 3; // 后台批量添加标记
$data['uid'] = $request->input('user_id');
$data['delivery_place'] = $request->input('delivery_place');
if ($type == 1) { // 联营
......@@ -810,9 +810,25 @@ Class AddOrderController extends Controller
public function addGoods(Request $request)
{
if ($request->isMethod('post')) {
$add_type = $request->input('add_type', ''); // 新增类型
if ($add_type) {
$data['add_goods_name'] = $request->input('add_goods_name', '');
$data['add_brand_name'] = $request->input('add_brand_name', '');
$data['add_supplier_name'] = $request->input('add_supplier_name', '');
$data['add_goods_number'] = $request->input('add_goods_number', 0);
$data['add_goods_price'] = $request->input('add_goods_price', 0);
$data['add_delivery_time'] = $request->input('add_delivery_time', '');
$data['add_buyer_id'] = $request->input('add_buyer_id', 0);
$data['add_batch'] = $request->input('add_batch', '');
$data['add_remarks'] = $request->input('add_remarks', '');
} else {
$data['goods_id'] = $request->input('goods_id');
$data['goods_num'] = $request->input('goods_num');
}
$data['order_id'] = $request->input('order_id');
$data['goods_id'] = $request->input('goods_id');
$data['goods_num'] = $request->input('goods_num');
$data['add_type'] = $add_type;
$data['operator_id'] = $request->user->userId;
$url = Config('website.order_api_domain').'/order/addgoods';
......
......@@ -193,15 +193,40 @@ class ApiController extends Controller
$data['id'] = $request->input('id');
$data['remarks'] = $request->input('remarks');
$data['buyer_id'] = $request->input('buyer_id');//采购id
$data['batch'] = $request->input('batch');//采购id
if($data['buyer_id'] == -1){
unset($data['buyer_id']);
}
$result = $OrderItemsModel->updateData($data);
if($result){
$this->Export($result, 'success');
$this->Export(0, '编辑明细成功');
}else{
$this->Export($result, 'error');
$this->Export(1, '编辑明细失败');
}
}
/*
检查内部系统用户是否存在
*/
public function check_user_exists($request){
$CmsModel = new CmsModel();
$userName = $request->input('user');
$user_info = $CmsModel->getUserInfo(array('name'=>$userName));
if($user_info){
$this->Export(1, 'success',$user_info['userId']);
}else{
$this->Export(-1, 'error');
}
}
}
......@@ -13,4 +13,23 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
// 二维数组,针对某个键名去重
public function assoc_unique($arr, $key='userId')
{
if (!$arr) return false;
$tmp = [];
foreach ($arr as $k=>$v) {
if (in_array($v->$key, $tmp)) {
unset($arr[$k]);
} else {
$tmp[] = $v->$key;
}
}
return array_merge($arr); // 重新索引
}
}
......@@ -17,6 +17,8 @@ use App\Model\UserMainModel;
use App\Model\OrderActionLogModel;
use App\Model\OrderReturnModel;
use App\Model\OrderItemsTrackModel;
use App\Model\CmsModel;
use App\Model\QueuedModel;
use Session;
use Hprose\Http\Client;
......@@ -398,13 +400,15 @@ Class OrderController extends Controller
$info = $this->getPageInfo($request);
$map = array();
// 页面参数
$map['order_type'] = $request->input('order_type', '');
$map['select_time_val'] = $request->input('select_time_val', '');
$map['order_contain'] = $request->input('order_contain', '');
$map['order_sn'] = $request->input('order_sn', '');
$map['erp_sn'] = $request->input('erp_sn', '');
$map['goods_name'] = $request->input('goods_name', '');
$map['select_time_type'] = $request->input('select_time_type', '');
$map['time_start'] = $request->input('time_start', '');
$map['time_end'] = $request->input('time_end', '');
$map['order_status'] = $request->input('order_status', '');
......@@ -493,7 +497,7 @@ Class OrderController extends Controller
public function getOrderInfo($request, $tid=1)
{
$info = $this->_search($request, $tid);
$key = Config('perm_args.redis_search_sales')[$tid];
$redis = Redis::connection('read');
$sale_list = $redis->get($key);
......@@ -568,24 +572,6 @@ Class OrderController extends Controller
return $info;
}
// 二维数组,针对某个键名去重
public function assoc_unique($arr, $key='userId')
{
if (!$arr) return false;
$tmp = [];
foreach ($arr as $k=>$v) {
if (in_array($v->$key, $tmp)) {
unset($arr[$k]);
} else {
$tmp[] = $v->$key;
}
}
return array_merge($arr); // 重新索引
}
// 订单其他信息
public function orderOtherInfoLoading(Request $request)
{
......@@ -746,6 +732,7 @@ Class OrderController extends Controller
public function templateData(Request $request, $id, $view_id)
{
$info = $this->orderDetail($request, $id);
$this->pageHeader($request, $info, '订单详情');
if ($info['order_info']['order_goods_type'] == 2 && in_array($info['order_info']['order_type'], [1, 3])) { // 平台自营订单
......@@ -754,11 +741,52 @@ Class OrderController extends Controller
} else {
$this->selfOtherData($info, $id);
}
} else {
$perm = new PermController;
$info['buyers'] = $perm->getRoleUsers($request, '采购员');
$key = Config('perm_args.redis_search_sales')[1];
$redis = Redis::connection('read');
$sale_list = json_decode($redis->get($key));
$info['cc_sales'] = $sale_list ? array_merge($info['buyers'], $sale_list) : $info['buyers'];
}
return view($view_id, $info);
}
/*
获取采购人名称
*/
public function getBuyerName(&$info){
if(count($info['order_items_info']) <=0){
return;
}
foreach ($info['order_items_info'] as $key => $value) {
$data[] = $value['buyer_id'];
}
$CmsModel = new CmsModel();
$name_data = $CmsModel->getBatchUserName($data);
foreach ($info['order_items_info'] as $key => $value) {
foreach ($name_data as $k => $v) {
if($v['userId'] == $value['buyer_id']){
$info['order_items_info'][$key]['buyerName'] = $v['name'];
$info['order_items_info'][$key]['send_email'] = $v['email'];
break;//找到了就不必再循环这个数组了
}
}
}
}
// 详情页自营其他数据
public function selfOtherData(&$info, $order_id)
{
......@@ -789,6 +817,7 @@ Class OrderController extends Controller
public function changeOrder(Request $request, $id)
{
$info = $this->orderDetail($request, $id);
$this->pageHeader($request, $info, '人工审单', ["title" => '人工审单', "href" => '#']);
if ($info['order_info']['order_goods_type'] == 2 && in_array($info['order_info']['order_type'], [1, 3])) { // 平台自营订单
......@@ -797,6 +826,9 @@ Class OrderController extends Controller
} else {
$this->selfOtherData($info, $id);
}
} else {
$perm = new PermController;
$info['buyers'] = $perm->getRoleUsers($request, '采购员');
}
// 账期订单跳转到详情页
......@@ -1548,6 +1580,9 @@ Class OrderController extends Controller
$response = array_merge($response, $info);
// 获取数组中的采购人id的名字
$this->getBuyerName($response);
return $response;
}
......@@ -2019,4 +2054,120 @@ Class OrderController extends Controller
});
}
/*
发送邮件
*/
public function send_mail(Request $request)
{
$id = $request->input('id');
$cc_email = $request->input('cc_email', '');
$info = $this->orderDetail($request, $id);
//循环订单详情
foreach ($info['order_items_info'] as $key => $value) {
$tmp['orderNum'] = $info['order_temp_info']['erp_sn'];
$tmp['goods'] = $value['goods_name'];
$tmp['purchasingPrice'] = $value['goods_price'];//采购价
$tmp['unitPrice'] = $value['goods_price'];//单价
$tmp['brand'] = $value['brand_name'];
$tmp['nums'] = $value['goods_number'];
$tmp['currency'] = $info['order_info']['currency'] == 1?'人民币':'美元';
$tmp['totalPrice'] = $value['goods_amount'];
$tmp['remarks'] = $value['remarks'];
$tmp['material'] = $value['erp_rec_id'];
$tmp['purchasing'] = !empty($value['buyerName'])?$value['buyerName']:'';
$tmp['projectId'] = $key+1;
if(empty($value['batch'])){
$msg = '商品:'.$tmp['goods'].'缺少批次<br/>'.'请填写批次后再发送';
echo json_encode(['errcode'=>-1,'errmsg'=>$msg]);
exit;
}
if(empty($value['buyerName'])){
$msg = '商品:'.$tmp['goods'].'缺少采购人员<br/>'.'请填写采购后再发送';
echo json_encode(['errcode'=>-1,'errmsg'=>$msg]);
exit;
}
//批次
$tmp['deliveryTime'] = $value['batch'];
$tmp['send_email'] = !empty($value['send_email'])?$value['send_email']:'';
$data['data'][] = $tmp;
}
//循环出邮件接收人
foreach ($data['data'] as $key => $value) {
$send_mail_array[] = $value['send_email'];
}
$send_mail_array = array_unique($send_mail_array);
if(empty($send_mail_array[0])){
echo json_encode(['errcode'=>-1,'errmsg'=>'没有填写采购人员,请至少填写一个采购人员']);
exit;
}
$data['toUser'] = $send_mail_array; // 收件人
$cc_send_mail_array = Config('config.cc_email'); // 固定抄送人
$cc_email_arr = [];
if ($cc_email) { // 后台选择的抄送人
$CmsModel = new CmsModel();
foreach ($cc_email as $v) {
$email = $CmsModel->getUserName($v, 'email');
$email && $cc_email_arr[] = $email;
}
}
$data['ccUser'] = array_unique(array_merge($cc_send_mail_array, $cc_email_arr));
$data['combined'] = $info['order_info']['order_amount'];
$data['order_amount'] = $info['order_info']['order_amount'];
$data['date'] = date('Y-m-d',time());
$data['kefu_remark'] = $info['order_temp_info']['kefu_remark']; // 客服备注
$CmsModel = new CmsModel();
$data['id'] = $CmsModel->getUserName($info['order_info']['sale_id']); //获取业务员
$data['order_id'] = intval($id);
$data['operator_id'] = intval($request->user->userId);
$data['operator_event'] = '发送邮件成功,收件人邮箱:'.json_encode($send_mail_array).',抄送人邮箱:'.json_encode($data['ccUser']);
// 推入到邮件队列
$QueuedModel = new QueuedModel();
$queued_name = 'send_buyer_mail';
$QueuedModel->pushAmq('ichunt_order_msg', $queued_name, $queued_name, json_encode($data));
return ['errcode'=>0, 'errmsg'=>'推送到邮件队列成功,请稍等...'];
// $crm_url = Config('website.crm_domain').'/api/sendCaiGouEmailByOrderAdmin';
// $data = json_encode($data);
// $crm_header = array('api-key: crm a1b2c3d4e5f6g7h8i9jk');
// $res = json_decode(post_curl($crm_url, $data,$crm_header));
// if(!empty($res->err_code) && $res->err_code == 0){
// // 操作日志
// $OrderActionLogModel = new OrderActionLogModel();
// $event = '发送邮件成功,收件人邮箱:'.json_encode($send_mail_array).',抄送人邮箱:'.json_encode($data['ccUser']);
// $actionLog = $OrderActionLogModel->addLog($id, $request->user->userId, 2, $event);
// echo json_encode(['errcode'=>1,'errmsg'=>'发送成功']);
// exit;
// }else{
// echo json_encode(['errcode'=>-1,'errmsg'=>'邮件发送接口错误,邮件发送失败']);
// exit;
// }
}
}
\ No newline at end of file
......@@ -118,6 +118,8 @@
foreach ($role as $v) {
$department = DB::table('t_role_perm')->where(['roleId' => $v, 'bid' => $bid])->first();
if (!isset($department->name)) continue;
$user_role[] = in_array($department->name, array_keys(Config('perm_args.roles'))) ? array_get(Config('perm_args.roles'), $department->name) : 0;
}
......@@ -141,10 +143,10 @@
$role = DB::table('t_role_perm')->where(['bid' => $bid, 'name' => $roleName])->first();
$roleId = $role->roleId;
$roleId = isset($role->roleId) ? $role->roleId : 0;
// $user = DB::select("SELECT * FROM `t_user_perm` WHERE `bid` = $bid AND `roles` REGEXP $roleId");
$user = DB::select("SELECT * FROM `t_user_perm` WHERE `bid` = $bid AND `roles` LIKE '%\"".$roleId."\"%'");
$user = DB::select("SELECT * FROM `t_user_perm` WHERE `bid` = $bid AND `roles` LIKE '%\"".$roleId."\"%' ORDER BY `mtime`");
if ($user) {
foreach ($user as $v) {
......
......@@ -11,6 +11,7 @@ use App\Model\OrderReturnItemsModel;
use DB;
use App\Http\Page;
use App\Model\UserMainModel;
use Illuminate\Support\Facades\Redis;
// 获取支付名称
function getPayName($order_id)
......@@ -164,11 +165,39 @@ class ReturnController extends Controller
$info['count'] = $response['data']['count'];
$info['page'] = $show;
$perm = new PermController;
$joint_kefu = $perm->getRoleUsers($request, '客服');
$self_kefu = $perm->getRoleUsers($request, '自营客服');
// $perm = new PermController;
// $joint_kefu = $perm->getRoleUsers($request, '客服');
// $self_kefu = $perm->getRoleUsers($request, '自营客服');
// $info['sale_list'] = array_merge($joint_kefu, $self_kefu);
$key = 'search_self_sales';
$redis = Redis::connection('read');
$sale_list = $redis->get($key);
if (!$sale_list) {
// 获取所有的业务员 (包括经理、交易员、客服、测试)
$perm = new PermController;
$sale_list = [];
$search_sales = Config('perm_args.search_self_sales');
if ($search_sales) {
foreach ($search_sales as $v) {
$role_name = array_keys(Config('perm_args.roles'), $v);
$temp = $perm->getRoleUsers($request, $role_name[0]);
$sale_list = array_merge($sale_list, $temp);
}
}
$sale_list = $this->assoc_unique($sale_list);
$expire = Config('perm_args.redis_search_sales_expire'); // 缓存两小时
Redis::setex($key, $expire, json_encode($sale_list));
} else {
$sale_list = json_decode($sale_list);
}
$info['sale_list'] = array_merge($joint_kefu, $self_kefu);
$info['sale_list'] = $sale_list;
return $info;
}
......
......@@ -482,4 +482,29 @@ function S_hash($key, $field='', $value='')
}
return $redis->hset($key, $field, $value);
}
// curl post
function post_curl($url, $data, $headers = array(), $cookie ="")
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
if (count($headers)){
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
if ($cookie){
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if (strpos($url, 'https://') !== false) {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
\ No newline at end of file
......@@ -62,6 +62,7 @@ Route::group(['middleware' => 'web'], function () {
Route::resource('/prompt', 'PromptController@index');
Route::get('/count', 'OrderCountController@count');
Route::post('/send_mail', 'OrderController@send_mail');
Route::get('/self_count', 'OrderCountController@selfCount');
Route::get('/amount', 'OrderCountController@amount');
Route::get('/self_amount', 'OrderCountController@selfAmount');
......
......@@ -13,11 +13,39 @@ class CmsModel extends Model
public $timestamps = false;
// 获取用户名称
public function getUserName($userId)
public function getUserName($userId, $field='name')
{
$user = $this->where(['userId' => $userId])->select('name')->first();
$user = $this->where(['userId' => $userId])->select($field)->first();
return $user ? $user->name : '';
return $user ? $user->$field : '';
}
// 获取用户ID
public function getSaleId($name='')
{
if (!$name) return false;
$name && $map['name'] = $name;
$user = $this->where($map)->select('userId')->first();
return $user ? $user->userId : 0;
}
/*
查询cms系统用户信息
*/
public function getUserInfo($where){
return $this->where($where)->select('userId')->first();
}
/*
批量查询用户姓名
*/
public function getBatchUserName($user_ids){
return $this->whereIn('userId',$user_ids)->select('userId','name','email')->get()->toArray();
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use App\Jobs\Queue;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
class QueuedModel extends Model
{
public function pushAmq($exchange, $route_key, $queue_name, $content='')
{
$connection = new AMQPStreamConnection(env('RABBITMQ_HOST'), env('RABBITMQ_PORT'), env('RABBITMQ_LOGIN'), env('RABBITMQ_PASSWORD'), env('RABBITMQ_VHOST')); // 创建连接
$channel = $connection->channel();
$channel->exchange_declare($exchange, 'direct', false, true, false); // 初始化交换机
$channel->queue_declare($queue_name, false, true, false, false); // 初始化队列
$channel->queue_bind($queue_name, $exchange, $route_key); // 将队列与某个交换机进行绑定,并使用路由关键字
$message = new AMQPMessage($content);
$channel->basic_publish($message, '', $queue_name); // 推送消息
$channel->close();
$connection->close();
}
public function pullAmq($queue_name='')
{
$connection = new AMQPStreamConnection(env('RABBITMQ_HOST'), env('RABBITMQ_PORT'), env('RABBITMQ_LOGIN'), env('RABBITMQ_PASSWORD'), env('RABBITMQ_VHOST')); // 创建连接
$channel = $connection->channel();
$message = $channel->basic_get($queue_name); // 取出消息
echo '<pre>';
print_r($message);
$channel->basic_ack($message->delivery_info['delivery_tag']); // 确认取出消息后会发送一个ack来确认取出来了,然后会从rabbitmq中将这个消息移除,如果删掉这段代码,会发现rabbitmq中的消息还是没有减少
$channel->close();
$connection->close();
}
}
\ No newline at end of file
......@@ -13,7 +13,8 @@
"predis/predis": "^1.1",
"redgo/monitor-ding": "0.2",
"barryvdh/laravel-debugbar": "^2.0",
"hprose/hprose": "2.0"
"hprose/hprose": "2.0",
"php-amqplib/php-amqplib": "2.7"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
......
......@@ -15,4 +15,12 @@ return [
],
// 固定邮件抄送人
'cc_email' => [
'zgj@ichunt.com',
// 'alanl@ichunt.com',
// 'zhengjf@ichunt.com',
// 'zoe@ichunt.com',
],
];
......@@ -57,6 +57,9 @@
3 => 'goods_price',
4 => 'delivery_time',
5 => 'supplier_name',
6 => 'buyer_id',
7 => 'remarks',
8 => 'batch',
],
'self_map' => [
......
......@@ -5,7 +5,7 @@ return [
'管理员' => 1,
'经理' => 2,
'交易员' => 3,
'客服' => 4,
// '客服' => 4,
'测试' => 5,
'京东自营' => 6,
'自营客服' => 7,
......@@ -35,7 +35,7 @@ return [
],
// 筛选自己的订单
'kefu_order' => [3, 4, 7, 12, 15, 17, 19],
'kefu_order' => [3, 7, 12, 15, 17, 19],
// 主管角色,查看自己及其组员订单
'manager_order' => [14, 16, 18, 22],
......@@ -47,10 +47,10 @@ return [
'is_manager_perm' => [1, 2, 10, 11, 14, 16, 18, 22],
// 筛选业务员 -- 联营列表
'search_joint_sales' => [3, 4, 5, 14, 15, 16, 17, 18, 19, 22],
'search_joint_sales' => [3, 5, 14, 15, 16, 17, 18, 19, 22],
// 筛选业务员 -- 自营列表 (包含联营、自营客服、交易员、主管)
'search_self_sales' => [3, 4, 5, 7, 10, 11, 12, 14, 15, 16, 17, 18, 19, 22],
'search_self_sales' => [3, 5, 7, 10, 11, 12, 14, 15, 16, 17, 18, 19, 22],
// 缓存筛选业务员
'redis_search_sales' => [
......
......@@ -322,7 +322,7 @@
html += '<tr><th>阶梯</th><th>RMB价格</th>';
if (data.ac_type) {
if (data.ac_type && data.ac_type != 5) { // ac_type = 5 为新客价,目前后台不展示新客价
switch (data.ac_type) {
case 1: html += '<th>限时限量</th>'; break;
case 2: html += '<th>活动价</th>'; break;
......@@ -341,7 +341,7 @@
html += '<tr>';
if (i == 0) {
if (data.ac_type) {
if (data.ac_type && data.ac_type != 5) {
html += '<td><span class="goods-min-num">'+data.tiered[i]['purchases']+'</span></td><td>¥<span class="goods-min-price price-line">'+data.tiered[i]['price_cn']+'</span><td>¥<span>'+data.tiered[i]['price_ac']+'</span></td>';
} else {
html += '<td><span class="goods-min-num">'+data.tiered[i]['purchases']+'</span></td><td>¥<span class="goods-min-price">'+data.tiered[i]['price_cn']+'</span></td>';
......@@ -351,7 +351,7 @@
html += '<td>$<span class="goods-min-price-us">'+data.tiered[i]['price_us']+'</span></td>';
}
} else {
if (data.ac_type) {
if (data.ac_type && data.ac_type != 5) {
html += '<td><span>'+data.tiered[i]['purchases']+'</span></td><td>¥<span class="price-line">'+data.tiered[i]['price_cn']+'</span></td><td>¥<span>'+data.tiered[i]['price_ac']+'</span></td>';
} else {
html += '<td><span>'+data.tiered[i]['purchases']+'</span></td><td>¥<span>'+data.tiered[i]['price_cn']+'</span></td>';
......@@ -767,7 +767,10 @@
location.href = '/addorder/success?order_id='+resp.data.order_id+'&type='+resp.data.type;
return false;
}
} else if (resp.errcode == 21024) {
layer.alert('该用户已进入公司黑名单,具体请联系吴承义,同时订单无法提交');
return false;
}
layer.alert(resp.errmsg);
},
......
......@@ -80,6 +80,108 @@
})
})
$('.order-change-main').on('click', '.add_goods_no_skuid', function() {
layer.open({
area: ['600px'],
type: 1,
title: '新增商品',
content: $('#addGoodsNoSkuid'),
btn: ['新增', '取消'],
btn1: function() {
var order_id = $('#order_id').val();
var add_goods_name = $('input[name=add_goods_name]').val();
var add_brand_name = $('input[name=add_brand_name]').val();
var add_supplier_name = $('input[name=add_supplier_name]').val();
var add_goods_number = $('input[name=add_goods_number]').val();
var add_goods_price = $('input[name=add_goods_price]').val();
var add_delivery_time = $('input[name=add_delivery_time]').val();
var add_buyer_id = $('select[name=add_buyer_id]').val();
var add_batch = $('input[name=add_batch]').val();
var add_remarks = $('textarea[name=add_remarks]').val();
var reg = /\d/;
if (!add_goods_name) {
layer.msg('请输入商品名称');
return false;
}
if (!add_brand_name) {
layer.msg('请输入制造商');
return false;
}
if (!add_supplier_name) {
layer.msg('请输入供应商');
return false;
}
if (!add_goods_number) {
layer.msg('请输入采购数量');
return false;
}
if (!reg.test(add_goods_number)) {
layer.msg('格式错误,请输入正确的采购数量');
return false;
}
if (!add_goods_price) {
layer.msg('请输入采购单价');
return false;
}
if (!reg.test(add_goods_price)) {
layer.msg('格式错误,请输入正确的采购单价');
return false;
}
if (!add_delivery_time) {
layer.msg('请输入货期');
return false;
}
var datax = {
add_type: 1,
order_id: order_id,
add_goods_name: add_goods_name,
add_brand_name: add_brand_name,
add_supplier_name: add_supplier_name,
add_goods_number: add_goods_number,
add_goods_price: add_goods_price,
add_delivery_time: add_delivery_time,
add_buyer_id: add_buyer_id,
add_batch: add_batch,
add_remarks: add_remarks,
};
$.ajax({
type: "POST",
url: '/ajax/addGoods',
data: datax,
dataType: "json",
success: function(resp){
if(resp.errcode == 0){
layer.msg(resp.errmsg || '操作成功');
setTimeout(function(){
location.reload();
}, 1000);
return false;
} else {
layer.alert(resp.errmsg || '网络异常');
}
},
})
},
btn2: function(index) {
layer.close(index)
}
})
$("#add_buyer_id").selectpicker();
$('.layui-layer-content').css('overflow', 'visible');
})
// 获取SKU信息
$('.get-sku').click(function() {
var sku_id = $(this).siblings('.search-sku').val();
......@@ -144,7 +246,7 @@
html += '<tr><th>阶梯</th><th>RMB价格</th>';
if (data.ac_type) {
if (data.ac_type && data.ac_type != 5) { // ac_type = 5 为新客价,目前后台不展示新客价
switch (data.ac_type) {
case 1: html += '<th>限时限量</th>'; break;
case 2: html += '<th>活动价</th>'; break;
......@@ -163,7 +265,7 @@
html += '<tr>';
if (i == 0) {
if (data.ac_type) {
if (data.ac_type && data.ac_type != 5) {
html += '<td><span class="goods-min-num">'+data.tiered[i]['purchases']+'</span></td><td>¥<span class="goods-min-price price-line">'+data.tiered[i]['price_cn']+'</span><td>¥<span>'+data.tiered[i]['price_ac']+'</span></td>';
} else {
html += '<td><span class="goods-min-num">'+data.tiered[i]['purchases']+'</span></td><td>¥<span class="goods-min-price">'+data.tiered[i]['price_cn']+'</span></td>';
......@@ -173,7 +275,7 @@
html += '<td>$<span class="goods-min-price-us">'+data.tiered[i]['price_us']+'</span></td>';
}
} else {
if (data.ac_type) {
if (data.ac_type && data.ac_type != 5) {
html += '<td><span>'+data.tiered[i]['purchases']+'</span></td><td>¥<span class="price-line">'+data.tiered[i]['price_cn']+'</span></td><td>¥<span>'+data.tiered[i]['price_ac']+'</span></td>';
} else {
html += '<td><span>'+data.tiered[i]['purchases']+'</span></td><td>¥<span>'+data.tiered[i]['price_cn']+'</span></td>';
......
......@@ -247,7 +247,7 @@
<div class="batch-btn">
<a class="btn btn-success goods_import" data-type="1">批量导入物料</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%81%94%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.csv">联营物料模板下载</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%81%94%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.csv">联营物料模板下载</a>
</div>
</div>
</div>
......
<style>
#addGoodsNoSkuid{ display: none; }
#addGoodsNoSkuid input { width: 280px; height: 35px; }
#addGoodsNoSkuid textarea { width: 280px; }
</style>
<div id="addGoodsNoSkuid">
<div class="ibox-content form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label"><i class="error">*</i> 商品名称</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="add_goods_name" value="" placeholder="请输入商品名称">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label"><i class="error">*</i> 制造商</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="add_brand_name" value="" placeholder="请输入制造商">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label"><i class="error">*</i> 供应商</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="add_supplier_name" value="" placeholder="请输入供应商">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label"><i class="error">*</i> 采购数量</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="add_goods_number" value="" placeholder="请输入采购数量">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label"><i class="error">*</i> 采购单价</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="add_goods_price" value="" placeholder="请输入采购单价">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label"><i class="error">*</i> 货期</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="add_delivery_time" value="" placeholder="请输入货期">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label">采购员</label>
<div class="col-sm-8" style="width:310px;">
<select class="form-control" name="add_buyer_id" id="add_buyer_id" data-live-search="true" data-size="7">
<option value="">请选择采购员</option>
@if (isset($buyers))
@foreach ($buyers as $v)
<option value="{{ $v->userId }}">{{ $v->name }}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label">批次</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="add_batch" value="" placeholder="请输入批次">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label">备注</label>
<div class="col-sm-8">
<textarea class="form-control" name="add_remarks" rows="3" placeholder="请输入备注"></textarea>
</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -91,6 +91,10 @@
<div>
<p style="float: left;">调价</p>
<a class="btn btn-info add_goods" style="float: right; margin-bottom: 5px;">新增商品</a>
@if ($order_info['order_goods_type'] == 1)
<a class="btn btn-primary add_goods_no_skuid" style="float: right; margin-bottom: 5px; margin-right: 5px;">新增无SKUID</a>
@endif
</div>
<table class="table table-bordered table-hover order-change-table">
......@@ -496,6 +500,7 @@
@endif
@include('detail.addGoods')
@include('detail.addGoodsNoSkuid')
<script>
var is_manager = "{{ in_array($role, Config('perm_args.is_manager_perm')) ? true : false }}";
......
......@@ -38,14 +38,25 @@
</dd>
</dl>
<dl>
<dt>创建日期: </dt>
<dd style="width:auto !important;">
<input type="text" name="time_start" value="{{ !empty($condition['time_start']) ? date('Y/m/d', $condition['time_start']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="开始时间" autocomplete="off" />
<dd style="width: 110px;">
<div class="droplist" data-default="{{$condition['select_time_type']}}" id="select_time_type" name="select_time_type">
<ul class="dropdown-menu">
<li class="select_time_type_tab active" data-val="">创建日期</li>
<li class="select_time_type_tab" data-val="1">审核日期</li>
<li class="select_time_type_tab" data-val="2">收款日期</li>
<li class="select_time_type_tab" data-val="3">发货日期</li>
<li class="select_time_type_tab" data-val="4">订单完成</li>
</ul>
</div>
</dd>
<dd style="width:auto !important;">
<!-- <dt>创建日期: </dt> -->
<dd style="width: 120px;">
<input type="text" name="time_start" value="{{ !empty($condition['time_start']) ? date('Y/m/d', $condition['time_start']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="开始时间" autocomplete="off" style="width: 140px;" />
</dd>
<dd style="width: 120px; margin-left: 20px;">
<input type="text" name="time_end" value="{{ !empty($condition['time_end']) ? date('Y/m/d', $condition['time_end']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="结束时间" autocomplete="off" />
</dd>
</dl>
</dl>
<dl>
<dt>型号名称:</dt>
<dd>
......@@ -64,6 +75,9 @@
</select>
</dd>
</dl>
<dl>
<dt>付款类型:</dt>
<dd>
......@@ -87,29 +101,6 @@
</dd>
</dl>
<dl>
<dt>推送业务员:</dt>
<dd>
<select id="order_send" name="order_send" class="form-control order_send selectpicker" title="全部" data-live-search="true" data-size="7" multiple>
<!-- <option value="">全部</option> -->
<option value="0">无推送</option>
<optgroup label="在职">
@foreach ($sale_list as $v)
@if ($v->status != 4)
<option value="{{$v->userId}}">{{$v->name}}</option>
@endif
@endforeach
</optgroup>
<optgroup label="离职">
@foreach ($sale_list as $v)
@if ($v->status == 4)
<option value="{{$v->userId}}">{{$v->name}}</option>
@endif
@endforeach
</optgroup>
</select>
</dd>
</dl>
<dl>
<dt>支付方式:</dt>
<dd>
<select id="order_payment_mode" name="order_payment_mode" class="form-control order_payment_mode selectpicker" title="全部" multiple>
......@@ -151,7 +142,31 @@
</dd>
</dl>
@endif
@if (!in_array($role, [7, 15, 17, 19]))
<dl>
<dt>推送业务员:</dt>
<dd>
<select id="order_send" name="order_send" class="form-control order_send selectpicker" title="全部" data-live-search="true" data-size="7" multiple>
<!-- <option value="">全部</option> -->
<option value="0">无推送</option>
<optgroup label="在职">
@foreach ($sale_list as $v)
@if ($v->status != 4)
<option value="{{$v->userId}}">{{$v->name}}</option>
@endif
@endforeach
</optgroup>
<optgroup label="离职">
@foreach ($sale_list as $v)
@if ($v->status == 4)
<option value="{{$v->userId}}">{{$v->name}}</option>
@endif
@endforeach
</optgroup>
</select>
</dd>
</dl>
<dl>
<dt>adtag来源:</dt>
<dd>
......@@ -186,6 +201,8 @@
</select>
</dd>
</dl>
@endif
<dl>
<dt>新订单:</dt>
<dd>
......
......@@ -39,11 +39,22 @@
</dd>
</dl>
<dl>
<dt>创建日期: </dt>
<dd style="width:auto !important;">
<input type="text" name="time_start" value="{{ !empty($condition['time_start']) ? date('Y/m/d', $condition['time_start']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="开始时间" autocomplete="off" />
<dd style="width: 110px;">
<div class="droplist" data-default="{{$condition['select_time_type']}}" id="select_time_type" name="select_time_type">
<ul class="dropdown-menu">
<li class="select_time_type_tab active" data-val="">创建日期</li>
<li class="select_time_type_tab" data-val="1">审核日期</li>
<li class="select_time_type_tab" data-val="2">收款日期</li>
<li class="select_time_type_tab" data-val="3">发货日期</li>
<li class="select_time_type_tab" data-val="4">订单完成</li>
</ul>
</div>
</dd>
<dd style="width:auto !important;">
<!-- <dt>创建日期: </dt> -->
<dd style="width: 120px;">
<input type="text" name="time_start" value="{{ !empty($condition['time_start']) ? date('Y/m/d', $condition['time_start']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="开始时间" autocomplete="off" style="width: 140px;" />
</dd>
<dd style="width: 120px; margin-left: 20px;">
<input type="text" name="time_end" value="{{ !empty($condition['time_end']) ? date('Y/m/d', $condition['time_end']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="结束时间" autocomplete="off" />
</dd>
</dl>
......@@ -86,29 +97,6 @@
</dd>
</dl>
<dl>
<dt>客服:</dt>
<dd>
<select id="order_send" name="order_send" class="form-control order_send selectpicker" title="全部" data-live-search="true" data-size="7" multiple>
<!-- <option value="">全部</option> -->
<option value="0">无推送</option>
<optgroup label="在职">
@foreach ($sale_list as $v)
@if ($v->status != 4)
<option value="{{$v->userId}}">{{$v->name}}</option>
@endif
@endforeach
</optgroup>
<optgroup label="离职">
@foreach ($sale_list as $v)
@if ($v->status == 4)
<option value="{{$v->userId}}">{{$v->name}}</option>
@endif
@endforeach
</optgroup>
</select>
</dd>
</dl>
<dl>
<dt>支付方式:</dt>
<dd>
<select id="order_payment_mode" name="order_payment_mode" class="form-control order_payment_mode selectpicker" title="全部" multiple>
......@@ -149,7 +137,31 @@
</select>
</dd>
</dl>
@if (!in_array($role, [7, 15, 17, 19]))
<dl>
<dt>客服:</dt>
<dd>
<select id="order_send" name="order_send" class="form-control order_send selectpicker" title="全部" data-live-search="true" data-size="7" multiple>
<!-- <option value="">全部</option> -->
<option value="0">无推送</option>
<optgroup label="在职">
@foreach ($sale_list as $v)
@if ($v->status != 4)
<option value="{{$v->userId}}">{{$v->name}}</option>
@endif
@endforeach
</optgroup>
<optgroup label="离职">
@foreach ($sale_list as $v)
@if ($v->status == 4)
<option value="{{$v->userId}}">{{$v->name}}</option>
@endif
@endforeach
</optgroup>
</select>
</dd>
</dl>
<dl>
<dt>adtag来源:</dt>
<dd>
......@@ -174,6 +186,8 @@
</select>
</dd>
</dl>
@endif
<!-- <dl>
<dt>新订单:</dt>
<dd style="width: 115px;">
......
#!/usr/bin/env sh
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../nesbot/carbon/bin" && pwd)
if [ -d /proc/cygdrive ]; then
case $(which php) in
$(readlink -n /proc/cygdrive)/*)
# We are in Cygwin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
;;
esac
fi
"${dir}/upgrade-carbon" "$@"
@ECHO OFF
setlocal DISABLEDELAYEDEXPANSION
SET BIN_TARGET=%~dp0/../nesbot/carbon/bin/upgrade-carbon
php "%BIN_TARGET%" %*
......@@ -7,12 +7,14 @@ $baseDir = dirname($vendorDir);
return array(
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'1d1b89d124cc9cb8219922c9d5569199' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
'667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
'1d1b89d124cc9cb8219922c9d5569199' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'e7223560d890eab89cda23685e711e2c' => $vendorDir . '/psy/psysh/src/Psy/functions.php',
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
......
......@@ -6,10 +6,9 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'),
'UpdateHelper\\' => array($vendorDir . '/kylekatarnls/update-helper/src'),
'PHPExcel' => array($vendorDir . '/phpoffice/phpexcel/Classes'),
'Mockery' => array($vendorDir . '/mockery/mockery/library'),
'Maatwebsite\\Excel\\' => array($vendorDir . '/maatwebsite/excel/src'),
'JakubOnderka\\PhpConsoleHighlighter' => array($vendorDir . '/jakub-onderka/php-console-highlighter/src'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
);
......@@ -13,6 +13,7 @@ return array(
'Symfony\\Polyfill\\Util\\' => array($vendorDir . '/symfony/polyfill-util'),
'Symfony\\Polyfill\\Php56\\' => array($vendorDir . '/symfony/polyfill-php56'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/var-dumper'),
'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'),
......@@ -31,8 +32,10 @@ return array(
'Psy\\' => array($vendorDir . '/psy/psysh/src/Psy'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src/Prophecy'),
'Predis\\' => array($vendorDir . '/predis/predis/src'),
'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'),
'PhpAmqpLib\\' => array($vendorDir . '/php-amqplib/php-amqplib/PhpAmqpLib'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'),
'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src', $vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
......@@ -44,6 +47,7 @@ return array(
'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'),
'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib/Doctrine/Common/Inflector'),
'DebugBar\\' => array($vendorDir . '/maximebf/debugbar/src/DebugBar'),
'Cron\\' => array($vendorDir . '/mtdowling/cron-expression/src/Cron'),
'ClassPreloader\\' => array($vendorDir . '/classpreloader/classpreloader/src'),
......
vendor/
composer.lock
composer.phar
phpunit.xml
language: php
sudo: false
cache:
directory:
- $HOME/.composer/cache
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
install:
- composer install -n
script:
- phpunit
......@@ -13,17 +13,20 @@
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
],
"require": {
"php": ">=5.3.2"
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "4.*"
"phpunit/phpunit": "^6.2"
},
"autoload": {
"psr-0": { "Doctrine\\Common\\Inflector\\": "lib/" }
"psr-4": { "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" }
},
"autoload-dev": {
"psr-4": { "Doctrine\\Tests\\Common\\Inflector\\": "tests/Doctrine/Common/Inflector" }
},
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
"dev-master": "1.2.x-dev"
}
}
}
......@@ -49,7 +49,7 @@ class Inflector
'/(matr|vert|ind)(ix|ex)$/i' => '\1ices',
'/(x|ch|ss|sh)$/i' => '\1es',
'/([^aeiouy]|qu)y$/i' => '\1ies',
'/(hive)$/i' => '\1s',
'/(hive|gulf)$/i' => '\1s',
'/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
'/sis$/i' => 'ses',
'/([ti])um$/i' => '\1a',
......@@ -67,7 +67,16 @@ class Inflector
'/$/' => 's',
),
'uninflected' => array(
'.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people', 'cookie'
'.*[nrlm]ese',
'.*deer',
'.*fish',
'.*measles',
'.*ois',
'.*pox',
'.*sheep',
'people',
'cookie',
'police',
),
'irregular' => array(
'atlas' => 'atlases',
......@@ -76,6 +85,7 @@ class Inflector
'brother' => 'brothers',
'cafe' => 'cafes',
'chateau' => 'chateaux',
'niveau' => 'niveaux',
'child' => 'children',
'cookie' => 'cookies',
'corpus' => 'corpuses',
......@@ -95,6 +105,7 @@ class Inflector
'hoof' => 'hoofs',
'human' => 'humans',
'iris' => 'irises',
'larva' => 'larvae',
'leaf' => 'leaves',
'loaf' => 'loaves',
'man' => 'men',
......@@ -112,6 +123,7 @@ class Inflector
'octopus' => 'octopuses',
'opus' => 'opuses',
'ox' => 'oxen',
'passerby' => 'passersby',
'penis' => 'penises',
'person' => 'people',
'plateau' => 'plateaux',
......@@ -161,6 +173,7 @@ class Inflector
'/(tive)s$/i' => '\1',
'/(hive)s$/i' => '\1',
'/(drive)s$/i' => '\1',
'/(dive)s$/i' => '\1',
'/([^fo])ves$/i' => '\1fe',
'/(^analy)ses$/i' => '\1sis',
'/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
......@@ -183,8 +196,12 @@ class Inflector
'.*pox',
'.*sheep',
'.*ss',
'police',
'pants',
'clothes',
),
'irregular' => array(
'caches' => 'cache',
'criteria' => 'criterion',
'curves' => 'curve',
'emphases' => 'emphasis',
......@@ -206,9 +223,9 @@ class Inflector
'Amoyese', 'bison', 'Borghese', 'bream', 'breeches', 'britches', 'buffalo', 'cantus',
'carp', 'chassis', 'clippers', 'cod', 'coitus', 'Congoese', 'contretemps', 'corps',
'debris', 'diabetes', 'djinn', 'eland', 'elk', 'equipment', 'Faroese', 'flounder',
'Foochowese', 'gallows', 'Genevese', 'Genoese', 'Gilbertese', 'graffiti',
'Foochowese', 'Furniture', 'gallows', 'Genevese', 'Genoese', 'Gilbertese', 'graffiti',
'headquarters', 'herpes', 'hijinks', 'Hottentotese', 'information', 'innings',
'jackanapes', 'Kiplingese', 'Kongoese', 'Lucchese', 'mackerel', 'Maltese', '.*?media',
'jackanapes', 'Kiplingese', 'Kongoese', 'Lucchese', 'Luggage', 'mackerel', 'Maltese', '.*?media',
'mews', 'moose', 'mumps', 'Nankingese', 'news', 'nexus', 'Niasese',
'Pekingese', 'Piedmontese', 'pincers', 'Pistoiese', 'pliers', 'Portuguese',
'proceedings', 'rabies', 'rice', 'rhinoceros', 'salmon', 'Sarawakese', 'scissors',
......@@ -252,7 +269,7 @@ class Inflector
*/
public static function classify($word)
{
return str_replace(" ", "", ucwords(strtr($word, "_-", " ")));
return str_replace(' ', '', ucwords(strtr($word, '_-', ' ')));
}
/**
......@@ -404,7 +421,7 @@ class Inflector
if (preg_match('/(.*)\\b(' . self::$plural['cacheIrregular'] . ')$/i', $word, $regs)) {
self::$cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$plural['merged']['irregular'][strtolower($regs[2])], 1);
return self::$cache['pluralize'][$word];
}
......@@ -457,7 +474,7 @@ class Inflector
if (preg_match('/(.*)\\b(' . self::$singular['cacheIrregular'] . ')$/i', $word, $regs)) {
self::$cache['singularize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$singular['merged']['irregular'][strtolower($regs[2])], 1);
return self::$cache['singularize'][$word];
}
......
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/Doctrine/Tests/TestInit.php"
>
<testsuites>
<testsuite name="Doctrine Inflector Test Suite">
<directory>./tests/Doctrine/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./lib/Doctrine/</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
</exclude>
</groups>
</phpunit>
<?php
/*
* This file bootstraps the test environment.
*/
namespace Doctrine\Tests;
error_reporting(E_ALL | E_STRICT);
// register silently failing autoloader
spl_autoload_register(function($class)
{
if (0 === strpos($class, 'Doctrine\Tests\\')) {
$path = __DIR__.'/../../'.strtr($class, '\\', '/').'.php';
if (is_file($path) && is_readable($path)) {
require_once $path;
return true;
}
} else if (0 === strpos($class, 'Doctrine\Common\\')) {
$path = __DIR__.'/../../../lib/'.($class = strtr($class, '\\', '/')).'.php';
if (is_file($path) && is_readable($path)) {
require_once $path;
return true;
}
}
});
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
### Summary
<!-- provide a summary here -->
### Versions
<!-- Please provide the versions of PHP as well as `fzaninotto/faker` on which the issue has been observed -->
| | Version |
|:--------------------|:--------|
| PHP | x.y.z |
| `fzaninotto/faker` | x.y.z |
### Self-enclosed code snippet for reproduction
```php
<!-- please replace this with a self-enclosed usage example -->
```
### Expected output
```txt
<!-- please replace this with the expected output of your self-enclosed example -->
```
### Actual output
```txt
<!-- please replace this with the actual output of your self-enclosed example -->
```
language: php
dist: precise
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- nightly
sudo: false
cache:
directories:
- $HOME/.composer/cache
before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-dist
script: make sniff test
#!/usr/bin/env bash
# The problem is that we do not want to remove the configuration file, just disable it for a few tasks, then enable it
#
# For reference, see
#
# - https://docs.travis-ci.com/user/languages/php#Disabling-preinstalled-PHP-extensions
# - https://docs.travis-ci.com/user/languages/php#Custom-PHP-configuration
config="/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini"
function xdebug-disable() {
if [[ -f $config ]]; then
mv $config "$config.bak"
fi
}
function xdebug-enable() {
if [[ -f "$config.bak" ]]; then
mv "$config.bak" $config
fi
}
Contributing
============
If you've written a new formatter, adapted Faker to a new locale, or fixed a bug, your contribution is welcome!
Before proposing a pull request, check the following:
* Your code should follow the [PSR-2 coding standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). Run `make sniff` to check that the coding standards are followed, and use [php-cs-fixer](https://github.com/fabpot/PHP-CS-Fixer) to fix inconsistencies.
* Unit tests should still pass after your patch. Run the tests on your dev server (with `make test`) or check the continuous integration status for your pull request.
* As much as possible, add unit tests for your code
* Never use `rand()` in your providers. Faker uses the Mersenne Twister Randomizer, so use `mt_rand()` or any of the base generators (`randomNumber`, `randomElement`, etc.) instead.
* If you add new providers (or new locales) and that they embed a lot of data for random generation (e.g. first names in a new language), please add a `@link` to the reference you used for this list (example [in the ru_RU locale](https://github.com/fzaninotto/Faker/blob/master/src/Faker/Provider/ru_RU/Person.php#L13)). This will ease future updates of the list and debates about the most relevant data for this provider.
* If you add long list of random data, please split the list into several lines. This makes diffs easier to read, and facilitates core review.
* If you add new formatters, please include documentation for it in the README. Don't forget to add a line about new formatters in the `@property` or `@method` phpDoc entries in [Generator.php](https://github.com/fzaninotto/Faker/blob/master/src/Faker/Generator.php#L6-L118) to help IDEs auto-complete your formatters.
* If your new formatters are specific to a certain locale, document them in the [Language-specific formatters](https://github.com/fzaninotto/Faker#language-specific-formatters) list instead.
* Avoid changing existing sets of data. Some developers use Faker with seeding for unit tests ; changing the data makes their tests fail.
* Speed is important in all Faker usages. Make sure your code is optimized to generate thousands of fake items in no time, without consuming too much memory or CPU.
* If you commit a new feature, be prepared to help maintaining it. Watch the project on GitHub, and please comment on issues or PRs regarding the feature you contributed.
Once your code is merged, it is available for free to everybody under the MIT License. Publishing your Pull Request on the Faker GitHub repository means that you agree with this license for your contribution.
Thank you for your contribution! Faker wouldn't be so great without you.
vendor/autoload.php:
composer install --no-interaction --prefer-dist
.PHONY: sniff
sniff: vendor/autoload.php
vendor/bin/phpcs --standard=PSR2 src -n
.PHONY: test
test: vendor/autoload.php
vendor/bin/phpunit --verbose
......@@ -2,7 +2,11 @@
"name": "fzaninotto/faker",
"type": "library",
"description": "Faker is a PHP library that generates fake data for you.",
"keywords": ["faker", "fixtures", "data"],
"keywords": [
"faker",
"fixtures",
"data"
],
"license": "MIT",
"authors": [
{
......@@ -13,9 +17,9 @@
"php": "^5.3.3 || ^7.0"
},
"require-dev": {
"ext-intl": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7",
"squizlabs/php_codesniffer": "^1.5",
"ext-intl": "*"
"squizlabs/php_codesniffer": "^2.9.2"
},
"autoload": {
"psr-4": {
......@@ -29,7 +33,10 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
"dev-master": "1.9-dev"
}
},
"config": {
"sort-packages": true
}
}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Faker Test Suite">
<directory>./test/Faker/</directory>
</testsuite>
</testsuites>
</phpunit>
<?php
namespace Faker\Calculator;
/**
* Utility class for validating EAN-8 and EAN-13 numbers
*
* @package Faker\Calculator
*/
class Ean
{
/** @var string EAN validation pattern */
const PATTERN = '/^(?:\d{8}|\d{13})$/';
/**
* Computes the checksum of an EAN number.
*
* @see https://en.wikipedia.org/wiki/International_Article_Number
*
* @param string $digits
* @return int
*/
public static function checksum($digits)
{
$length = strlen($digits);
$even = 0;
for ($i = $length - 1; $i >= 0; $i -= 2) {
$even += $digits[$i];
}
$odd = 0;
for ($i = $length - 2; $i >= 0; $i -= 2) {
$odd += $digits[$i];
}
return (10 - ((3 * $even + $odd) % 10)) % 10;
}
/**
* Checks whether the provided number is an EAN compliant number and that
* the checksum is correct.
*
* @param string $ean An EAN number
* @return boolean
*/
public static function isValid($ean)
{
if (!preg_match(self::PATTERN, $ean)) {
return false;
}
return self::checksum(substr($ean, 0, -1)) === intval(substr($ean, -1));
}
}
......@@ -24,10 +24,10 @@ class Luhn
$length = strlen($number);
$sum = 0;
for ($i = $length - 1; $i >= 0; $i -= 2) {
$sum += $number{$i};
$sum += $number[$i];
}
for ($i = $length - 2; $i >= 0; $i -= 2) {
$sum += array_sum(str_split($number{$i} * 2));
$sum += array_sum(str_split($number[$i] * 2));
}
return $sum % 10;
......
......@@ -21,8 +21,10 @@ namespace Faker;
* @property string $city
* @property string $streetName
* @property string $streetAddress
* @property string $secondaryAddress
* @property string $postcode
* @property string $address
* @property string $state
* @property string $country
* @property float $latitude
* @property float $longitude
......@@ -33,6 +35,7 @@ namespace Faker;
* @property string $isbn10
*
* @property string $phoneNumber
* @property string $e164PhoneNumber
*
* @property string $company
* @property string $companySuffix
......@@ -52,6 +55,7 @@ namespace Faker;
* @property string $word
* @property string|array $words
* @method string|array words($nb = 3, $asText = false)
* @method string word()
* @property string $sentence
* @method string sentence($nbWords = 6, $variableNbWords = true)
* @property string|array $sentences
......@@ -113,7 +117,7 @@ namespace Faker;
* @method string year($max = 'now')
* @method \DateTime dateTime($max = 'now', $timezone = null)
* @method \DateTime dateTimeAd($max = 'now', $timezone = null)
* @method \DateTime dateTimeBetween($startDate = '-30 years', $endDate = 'now')
* @method \DateTime dateTimeBetween($startDate = '-30 years', $endDate = 'now', $timezone = null)
* @method \DateTime dateTimeInInterval($date = '-30 years', $interval = '+5 days', $timezone = null)
* @method \DateTime dateTimeThisCentury($max = 'now', $timezone = null)
* @method \DateTime dateTimeThisDecade($max = 'now', $timezone = null)
......@@ -132,6 +136,7 @@ namespace Faker;
* @method boolean boolean($chanceOfGettingTrue = 50)
*
* @property int $randomDigit
* @property int $randomDigitNot
* @property int $randomDigitNotNull
* @property string $randomLetter
* @property string $randomAscii
......@@ -154,6 +159,7 @@ namespace Faker;
* @method Generator optional($weight = 0.5, $default = null)
* @method Generator unique($reset = false, $maxRetries = 10000)
* @method Generator valid($validator = null, $maxRetries = 10000)
* @method mixed passthrough($passthrough)
*
* @method integer biasedNumberBetween($min = 0, $max = 100, $function = 'sqrt')
*
......@@ -278,4 +284,9 @@ class Generator
{
return $this->format($method, $attributes);
}
public function __destruct()
{
$this->seed();
}
}
......@@ -42,7 +42,11 @@ class ColumnTypeGuesser
return $generator->uuid();
};
case 'string':
$columnData = $schema->column($column);
if (method_exists($schema, 'getColumn')) {
$columnData = $schema->getColumn($column);
} else {
$columnData = $schema->column($column);
}
$length = $columnData['length'];
return function () use ($generator, $length) {
return $generator->text($length);
......
......@@ -67,6 +67,12 @@ class ColumnTypeGuesser
return function () use ($generator) {
return $generator->datetime;
};
case 'datetime_immutable':
case 'date_immutable':
case 'time_immutable':
return function () use ($generator) {
return \DateTimeImmutable::createFromMutable($generator->datetime);
};
default:
// no smart way to guess what the user expects here
return null;
......
......@@ -3,6 +3,7 @@
namespace Faker\ORM\Doctrine;
use Doctrine\Common\Persistence\ObjectManager;
use Faker\Generator;
/**
* Service class for populating a database using the Doctrine ORM or ODM.
......@@ -10,20 +11,35 @@ use Doctrine\Common\Persistence\ObjectManager;
*/
class Populator
{
/** @var int */
protected $batchSize;
/** @var Generator */
protected $generator;
/** @var ObjectManager|null */
protected $manager;
/** @var array */
protected $entities = array();
/** @var array */
protected $quantities = array();
/** @var array */
protected $generateId = array();
/**
* @param \Faker\Generator $generator
* Populator constructor.
* @param Generator $generator
* @param ObjectManager|null $manager
* @param int $batchSize
*/
public function __construct(\Faker\Generator $generator, ObjectManager $manager = null)
public function __construct(Generator $generator, ObjectManager $manager = null, $batchSize = 1000)
{
$this->generator = $generator;
$this->manager = $manager;
$this->batchSize = $batchSize;
}
/**
......@@ -55,6 +71,9 @@ class Populator
/**
* Populate the database using all the Entity classes previously added.
*
* Please note that large amounts of data will result in more memory usage since the the Populator will return
* all newly created primary keys after executing.
*
* @param null|EntityManager $entityManager A Doctrine connection object
*
* @return array A list of the inserted PKs
......@@ -72,9 +91,18 @@ class Populator
foreach ($this->quantities as $class => $number) {
$generateId = $this->generateId[$class];
for ($i=0; $i < $number; $i++) {
$insertedEntities[$class][]= $this->entities[$class]->execute($entityManager, $insertedEntities, $generateId);
$insertedEntities[$class][]= $this->entities[$class]->execute(
$entityManager,
$insertedEntities,
$generateId
);
if (count($insertedEntities) % $this->batchSize === 0) {
$entityManager->flush();
$entityManager->clear($class);
}
}
$entityManager->flush();
$entityManager->clear($class);
}
return $insertedEntities;
......
......@@ -141,7 +141,6 @@ class EntityPopulator
foreach ($relations as $relation) {
// We don't need any other relation here.
if ($relation instanceof BelongsTo) {
$fieldName = $relation->localKey();
$entityName = $relation->entityName();
$field = $fields[$fieldName];
......@@ -162,14 +161,12 @@ class EntityPopulator
if (empty($records)) {
return null;
}
$id = $records[mt_rand(0, count($records) - 1)]['id'];
return $id;
return $records[mt_rand(0, count($records) - 1)]['id'];
}
return null;
};
}
}
......
......@@ -173,7 +173,7 @@ class Base
/**
* Returns randomly ordered subsequence of $count elements from a provided array
*
* @param array $array Array to take elements from. Defaults to a-f
* @param array $array Array to take elements from. Defaults to a-c
* @param integer $count Number of elements to take.
* @param boolean $allowDuplicates Allow elements to be picked several times. Defaults to false
* @throws \LengthException When requesting more elements than provided
......@@ -492,7 +492,7 @@ class Base
// All A-F inside of [] become ABCDEF
$regex = preg_replace_callback('/\[([^\]]+)\]/', function ($matches) {
return '[' . preg_replace_callback('/(\w|\d)\-(\w|\d)/', function ($range) {
return implode(range($range[1], $range[2]), '');
return implode('', range($range[1], $range[2]));
}, $matches[1]) . ']';
}, $regex);
// All [ABC] become B (or A or C)
......@@ -590,10 +590,10 @@ class Base
* <code>
* $values = array();
* $evenValidator = function ($digit) {
* return $digit % 2 === 0;
* return $digit % 2 === 0;
* };
* for ($i=0; $i < 10; $i++) {
* $values []= $faker->valid($evenValidator)->randomDigit;
* $values []= $faker->valid($evenValidator)->randomDigit;
* }
* print_r($values); // [0, 4, 8, 4, 2, 6, 0, 8, 8, 6]
* </code>
......
......@@ -26,7 +26,7 @@ class Biased extends Base
$y = mt_rand() / (mt_getrandmax() + 1);
} while (call_user_func($function, $x) < $y);
return floor($x * ($max - $min + 1) + $min);
return (int) floor($x * ($max - $min + 1) + $min);
}
/**
......
......@@ -113,4 +113,31 @@ class Color extends Base
{
return static::randomElement(static::$allColorNames);
}
/**
* @example '340,50,20'
* @return string
*/
public static function hslColor()
{
return sprintf(
'%s,%s,%s',
static::numberBetween(0, 360),
static::numberBetween(0, 100),
static::numberBetween(0, 100)
);
}
/**
* @example array(340, 50, 20)
* @return array
*/
public static function hslColorAsArray()
{
return array(
static::numberBetween(0, 360),
static::numberBetween(0, 100),
static::numberBetween(0, 100)
);
}
}
......@@ -16,6 +16,8 @@ class Company extends Base
/**
* @example 'Acme Ltd'
*
* @return string
*/
public function company()
{
......@@ -26,6 +28,8 @@ class Company extends Base
/**
* @example 'Ltd'
*
* @return string
*/
public static function companySuffix()
{
......@@ -34,6 +38,8 @@ class Company extends Base
/**
* @example 'Job'
*
* @return string
*/
public function jobTitle()
{
......
......@@ -9,7 +9,7 @@ class DateTime extends Base
protected static $defaultTimezone = null;
/**
* @param string|float|int $max
* @param \DateTime|string|float|int $max
* @return int|false
*/
protected static function getMaxTimestamp($max = 'now')
......@@ -147,7 +147,7 @@ class DateTime extends Base
* an interval
* Accepts date string that can be recognized by strtotime().
*
* @param string $date Defaults to 30 years ago
* @param \DateTime|string $date Defaults to 30 years ago
* @param string $interval Defaults to 5 days after
* @param string|null $timezone time zone in which the date time should be set, default to DateTime::$defaultTimezone, if set, otherwise the result of `date_default_timezone_get`
* @example dateTimeInInterval('1999-02-02 11:42:52', '+ 5 days')
......
......@@ -83,14 +83,14 @@ class HtmlLorem extends Base
$this->addRandomAttribute($sibling);
$this->addRandomSubTree($sibling, mt_rand(0, $maxDepth), $maxWidth);
}
};
}
return $root;
}
private function addRandomLeaf(\DOMElement $node)
{
$rand = mt_rand(1, 10);
switch($rand){
switch ($rand) {
case 1:
$this->addRandomP($node);
break;
......@@ -172,7 +172,6 @@ class HtmlLorem extends Base
$node = $element->ownerDocument->createElement($h);
$node->appendChild($text);
$element->appendChild($node);
}
private function addRandomB(\DOMElement $element, $maxLength = 10)
......
......@@ -61,7 +61,7 @@ class Image extends Base
*
* @example '/path/to/dir/13b73edae8443990be1aa8f1a483bc27.jpg'
*/
public static function image($dir = null, $width = 640, $height = 480, $category = null, $fullPath = true, $randomize = true, $word = null)
public static function image($dir = null, $width = 640, $height = 480, $category = null, $fullPath = true, $randomize = true, $word = null, $gray = false)
{
$dir = is_null($dir) ? sys_get_temp_dir() : $dir; // GNU/Linux / OS X / Windows compatible
// Validate directory path
......@@ -75,7 +75,7 @@ class Image extends Base
$filename = $name .'.jpg';
$filepath = $dir . DIRECTORY_SEPARATOR . $filename;
$url = static::imageUrl($width, $height, $category, $randomize, $word);
$url = static::imageUrl($width, $height, $category, $randomize, $word, $gray);
// save file
if (function_exists('curl_exec')) {
......
......@@ -175,7 +175,7 @@ class Internet extends Base
}
$words = $this->generator->words($nbWords);
return join($words, '-');
return join('-', $words);
}
/**
......@@ -233,7 +233,7 @@ class Internet extends Base
}
$transId = 'Any-Latin; Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC;';
if (class_exists('Transliterator') && $transliterator = \Transliterator::create($transId)) {
if (class_exists('Transliterator', false) && $transliterator = \Transliterator::create($transId)) {
$transString = $transliterator->transliterate($string);
} else {
$transString = static::toAscii($string);
......
......@@ -92,7 +92,7 @@ class Lorem extends Base
$words = static::words($nbWords);
$words[0] = ucwords($words[0]);
return implode($words, ' ') . '.';
return implode(' ', $words) . '.';
}
/**
......@@ -131,7 +131,7 @@ class Lorem extends Base
$nbSentences = self::randomizeNbElements($nbSentences);
}
return implode(static::sentences($nbSentences), ' ');
return implode(' ', static::sentences($nbSentences));
}
/**
......@@ -193,7 +193,7 @@ class Lorem extends Base
$text[count($text) - 1] .= '.';
}
return implode($text, '');
return implode('', $text);
}
protected static function randomizeNbElements($nbElements)
......
......@@ -61,28 +61,28 @@ class Miscellaneous extends Base
'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR',
'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE',
'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ',
'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD',
'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR',
'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM',
'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI',
'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF',
'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS',
'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU',
'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT',
'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN',
'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK',
'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME',
'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ',
'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA',
'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU',
'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM',
'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS',
'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI',
'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV',
'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK',
'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA',
'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI',
'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW',
'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF',
'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU',
'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO',
'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ',
'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG',
'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT',
'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE',
'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM',
'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR',
'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS',
'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG',
'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS',
'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE',
'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM',
'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR',
'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW',
'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK',
'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY',
'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM',
'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM',
'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU',
'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW',
);
/**
......@@ -202,7 +202,7 @@ class Miscellaneous extends Base
/**
* @link https://en.wikipedia.org/wiki/ISO_4217
* On date of 2017-07-07
* On date of 2019-09-27
*
* With the following exceptions:
* SVC has been replaced by the USD in 2001: https://en.wikipedia.org/wiki/Salvadoran_col%C3%B3n
......@@ -218,12 +218,12 @@ class Miscellaneous extends Base
'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS',
'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR',
'LRD', 'LSL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP',
'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO',
'MRU', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO',
'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN',
'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG',
'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'SSP', 'STD', 'SYP', 'SZL',
'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'SSP', 'STN', 'SYP', 'SZL',
'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH',
'UGX', 'USD', 'UYU', 'UZS', 'VEF', 'VND', 'VUV', 'WST', 'XAF', 'XCD',
'UGX', 'USD', 'UYU', 'UZS', 'VES', 'VND', 'VUV', 'WST', 'XAF', 'XCD',
'XOF', 'XPF', 'YER', 'ZAR', 'ZMW',
);
......
......@@ -21,7 +21,7 @@ abstract class Text extends Base
* @example 'Alice, swallowing down her flamingo, and began by taking the little golden key'
* @param integer $maxNbChars Maximum number of characters the text should contain (minimum: 10)
* @param integer $indexSize Determines how many words are considered for the generation of the next word.
* The minimum is 1, and it produces the higher level of randomness, although the
* The minimum is 1, and it produces a higher level of randomness, although the
* generated text usually doesn't make sense. Higher index sizes (up to 5)
* produce more correct text, at the price of less randomness.
* @return string
......
......@@ -10,7 +10,8 @@ class Uuid extends Base
*/
public static function uuid()
{
// fix for compatibility with 32bit architecture; seed range restricted to 62bit
// fix for compatibility with 32bit architecture; each mt_rand call is restricted to 32bit
// two such calls will cause 64bits of randomness regardless of architecture
$seed = mt_rand(0, 2147483647) . '#' . mt_rand(0, 2147483647);
// Hash the seed and convert to a byte array
......
......@@ -45,7 +45,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......@@ -58,6 +58,6 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
}
......@@ -47,7 +47,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......@@ -60,7 +60,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......
......@@ -24,7 +24,7 @@ class Payment extends \Faker\Provider\Payment
*/
public static function vat($spacedNationalPrefix = true)
{
$prefix = ($spacedNationalPrefix) ? "AT U" : "ATU";
$prefix = $spacedNationalPrefix ? "AT U" : "ATU";
return sprintf("%s%d", $prefix, self::randomNumber(8, true));
}
......
......@@ -31,7 +31,7 @@ class Payment extends \Faker\Provider\Payment
*/
public static function vat($spacedNationalPrefix = true)
{
$prefix = ($spacedNationalPrefix) ? "BG " : "BG";
$prefix = $spacedNationalPrefix ? "BG " : "BG";
return sprintf(
"%s%d%d",
......
......@@ -13,7 +13,18 @@ class Address extends \Faker\Provider\Address
'gasse', 'platz', 'ring', 'straße', 'weg',
);
protected static $postcode = array('####');
// As per https://en.wikipedia.org/wiki/List_of_postal_codes_in_Austria (@todo implement more strict postal code values according to wikipedia)
protected static $postcode = array(
'1###',
'2###',
'3###',
'4###',
'5###',
'6###',
'7###',
'8###',
'9###',
);
protected static $cityNames = array(
'Allentsteig', 'Altheim', 'Althofen', 'Amstetten', 'Ansfelden', 'Attnang-Puchheim',
......
......@@ -86,4 +86,32 @@ class Person extends \Faker\Provider\de_DE\Person
'Wagner', 'Walker', 'Walser', 'Weber', 'Wehrli', 'Weibel', 'Weiss', 'Wenger', 'Wicki', 'Widmer', 'Willi', 'Wirth', 'Wirz', 'Wittwer', 'Wolf', 'Wyss', 'Wüthrich',
'Zaugg', 'Zbinden', 'Zehnder', 'Ziegler', 'Zimmermann', 'Zwahlen', 'Zürcher',
);
/**
* Generates a valid random AVS13 (swiss social security) number
*
* This function acts as a localized alias for the function defined in the
* fr_CH provider. In the german-speaking part of Switzerland, the AVS13
* number is generally known as AHV13.
*
* @see \Faker\Provider\fr_CH\Person::avs13()
* @return string
*/
public static function ahv13()
{
return \Faker\Provider\fr_CH\Person::avs13();
}
/**
* Generates a valid random AVS13 (swiss social security) number
*
* This function acts as an alias for the function defined in the fr_CH provider.
*
* @see \Faker\Provider\fr_CH\Person::avs13()
* @return string
*/
public static function avs13()
{
return \Faker\Provider\fr_CH\Person::avs13();
}
}
......@@ -4,7 +4,7 @@ namespace Faker\Provider\de_DE;
class Address extends \Faker\Provider\Address
{
protected static $buildingNumber = array('###', '##', '#', '#/#', '##[abc]', '#[abc]');
protected static $buildingNumber = array('%##', '%#', '%', '%/%', '%#[abc]', '%[abc]');
protected static $streetSuffixLong = array(
'Gasse', 'Platz', 'Ring', 'Straße', 'Weg', 'Allee'
......
......@@ -11,5 +11,14 @@ class Company extends \Faker\Provider\Company
'{{lastName}}',
);
/**
* @link http://www.personalseite.de/information/titel.htm
*/
protected static $jobTitleFormat = array(
'Abteilungsdirektor', 'Arbeitsdirektor', 'Aufsichtsrat', 'Beirat', 'Bereichsleiter', 'Betriebsleiter', 'Finanzvorstand', 'Geschäftsführender Gesellschafter', 'Geschäftsführer', 'Gesellschafter',
'Handlungsbevollmächtigter', 'Kaufmännischer Vorstand', 'Leiter Rechtsabteilung', 'Mitglied des Aufsichtsrats', 'Personalleiter', 'Prokurist', 'Sellvertretender Vorsitzender des Vorstandes',
'Vorsitzender der Geschäftsführung', 'Vorsitzender des Aufsichtsrats', 'Vorsitzender des Vorstandes', 'Vorstand Personal', 'Vorstand Technik', 'Vorstand Vertrieb', 'Vorstandsmitglied', 'Werksleiter'
);
protected static $companySuffix = array('e.G.', 'e.V.', 'GbR', 'GbR', 'OHG mbH', 'GmbH & Co. OHG', 'AG & Co. OHG', 'GmbH', 'GmbH', 'GmbH', 'GmbH', 'AG', 'AG', 'AG', 'AG', 'KG', 'KG', 'KG', 'GmbH & Co. KG', 'GmbH & Co. KG', 'AG & Co. KG', 'Stiftung & Co. KG', 'KGaA', 'GmbH & Co. KGaA', 'AG & Co. KGaA', 'Stiftung & Co. KGaA');
}
......@@ -2,7 +2,7 @@
namespace Faker\Provider\en_CA;
class PhoneNumber extends \Faker\Provider\PhoneNumber
class PhoneNumber extends \Faker\Provider\en_US\PhoneNumber
{
protected static $formats = array(
'%##-###-####',
......
......@@ -31,9 +31,9 @@ class Address extends \Faker\Provider\Address
'L40 4LA','LU7 4SW','WV99 1RG','EC3P 3AY','CW5 6DY','CR2 8EN','PO11 0JY','IP33 9GD','WA3 3UR','WD3 3LY','CT6 7HL','TN15 8JE',
'L35 5JA','CF23 0EL','TR13 0DP','GL14 2NW','W1D 4PR','SY5 0AR','NP4 8LA','CH45 7RH','S35 4FX','PL20 6JB','NW1 6AB','AB41 7HB',
'S72 7HG','RG27 8PG','TA1 3TF','FK3 8EP','MK43 7LX','BT79 7AQ','L9 9BL','PE28 5US','PO4 8NU','WF4 3QZ','SE23 3RG','NN5 7AR',
'L15 6UE','CA4 9QG','RH9 8DR','KT18 5DN','AB11 5QE','L2 2TX','NE20 0RB','TF3 2BG','NW2 2SH','IG10 3JT','HR9 7GB','N10 3DS',
'PA3 4NH','W8 7EY','HP19 9BW','KA1 3TU','SE26 6JG','SL3 9LU','L38 9EB','M15 6QL','BN6 8DA','PE27 5PP','LS16 8EE','AB15 4YR',
'CM0 7HA','SY11 4LB','IG1 3TR','NE63 8EL','CR5 3DN','NW4 4XL','BL9 6QT','KT24 6NU','EH37 5TF','SO16 9RJ','B62 8RS','PL28 8QJ',
'L15 6UE','CA4 9QG','RH9 8DR','AB11 5QE','L2 2TX','NE20 0RB','TF3 2BG','NW2 2SH','IG10 3JT','HR9 7GB','N10 3DS',
'PA3 4NH','W8 7EY','HP19 9BW','KA1 3TU','SE26 6JG','SL3 9LU','L38 9EB','M15 6QL','BN6 8DA','PE27 5PP','LS16 8EE',
'CM0 7HA','SY11 4LB','IG1 3TR','NE63 8EL','CR5 3DN','NW4 4XL','BL9 6QT','KT24 6NU','EH37 5TF','SO16 9RJ','PL28 8QJ',
'E9 5LR','BR6 9XJ','M25 3BY','M20 1BT','SE18 7QX','DD1 2NF','NR31 8NS','BH31 6AF','TN23 5PR','TN12 9PU','HR8 2JJ','KT6 5DX',
'HX3 0NS','SN7 8NR','SY7 8AQ','CV8 1LS','NR34 9ET','BD23 3EU','YO11 3JN','BH11 9NE','CM3 3AE','KA3 7PR','DE15 9DU','PR8 9LB',
'GL53 7EN','OX15 4HW','TS19 9ES','G65 9BG','SE15 6FE','B37 7RA','BT51 3NQ','YO32 9SX','M50 3TU','LL14 5NR','PO35 5XS','W5 9TG',
......
......@@ -36,7 +36,7 @@ class Person extends \Faker\Provider\Person
'Kartik', 'Koushtubh', 'Kirti', 'Kushal', 'Kailash', 'Kalyan', 'Krishna', 'Kamlesh', 'Kalpit', 'Kabeer', 'Karim',
'Lalit', 'Lakshmi', 'Labeen',
'Mohan', 'Mukund', 'Mohan', 'Mohit', 'Manish', 'Moti', 'Mowgli', 'Mohanlal', 'Mitesh', 'Manoj', 'Monin', 'Mahmood', 'Malik', 'Mehul', 'Mustafa', 'Manpreet', 'Mukul', 'Munaf', 'Marlo',
'Nitin', 'Nayan', 'Naresh', 'Neerendra', 'Nirmal', 'Narayan', 'Nakul', 'Naval', 'Natwar', 'Naseer', 'Nazir', 'Nawab, ',
'Nitin', 'Nayan', 'Naresh', 'Neerendra', 'Nirmal', 'Narayan', 'Nakul', 'Naval', 'Natwar', 'Naseer', 'Nazir', 'Nawab',
'Parveen', 'Pravin', 'Pranab', 'Prabhat', 'Pradeep', 'Prasoon', 'Preet', 'Pranay', 'Parvez', 'Pirzada', 'Peter',
'Omar', 'Obaid', 'Owais',
'Qabeel', 'Qabool', 'Qadim',
......
<?php
// data source
namespace Faker\Provider\en_NG;
class Person extends \Faker\Provider\Person
......@@ -74,7 +72,7 @@ class Person extends \Faker\Provider\Person
'Funmilayo',
'Gbadamosi', 'Gbogboade', 'Grace',
'Habeeb', 'Hanifat', 'Isaac',
'Ismail', 'Isokun', 'Isreal', 'Iyalla',
'Ismail', 'Isokun', 'Israel', 'Iyalla',
'Jamiu', 'Jimoh', 'Joshua', 'Justina',
'Katherine', 'Kayode', 'Kayode', 'Kimberly',
'Ladega', 'Latifat', 'Lawal', 'Leonard',
......
......@@ -11,18 +11,15 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
protected static $zeroToEight = array(0, 1, 2, 3, 4, 5, 6, 7, 8);
protected static $oneToNine = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
protected static $oneToEight = array(1, 2, 3, 4, 5, 6, 7, 8);
protected static $mobileNumberFormats = array(
'{{internationalCodePrefix}}9{{zeroToEight}}## ####',
'{{internationalCodePrefix}} 9{{zeroToEight}}## ####',
'9{{zeroToEight}}## ####',
'{{internationalCodePrefix}}8{{oneToNine}}## ####',
'{{internationalCodePrefix}} 8{{oneToNine}}## ####',
'8{{oneToNine}}## ####',
'{{internationalCodePrefix}}7{{oneToNine}}## ####',
'{{internationalCodePrefix}} 7{{oneToNine}}## ####',
'7{{oneToNine}}## ####',
'{{internationalCodePrefix}}8{{oneToEight}}## ####',
'{{internationalCodePrefix}} 8{{oneToEight}}## ####',
'8{{oneToEight}}## ####',
);
protected static $fixedLineNumberFormats = array(
......@@ -103,8 +100,8 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
return static::randomElement(static::$zeroToEight);
}
public function oneToNine()
public function oneToEight()
{
return static::randomElement(static::$oneToNine);
return static::randomElement(static::$oneToEight);
}
}
......@@ -84,7 +84,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......@@ -97,7 +97,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......
......@@ -3,7 +3,6 @@
namespace Faker\Provider\en_US;
class Payment extends \Faker\Provider\Payment
{
public function bankAccountNumber()
......
......@@ -48,7 +48,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......@@ -61,6 +61,6 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
}
<?php
namespace Faker\Provider\es_ES;
class Color extends \Faker\Provider\Color
{
protected static $safeColorNames = array(
'amarillo',
'azul marino',
'azul',
'blanco',
'celeste',
'gris',
'lima',
'magenta',
'marrón',
'morado',
'negro',
'plata',
'turquesa',
'verde',
'verde oliva',
);
}
......@@ -62,7 +62,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......@@ -75,6 +75,6 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
}
......@@ -15,6 +15,9 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
'9########',
'9##-##-####',
'9##-######',
);
protected static $mobileFormats = array(
'+34 6## ## ####',
'+34 6## ######',
'+34 6########',
......@@ -26,4 +29,19 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
'6##-##-####',
'6##-######',
);
protected static $tollFreeFormats = array(
'900 ### ###',
'800 ### ###',
);
public static function mobileNumber()
{
return static::numerify(static::randomElement(static::$mobileFormats));
}
public static function tollFreeNumber()
{
return static::numerify(static::randomElement(static::$tollFreeFormats));
}
}
......@@ -48,7 +48,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......@@ -61,6 +61,6 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
}
<?php
namespace Faker\Provider\et_EE;
/**
* Class Person
* @package Faker\Provider\et_EE
* @author David Gegelija <code@imdavid.xyz>
*/
class Person extends \Faker\Provider\Person
{
/**
* @link https://news.err.ee/114745/most-popular-baby-names-of-2014
* @link https://www.stat.ee/public/apps/nimed/TOP
*/
protected static $firstNameMale = array(
"Andrei", "Aleksei", "Andres", "Alexander", "Aivar", "Aleksander", "Artur", "Andrus", "Ants", "Artjom", "Anatoli", "Anton", "Arvo", "Aare", "Ain", "Aleksandr",
"Dmitri", "Daniil", "Daniel",
"Eduard", "Erik", "Enn",
"Fjodorov",
"Gennadi",
"Heino", "Henri", "Hugo",
"Igor", "Indrek", "Ivan", "Ilja",
"Jüri", "Jaan", "Jevgeni", "Jaanus", "Janek", "Jaak",
"Kristjan", "Kalev", "Karl", "Kalle", "Kaido", "Kevin", "Konstantin", "Kaspar", "Kirill", "Kristo", "Kalju", "Kristofer",
"Lauri", "Lembit", "Laur",
"Martin", "Margus", "Maksim", "Marko", "Mati", "Meelis", "Mihhail", "Marek", "Mihkel", "Mart", "Madis", "Markus", "Mark", "Marten",
"Nikolai", "Nikita", "Nikolay",
"Oleg", "Oliver", "Oskar",
"Peeter", "Priit", "Pavel",
"Rein", "Roman", "Raivo", "Rasmus", "Raul", "Robert", "Riho", "Robin", "Romet",
"Sergei", "Sander", "Sergey", "Siim", "Silver", "Sebastian",
"Toomas", "Tarmo", "Tõnu", "Tiit", "Tanel", "Taavi", "Toivo", "Tõnis",
"Urmas", "Ülo",
"Vladimir", "Viktor", "Valeri", "Vello", "Vadim", "Vitali", "Vladislav", "Vjatšeslav", "Victor",
);
/**
* @link https://news.err.ee/114745/most-popular-baby-names-of-2014
* @link https://www.stat.ee/public/apps/nimed/TOP
*/
protected static $firstNameFemale = array(
"Aino", "Aleksandra", "Alisa", "Anastasia", "Anna", "Anne", "Anneli", "Anu", "Arina", "Annika", "Anastassia", "Alla", "Aili", "Alina", "Aime", "Antonina",
"Darja", "Diana",
"Elena", "Eliise", "Elisabeth", "Emma", "Ene", "Eve", "Eha", "Evi",
"Galina",
"Hanna", "Helen", "Heli", "Helle", "Helgi",
"Irina", "Inna", "Ingrid",
"Jekaterina", "Jelena", "Julia", "Jana",
"Kadri", "Katrin", "Kristi", "Kristiina", "Kristina", "Karin", "Kersti", "Kristel", "Kaja", "Külli", "Kätlin", "Krista",
"Laura", "Lenna", "Liisa", "Linda", "Lisandra", "Ljubov", "Ljudmila", "Liina", "Ljudmilla", "Larissa", "Liis", "Lea", "Laine", "Liudmila",
"Maie", "Malle", "Mare", "Maria", "Marina", "Marleen", "Marta", "Merike", "Mia", "Milana", "Mirtel", "Marika", "Merle", "Margit", "Milvi", "Maire", "Margarita", "Mari", "Maarja",
"Natalia", "Niina", "Nora", "Natalja", "Nadežda", "Nina",
"Olga", "Oksana",
"Piret", "Polina", "Pille",
"Reet", "Riina",
"Sandra", "Sirje", "Sofia", "Svetlana", "Silvi",
"Tamara", "Tatiana", "Tiina", "Tiiu", "Triin", "Tatjana", "Tiia",
"Ülle", "Urve",
"Valentina", "Viktoria", "Veera", "Veronika", "Vaike",
"Zinaida",
);
/**
* @link https://en.wikipedia.org/wiki/Category:Estonian-language_surnames
* @link https://www.stat.ee/public/apps/nimed/pere/TOP
*/
protected static $lastName = array(
"Aleksejev", "Andrejev", "Allik", "Aas", "Aleksandrov", "Aare", "Aarma", "Aas", "Aasmäe", "Aav", "Aavik", "Allik", "Alver", "Andrejeva", "Aleksejeva", "Aleksandrova", "Allik", "Aas",
"Bogdanova", "Bogdanov",
"Eenpalu", "Eskola",
"Fjodorov", "Fjodorov", "Fjodorova", "Fjodorova",
"Grigorjev", "Grigorjeva",
"Hunt", "Hein", "Hein", "Härma",
"Ivanov", "Ilves", "Ilves", "Ivanov", "Ivanova", "Ivanova", "Ilves",
"Jõgi", "Jakobson", "Jakovlev", "Jürgenson", "Jegorov", "Järv", "Johanson", "Järve", "Jakobson", "Jänes", "Järve", "Järvis", "Jõgi", "Jõgi", "Johanson", "Jürgenson", "Järv", "Jakovleva", "Jegorova", "Järve", "Jakobson",
"Kuzmina", "Kalda", "Kozlova", "Kruus", "Kask", "Kukk", "Kuznetsov", "Koppel", "Kaasik", "Kuusk", "Karu", "Kütt", "Kallas", "Kivi", "Kangur", "Kuusik", "Kõiv", "Kozlov", "Kull", "Kuzmin", "Kalda", "Kaaleste", "Kaasik", "Käbin", "Kalda", "Kaljulaid", "Kaljurand", "Kallas", "Kallaste", "Kangro", "Kangur", "Kapp", "Kärner", "Karu", "Kask", "Käsper", "Kass", "Keres", "Keskküla", "Kesküla", "Kikkas", "Kingsepp", "Kirs", "Kirsipuu", "Kivi", "Klavan", "Kõiv", "Kokk", "Kontaveit", "Koppel", "Korjus", "Kotkas", "Kreek", "Kross", "Kruus", "Kukk", "Kull", "Kütt", "Kuusik", "Kuusk", "Kuznetsov", "Kuznetsova", "Kask", "Kukk", "Kuznetsova", "Koppel", "Kaasik", "Kuusk", "Karu", "Kütt", "Kallas", "Kivi", "Kuusik", "Kangur", "Kõiv", "Kull",
"Luik", "Lepik", "Lepp", "Lõhmus", "Liiv", "Laur", "Leppik", "Lebedev", "Laas", "Laar", "Laht", "Lass", "Laur", "Laurits", "Lemsalu", "Lepik", "Lepmets", "Lepp", "Leppik", "Levandi", "Liiv", "Lill", "Lindmaa", "Linna", "Lipp", "Lippmaa", "Lõhmus", "Loo", "Lõoke", "Luik", "Luts", "Luik", "Lepik", "Lepp", "Lõhmus", "Laur", "Liiv", "Leppik", "Lebedeva", "Laas",
"Männik", "Mänd", "Mitt", "Makarova", "Mägi", "Mets", "Mihhailov", "Mölder", "Morozov", "Mitt", "Männik", "Mõttus", "Mänd", "Makarov", "Mägi", "Mälk", "Mänd", "Männik", "Margiste", "Mark", "Masing", "Mets", "Mihhailov", "Mihhailova", "Mölder", "Must", "Mägi", "Mets", "Mihhailova", "Mölder", "Morozova",
"Nikolajev", "Nõmm", "Nikitin", "Novikov", "Nõmmik", "Nurme", "Nurmsalu", "Nõmm", "Nikitina", "Nikolajeva",
"Orlova", "Orav", "Oja", "Ots", "Orav", "Orlov", "Oja", "Olesk", "Öpik", "Orav", "Ots", "Oja", "Ots",
"Petrov", "Pärn", "Põder", "Pavlov", "Popov", "Peterson", "Puusepp", "Paju", "Põld", "Pukk", "Paas", "Palm", "Pääsuke", "Padar", "Pärn", "Pavlov", "Pavlova", "Peebo", "Peetre", "Peterson", "Petrov", "Petrova", "Pihlak", "Piho", "Piip", "Põder", "Põld", "Popov", "Popova", "Poska", "Puhvel", "Pütsep", "Puusepp", "Petrova", "Pärn", "Pavlova", "Põder", "Peterson", "Popova", "Puusepp", "Paas", "Paju", "Pukk", "Parts", "Palm", "Põld",
"Romanova", "Rand", "Roos", "Rebane", "Raudsepp", "Raud", "Rand", "Roos", "Rätsep", "Raag", "Raud", "Raudsepp", "Rebane", "Reek", "Reinsalu", "Rooba", "Roolaid", "Rootare", "Rummo", "Rüütel", "Rüütli", "Rebane", "Raudsepp", "Raud",
"Saar", "Sepp", "Smirnov", "Stepanov", "Semjonov", "Sokolov", "Sild", "Sarapuu", "Saks", "Saar", "Salumäe", "Semjonov", "Sepp", "Sibul", "Siimar", "Simm", "Sirel", "Sisask", "Smirnov", "Smirnova", "Sokk", "Sokolov", "Soosaar", "Stepanov", "Stepanova", "Susi", "Saar", "Sepp", "Smirnova", "Stepanova", "Sokolova", "Saks", "Sarapuu", "Sild", "Semjonova",
"Tamme", "Tomson", "Tamm", "Teder", "Toom", "Tomson", "Tamme", "Talts", "Tamm", "Tamme", "Tarvas", "Teder", "Toom", "Toome", "Toots", "Tamm", "Teder", "Toom",
"Uibo", "Uibo",
"Vassiljev", "Vaher", "Volkov", "Valk", "Vaher", "Vahtra", "Vaino", "Vainola", "Välbe", "Valdma", "Väljas", "Valk", "Vassiljev", "Vassiljeva", "Vesik", "Veski", "Viiding", "Vitsut", "Võigemast", "Volkov", "Volkova", "Võsu", "Vassiljeva", "Vaher", "Volkova",
);
}
......@@ -134,4 +134,68 @@ class Person extends \Faker\Provider\Person
protected static $titleMale = array('آقای', 'استاد', 'دکتر', 'مهندس');
protected static $titleFemale = array('خانم', 'استاد', 'دکتر', 'مهندس');
/**
* This method returns a valid Iranian nationalCode
* @example '8075859741'
* @link https://fa.wikipedia.org/wiki/%DA%A9%D8%A7%D8%B1%D8%AA_%D8%B4%D9%86%D8%A7%D8%B3%D8%A7%DB%8C%DB%8C_%D9%85%D9%84%DB%8C#%D8%AD%D8%B3%D8%A7%D8%A8_%DA%A9%D8%B1%D8%AF%D9%86_%DA%A9%D8%AF_%DA%A9%D9%86%D8%AA%D8%B1%D9%84
* @return string
*/
public static function nationalCode()
{
$area = self::createAreaCode();
$core = self::createCoreCode();
$control = self::createControlCode($area, $core);
return sprintf("%03d%06d%01d", $area, $core, $control);
}
/**
* This method generates a 3-digit valid area code to be used in nationalCode
* @return int|string
*/
private static function createAreaCode()
{
$area = "000";
while ($area == "000") {
$area = static::numerify("###");
}
return $area;
}
/**
* This method randomly generates a 6-digit core code for nationalCode
* @return string
*/
private static function createCoreCode()
{
return static::numerify("######");
}
/**
* This method uses the Iranian nationalCode validation algorithm to generate a valid 10-digit code
* @param $area
* @param $core
* @link https://fa.wikipedia.org/wiki/%DA%A9%D8%A7%D8%B1%D8%AA_%D8%B4%D9%86%D8%A7%D8%B3%D8%A7%DB%8C%DB%8C_%D9%85%D9%84%DB%8C#%D8%AD%D8%B3%D8%A7%D8%A8_%DA%A9%D8%B1%D8%AF%D9%86_%DA%A9%D8%AF_%DA%A9%D9%86%D8%AA%D8%B1%D9%84
* @return int
*/
private static function createControlCode($area, $core)
{
$subNationalCodeString = $area . $core;
$sum = 0;
$count = 0;
for ($i = 10; $i > 1; $i--) {
$sum += $subNationalCodeString[$count] * ($i);
$count++;
}
if (($sum % 11) < 2) {
return $sum % 11;
}
return 11 - ($sum % 11);
}
}
......@@ -7,11 +7,40 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
/**
* @link https://fa.wikipedia.org/wiki/%D8%B4%D9%85%D8%A7%D8%B1%D9%87%E2%80%8C%D9%87%D8%A7%DB%8C_%D8%AA%D9%84%D9%81%D9%86_%D8%AF%D8%B1_%D8%A7%DB%8C%D8%B1%D8%A7%D9%86#.D8.AA.D9.84.D9.81.D9.86.E2.80.8C.D9.87.D8.A7.DB.8C_.D9.87.D9.85.D8.B1.D8.A7.D9.87
*/
protected static $formats = array(
'021########',
'026########',
'031########',
protected static $formats = array( // land line formts seprated by province
"011########", //Mazandaran
"013########", //Gilan
"017########", //Golestan
"021########", //Tehran
"023########", //Semnan
"024########", //Zanjan
"025########", //Qom
"026########", //Alborz
"028########", //Qazvin
"031########", //Isfahan
"034########", //Kerman
"035########", //Yazd
"038########", //Chaharmahal and Bakhtiari
"041########", //East Azerbaijan
"044########", //West Azerbaijan
"045########", //Ardabil
"051########", //Razavi Khorasan
"054########", //Sistan and Baluchestan
"056########", //South Khorasan
"058########", //North Khorasan
"061########", //Khuzestan
"066########", //Lorestan
"071########", //Fars
"074########", //Kohgiluyeh and Boyer-Ahmad
"076########", //Hormozgan
"077########", //Bushehr
"081########", //Hamadan
"083########", //Kermanshah
"084########", //Ilam
"086########", //Markazi
"087########", //Kurdistan
);
protected static $mobileNumberPrefixes = array(
'0910#######',//mci
'0911#######',
......@@ -37,7 +66,7 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
'0920#######',
'0921#######',
'0937#######',
'0937#######',
'0990#######', // MCI
);
public static function mobileNumber()
{
......
......@@ -46,7 +46,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......@@ -59,6 +59,6 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
}
......@@ -32,7 +32,7 @@ class Payment extends \Faker\Provider\Payment
*/
public static function vat($spacedNationalPrefix = true)
{
$prefix = ($spacedNationalPrefix) ? "BE " : "BE";
$prefix = $spacedNationalPrefix ? "BE " : "BE";
return sprintf("%s0%d", $prefix, self::randomNumber(9, true));
}
......
This diff could not be displayed because it is too large.
......@@ -87,4 +87,29 @@ class Person extends \Faker\Provider\fr_FR\Person
'Waeber', 'Weber', 'Wenger', 'Widmer', 'Wyss',
'Zbinden', 'Zimmermann',
);
/**
* Generates a valid random AVS13 (swiss social security) number
*
* This function will generate a valid random AVS13 number and return it
* as a formatted string.
*
* @see https://www.zas.admin.ch/zas/fr/home/partenaires-et-institutions-/navs13.html
* @return string
*/
public static function avs13()
{
$p = array(
756,
self::numerify('####'),
self::numerify('####'),
self::numerify('#'),
);
$checksum = \Faker\Calculator\Ean::checksum(implode($p));
$avs = sprintf("%s.%s.%s.%s%s", $p[0], $p[1], $p[2], $p[3], $checksum);
return $avs;
}
}
......@@ -36,7 +36,7 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
/**
......@@ -49,6 +49,6 @@ class Company extends \Faker\Provider\Company
$result[] = static::randomElement($word);
}
return join($result, ' ');
return join(' ', $result);
}
}
<?php
namespace Faker\Provider\id_ID;
class Color extends \Faker\Provider\Color
{
/**
* @link https://id.wikipedia.org/wiki/Warna
* @link https://id.wikipedia.org/wiki/Kategori:Warna
* @link https://id.wikipedia.org/wiki/Warna_tersier
**/
protected static $safeColorNames = array('abu-abu', 'biru', 'biru dongker', 'biru laut', 'cokelat',
'emas', 'hijau', 'hitam', 'jingga', 'krem', 'kuning', 'magenta', 'mawar', 'merah', 'merah jambu',
'merah marun', 'nila', 'perak', 'putih', 'sepia', 'teal', 'toska', 'ungu', 'violet', 'zaitun'
);
/**
* @link https://id.wikipedia.org/wiki/Daftar_warna
**/
protected static $allColorNames = array(
'Abu-Abu', 'Abu-Abu Tua', 'Abu-Abu Muda', 'Abu-Abu Kecokelatan', 'Almond',
'Biru', 'Biru Baja', 'Biru Dongker', 'Biru Keabu-abuan', 'Biru Kehijauan', 'Biru Keunguan', 'Biru Laut', 'Biru Laut Gelap', 'Biru Laut Terang', 'Biru Langit', 'Biru Langit Muda', 'Biru Langit Tua', 'Biru Malam', 'Biru Muda', 'Biru Nilam', 'Biru Pucat', 'Biru Terang', 'Biru Tua',
'Chiffon', 'Cokelat', 'Cokelat Gandum', 'Cokelat Keemasan', 'Cokelat Kekuningan', 'Cokelat Kemerahan', 'Cokelat Tua',
'Delima',
'Emas',
'Hijau Abu-Abu', 'Hijau Botol', 'Hijau Cerah', 'Hijah Gelap', 'Hijau Hutan', 'Hijau Kebiruan', 'Hijau Kekuningan', 'Hijau Laut', 'Hijau Laut Gelap', 'Hijau Laut Terang', 'Hijau Lemon', 'Hijau Lumut', 'Hijau Muda', 'Hijau Muda Kekuningan', 'Hijau Neon', 'Hijau Pucat', 'Hijau Rumput', 'Hijau Tua', 'Hijau Zamrud', 'Hitam', 'Hitam Arang', 'Hitam Pekat',
'Jingga', 'Jingga Labu', 'Jingga Muda', 'Jingga Tua',
'Khaki', 'Khaki Tua', 'Koral', 'Koral Terang', 'Krem', 'Krimson', 'Kuning', 'Kuning Aprikot', 'Kuning Gelap', 'Kuning Jingga', 'Kuning Kehijauan', 'Kuning Kehijauan Pucat', 'Kuning Kecokelatan Tua', 'Kuning Lemon', 'Kuning Muda', 'Kuning Neon', 'Kuning Pucat', 'Kuning Terang', 'Kuning Sawo',
'Lavender', 'Lemon', 'Lemon Chiffon',
'Magenta', 'Magenta Gelap', 'Mawar', 'Merah', 'Merah Bata', 'Merah Indian', 'Merah Kekuning-Kuningan', 'Merah Keungu-Unguan', 'Merah Muda', 'Merah Muda Dakam', 'Merah Muda Kekuningan', 'Merah Muda Keunguan', 'Merah Muda Keunguan Pudar', 'Merah Muda Panas', 'Merah Muda Terang', 'Merah Oranye', 'Merah Tomat', 'Merah Tua', 'Merah Tua Terang', 'Moka',
'Nila',
'Oranye', 'Oranye Pepaya',
'Pastel', 'Peach', 'Pelangi', 'Perak', 'Plum', 'Putih', 'Putih Gading', 'Putih Gandum', 'Putih Salju', 'Putih Terang',
'Rambut Jagung',
'Salmon', 'Salmon Gelap', 'Salmon Terang', 'Sawo', 'Sawo Matang',
'Tembaga', 'Tomat',
'Ungu', 'Ungu Gelap', 'Ungu Kebiruan', 'Ungu Kecokelatan', 'Ungu Lembayung', 'Ungu Lembayung Muda', 'Ungu Muda', 'Ungu Terong',
'Zaitun', 'Zaitun Hijau Gelap'
);
}
......@@ -20,6 +20,6 @@ class Internet extends \Faker\Provider\Internet
protected static $tld = array(
'com', 'net', 'org', 'asia', 'tv', 'biz', 'info', 'in', 'name', 'co',
'ac.id', 'sch.id', 'go.id', 'mil.id', 'co.id', 'or.id', 'web.id',
'my.id', 'biz.id', 'desa.id',
'my.id', 'biz.id', 'desa.id', 'id',
);
}
......@@ -194,6 +194,44 @@ class Person extends \Faker\Provider\Person
protected static $titleFemale = array('dr.', 'drg.', 'Dr.', 'Hj.');
/**
* @link http://informasipedia.com/wilayah-indonesia/daftar-kabupaten-kota-di-indonesia/
*/
protected static $birthPlaceCode = array(
'1101', '1102', '1103', '1104', '1105', '1106', '1107', '1108', '1109', '1110', '1111', '1112', '1113', '1114', '1115', '1116',
'1117', '1118', '1171', '1172', '1173', '1174', '1175', '1201', '1202', '1203', '1204', '1205', '1206', '1207', '1208', '1209',
'1210', '1211', '1212', '1213', '1214', '1215', '1216', '1217', '1218', '1219', '1220', '1221', '1222', '1223', '1224', '1225',
'1271', '1272', '1273', '1274', '1275', '1276', '1277', '1278', '1301', '1302', '1303', '1304', '1305', '1306', '1307', '1308',
'1309', '1310', '1311', '1312', '1371', '1372', '1373', '1374', '1375', '1376', '1377', '1401', '1402', '1403', '1404', '1405',
'1406', '1407', '1408', '1409', '1410', '1471', '1472', '1501', '1502', '1503', '1504', '1505', '1506', '1507', '1508', '1509',
'1571', '1572', '1601', '1602', '1603', '1604', '1605', '1606', '1607', '1608', '1609', '1610', '1611', '1612', '1613', '1671',
'1672', '1673', '1674', '1701', '1702', '1703', '1704', '1705', '1706', '1707', '1708', '1709', '1771', '1801', '1802', '1803',
'1804', '1805', '1806', '1807', '1808', '1809', '1810', '1811', '1812', '1813', '1871', '1872', '1901', '1902', '1903', '1904',
'1905', '1906', '1971', '2101', '2102', '2103', '2104', '2105', '2171', '2172', '3101', '3171', '3172', '3173', '3174', '3175',
'3201', '3202', '3203', '3204', '3205', '3206', '3207', '3208', '3209', '3210', '3211', '3212', '3213', '3214', '3215', '3216',
'3217', '3218', '3271', '3272', '3273', '3274', '3275', '3276', '3277', '3278', '3279', '3301', '3302', '3303', '3304', '3305',
'3306', '3307', '3308', '3309', '3310', '3311', '3312', '3313', '3314', '3315', '3316', '3317', '3318', '3319', '3320', '3321',
'3322', '3323', '3324', '3325', '3326', '3327', '3328', '3329', '3371', '3372', '3373', '3374', '3375', '3376', '3401', '3402',
'3403', '3404', '3471', '3501', '3502', '3503', '3504', '3505', '3506', '3507', '3508', '3509', '3510', '3511', '3512', '3513',
'3514', '3515', '3516', '3517', '3518', '3519', '3520', '3521', '3522', '3523', '3524', '3525', '3526', '3527', '3528', '3529',
'3571', '3572', '3573', '3574', '3575', '3576', '3577', '3578', '3579', '3601', '3602', '3603', '3604', '3671', '3672', '3673',
'3674', '5101', '5102', '5103', '5104', '5105', '5106', '5107', '5108', '5171', '5201', '5202', '5203', '5204', '5205', '5206',
'5207', '5208', '5271', '5272', '5301', '5302', '5303', '5304', '5305', '5306', '5307', '5308', '5309', '5310', '5311', '5312',
'5313', '5314', '5315', '5316', '5317', '5318', '5319', '5320', '5321', '5371', '6101', '6102', '6103', '6104', '6105', '6106',
'6107', '6108', '6109', '6110', '6111', '6112', '6171', '6172', '6201', '6202', '6203', '6204', '6205', '6206', '6207', '6208',
'6209', '6210', '6211', '6212', '6213', '6271', '6301', '6302', '6303', '6304', '6305', '6306', '6307', '6308', '6309', '6310',
'6311', '6371', '6401', '6402', '6403', '6407', '6408', '6409', '6411', '6471', '6472', '6474', '6501', '6502', '6503', '6504',
'6571', '7101', '7102', '7103', '7104', '7105', '7106', '7107', '7108', '7109', '7110', '7111', '7171', '7201', '7202', '7203',
'7204', '7205', '7206', '7207', '7208', '7209', '7210', '7211', '7212', '7271', '7301', '7302', '7303', '7304', '7305', '7306',
'7307', '7308', '7309', '7310', '7311', '7312', '7313', '7314', '7315', '7316', '7317', '7318', '7322', '7324', '7326', '7371',
'7372', '7373', '7401', '7402', '7403', '7404', '7405', '7406', '7407', '7408', '7409', '7410', '7411', '7412', '7413', '7414',
'7415', '7471', '7472', '7501', '7502', '7503', '7504', '7505', '7571', '7601', '7602', '7603', '7604', '7605', '7606', '8101',
'8102', '8103', '8104', '8105', '8106', '8107', '8108', '8109', '8171', '8172', '8201', '8202', '8203', '8204', '8205', '8206',
'8207', '8208', '8271', '8272', '9101', '9102', '9103', '9104', '9105', '9106', '9107', '9108', '9109', '9110', '9111', '9112',
'9113', '9114', '9115', '9116', '9117', '9118', '9119', '9120', '9121', '9122', '9123', '9124', '9125', '9126', '9127', '9128',
'9171', '9201', '9202', '9203', '9204', '9205', '9206', '9207', '9208', '9209', '9210', '9211', '9212', '9271',
);
/**
* For academic title
* @link http://id.wikipedia.org/wiki/Gelar_akademik
*/
......@@ -266,7 +304,8 @@ class Person extends \Faker\Provider\Person
public function nik($gender = null, $birthDate = null)
{
# generate first numbers (region data)
$nik = $this->generator->numerify('######');
$nik = $this->birthPlaceCode();
$nik .= $this->generator->numerify('##');
if (!$birthDate) {
$birthDate = $this->generator->dateTimeBetween();
......@@ -286,8 +325,19 @@ class Person extends \Faker\Provider\Person
$nik .= $birthDate->format('my');
# add last random digits
$nik.= $this->generator->numerify('####');
$nik .= $this->generator->numerify('####');
return $nik;
}
/**
* Generates birth place code for NIK
*
* @link https://id.wikipedia.org/wiki/Nomor_Induk_Kependudukan
* @link http://informasipedia.com/wilayah-indonesia/daftar-kabupaten-kota-di-indonesia/
*/
protected function birthPlaceCode()
{
return static::randomElement(static::$birthPlaceCode);
}
}
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment