Drupal 自定义模块条码生成
来源:互联网 发布:淘宝店铺介绍 编辑:程序博客网 时间:2024/06/11 07:09
需要生成一个规则条码,自定义了下面功能:
<?php/** * @file * Defines "通过已上传的样板资料生成对应的条码" * * @TODO: Split admin functions into their own file. */ /*** Implements hook_menu(). 执行Hook来注册一个URL*/function sample_barcode_menu(){$items=array();$items['samplebarcode']=array('title'=>'Sample Barcode','page callback'=>'sample_intro','access callback'=>TRUE,);$items['samplebarcode/createrbarcode']=array('title'=>'Barcode Creater','description'=>'生成样板衣的条码','page callback'=>'drupal_get_form','page arguments'=>array('sample_barcode_creater'),//页面回调的function'access arguments'=>array('Sample Barcode Creater'),//页面调用的用户权限'access callback'=>TRUE,//'weight'=>'5',);return $items;}/** * @file * 定义一个样板单的权限 */ function sample_barcode_permission(){ return array('Sample Barcode Creater'=>array('title'=>t('样板单条码生成器'),),); } /** * @file * 定义样板单的说明 */ function sample_intro(){$markup = t('样板单操作说明');return array('#markup' => $markup); }/** * @file * 定义生成按钮的表单 */function sample_barcode_creater($form, &$form_state){ $form=array();$form['sample']= array('#type' => 'submit','#value' => t('Creater Barcode'),//'#submit' =>array('costsheet_puma_ajax'),'#ajax'=>array('callback'=>'sample_barcode_ajax','wrapper'=>'showexcel-wrapper',),);$form['showexcel']=array('#type'=>'fieldset','#title'=>t('Sample Show'),'#prefix'=>'<div id="showexcel-wrapper">','#suffix'=>'</div>','#markup' =>'',); return $form;} /** * @ * 定义ajax回调PUMA的格式转换 */ function sample_barcode_ajax($form,&$form_state){$views=views_get_view("sample_table");//$views->set_display("nobarcode");$views->preview("block_1");$results=$views->result;//dpm($results);$showbar=array();foreach($results as $key){//dpm($key);if($key->field_field_qty[0]['raw']['value']){$node=node_load($key->nid);for($i=0;$i<(int)$key->field_field_qty[0]['raw']['value'];$i++){$newbar="B".sprintf("%08d",(int)$key->nid).sprintf("%03d",$i+1);$showbar[$key->nid][]=$newbar;$node->field_samplegroup['und'][$i]['value']=$newbar;}//dpm($showbar);node_save($node);}else{Drupal_set_message("样板数量有误,请确认后再操作!");}}$form['showexcel']['#description']='Set Done';return $form['showexcel']; } /** * @ * 定义Form的提交 */
0 0
- Drupal 自定义模块条码生成
- drupal 模块
- 生成条码
- 自定义gii生成模块
- Drupal 7 模块开发 创建自定义表(table) (hook_schema)
- drupal几个模块
- Drupal常用模块简介
- drupal模块: Ajax Slideshow
- Drupal模块功能一览
- Drupal常用模块简述
- Drupal常用模块简述
- Drupal Hello World模块
- Drupal模块开发注意事项
- Drupal模块开发指南
- Drupal模块开发指南
- drupal模块开发总结
- Drupal常用模块介绍
- Drupal 常用模块推荐
- 高性能服务器架构思路【不仅是思路】
- JDK1.8-新特性
- Swift-UICollectionView布局之线性布局
- poj2376 贪心算法
- C#——窗体实验—进阶-文本框实验
- Drupal 自定义模块条码生成
- Shader and Program编程基本概念 - 转
- 162. Find Peak Element
- 华为--嵌入式软件工程师面试题汇总
- php 生成条形码(基于yii)
- Xen虚拟化技术的模式和演变
- JavaWeb防止表单重复提交
- Java反射机制和TelephoneManager电话监听
- NSLayoutAttributeLeft与NSLayoutAttributeLeading的区别