How to use Od method in Protractor

Best JavaScript code snippet using protractor

Prod_odtable_detail_SP.js

Source:Prod_odtable_detail_SP.js Github

copy

Full Screen

1// SP(세트, 기획, 이벤트) 상품 테이블 Script START //2function getURLParams(url) {3 var result = {};4 url.replace(/[?&]{1}([^=&#]+)=([^&#]*)/g, function(s, k, v) { result[k] = decodeURIComponent(v); });5 return result;6}7var URL_pdn = getURLParams(location.search); // URL 쿼리스트링 추출8// 상품 행수 최초 생성 및 동기화 폼 생성 START9function Create_od_Row_SP() {10 $.ajax({11 url: "/Product_Rows_SP",12 type: "GET",13 data: {"pdn":String(URL_pdn['pdn'])},14 cache: false,15 success: function (Row) {16 var Product_Row_SP = JSON.parse(Row);17 var od_Row_Count_SP = JSON.stringify(Product_Row_SP[0]['COUNT(*)']); // 세트,기획 상품 상세 옵션 목록 행수 (Prod_od_List_SP)18 var Prod_Row_Count_SP = JSON.stringify(Product_Row_SP[1]['COUNT(*)']); // 세트,기획 상품 목록 행수 (Product_List_SP)19 for (var i = Number(od_Row_Count_SP)-1; i > -1; i--){ // 값 전달 용 hidden 생성20 var after_Value = `<input type="hidden" id="hidden_ck_pdn_odn_`+i+`_SP" name="hidden_ck_pdn_odn_`+i+`_SP" value="0"/>21 <input type="hidden" id="hidden_ck_size_`+i+`_SP" name="hidden_ck_size_`+i+`_SP" value="0"/>22 <input type="hidden" id="hidden_ck_in_quantity_`+i+`_SP" name="hidden_ck_in_quantity_`+i+`_SP" value="0"/>23 <input type="hidden" id="hidden_ck_out_quantity_`+i+`_SP" name="hidden_ck_out_quantity_`+i+`_SP" value="0"/>`24 $('#hidden_ck_od_Row_SP').after(after_Value);25 }26 $('#hidden_ck_Prod_num').val(String(URL_pdn['pdn']));27 $('#hidden_od_Row_SP').val(od_Row_Count_SP);28 $('#hidden_ck_od_Row_SP').val(od_Row_Count_SP);29 $('#hidden_Prod_Row_SP').val(Prod_Row_Count_SP);30 }31 });32};33// 상품 행수 최초 생성 및 동기화 폼 생성 END34// 상품 행수 실시간 호출 START35function update_Rows_SP() {36 $.ajax({37 url: "/Product_Rows_SP",38 type: "GET",39 data: {"pdn":String(URL_pdn['pdn'])},40 cache: false,41 success: function (Row) {42 var Product_Row_SP = JSON.parse(Row);43 var od_Row_Count_SP = JSON.stringify(Product_Row_SP[0]['COUNT(*)']); // 세트,기획 상품 상세 옵션 목록 행수 (Prod_od_List_SP)44 var Prod_Row_Count_SP = JSON.stringify(Product_Row_SP[1]['COUNT(*)']); // 세트,기획 상품 목록 행수 (Product_List_SP)45 $('#hidden_update_Prod_Row_SP').val(Prod_Row_Count_SP);46 $('#hidden_update_od_Row_SP').val(od_Row_Count_SP);47 }48 });49 };50 // 상품 행수 실시간 호출 END51// 상품 리스트 생성 (Prod_od_List_SP) START52function updateData_SP() {53 $.ajax({54 url: "/update_Prod_od_List_SP",55 type: "GET",56 data: {"pdn":String(URL_pdn['pdn'])},57 // dataType : "json",58 cache: false,59 success: function (data1) {60 var Prod_od_List_SP = JSON.parse(data1); // String 타입 -> Object 타입으로 변환61 var od_SP_Row_Count = $('#hidden_od_Row_SP').val();62 for (var a = 0; a < Number(od_SP_Row_Count); a++){63 var pdn_odn = JSON.stringify(Prod_od_List_SP[a]['pdn_odn']).replace(/\"/g, "");64 var od_stock_sku = JSON.stringify(Prod_od_List_SP[a]['od_stock_sku']).replace(/\"/g, ""); // Object 타입 -> String 타입으로 변환65 var od_size = JSON.stringify(Prod_od_List_SP[a]['od_size']).replace(/\"/g, "");66 var od_price = JSON.stringify(Prod_od_List_SP[a]['od_price']).replace(/\"/g, "");67 var od_stock = JSON.stringify(Prod_od_List_SP[a]['od_stock']).replace(/\"/g, "");68 var od_status = JSON.stringify(Prod_od_List_SP[a]['od_status']).replace(/\"/g, "");69 var append_Value2 = `<tr class="alert" role="alert" style="cursor: pointer;">70 <td style="padding:15px;" align="center" id="id_tdck_`+String(a)+`_SP">71 <label class="checkbox-wrap checkbox-primary">72 <input type="checkbox" id="ck_`+String(a)+`_SP" value="`+pdn_odn+`" tabindex="-1">73 <span class="checkmark"></span>74 </label>75 </td>76 <td align="center" class=`+String(a)+`_SP>77 <span id="id_pdn_odn_`+String(a)+`_SP"></span>78 </td>79 <td width=30px; class=`+String(a)+`_SP>80 <div class="img" id="id_image_url_`+String(a)+`_SP"></div>81 </td>82 <td width=300px; class=`+String(a)+`_SP>83 <div class="email" id="id_od_stock_sku_`+String(a)+`_SP">84 </div>85 <input type="hidden" id="id_od_size_`+String(a)+`_SP"/>86 </td>87 <td align="center" id="id_od_price_`+String(a)+`_SP"></td>88 <td width=110px; align="center" id="id_od_status_`+String(a)+`_SP"></td>89 </tr>90 `;91 $('#id_tbody').append(append_Value2);92 $('#id_pdn_odn_'+String(a)+'_SP').append(pdn_odn);93 $('#id_od_stock_sku_'+String(a)+'_SP').append("<span id=id2_od_stock_sku_"+String(a)+"_SP>"+od_stock_sku+"</span>");94 $('#id_od_size_'+String(a)+'_SP').val(od_size);95 $('#id_od_price_'+String(a)+'_SP').append(CurrencyCommas(od_price)+"원");96 $('#id_od_status_'+String(a)+'_SP').append(od_status);97 }98 // 행 클릭 시 체크박스 체크 START //99 $("#id_tbody").on('click', 'tr', function (e) {100 if ($(e.target).is('label')) return;101 if ($(e.target).is('input[name="quantity"]')) return;102 if ($(e.target).is('td:nth-child(n+8):nth-child(-n+9)')) return;103 var chkbox = $(this).find('td:first-child :checkbox');104 chkbox.prop('checked', !chkbox.prop('checked'));105 page_move = true;106 });107 // 행 클릭 시 체크박스 체크 END //108 }109 });110 // timerID = setTimeout("updateData()", 5000); // 2초 단위로 갱신 처리111};112// 상품 리스트 생성 (Prod_od_List_SP) END113// 상품 리스트 생성 (Product_List) START114function updateData2_SP() {115 $.ajax({116 url: "/update_Prod_List_SP",117 type: "GET",118 data: {"pdn":String(URL_pdn['pdn'])},119 cache: false,120 success: function (data2) {121 var Prod_List = JSON.parse(data2); // String 타입 -> Object 타입으로 변환122 var Prod_Row_Count = $('#hidden_Prod_Row_SP').val();123 var od_Row_Count = $('#hidden_od_Row_SP').val();124 125 for (var a = 0; a < Number(Prod_Row_Count); a++){126 var prod_no = JSON.stringify(Prod_List[a]['prod_no']).replace(/\"/g, ""); // 상품 번호127 var prod_name = JSON.stringify(Prod_List[a]['prod_name']).replace(/\"/g, ""); // 상품 이름128 var image_url = "https://cdn.imweb.me/upload/"+JSON.stringify(Prod_List[a]['image_url']).replace(/\"/g, ""); // 상품 사진129 for (var b = 0; b < Number(od_Row_Count); b++){130 var pdn_odn = String($('#id_pdn_odn_'+String(b)+'_SP').html()).split('-');131 if (prod_no == pdn_odn[0]){132 $('#id2_od_stock_sku_'+String(b)+'_SP').after("<span>"+prod_name+"</span>");133 $('#id_image_url_'+String(b)+'_SP').css('background-image',"url("+image_url+")");134 }135 }136 }137 }138 });139 // timerID2 = setTimeout("updateData2()", 5000); // 2초 단위로 갱신 처리140}141// 상품 리스트 생성 (Product_List) END142// SP 현재 재고 출력 START143function update_Prod_od_List_SP() {144 update_Rows_SP();145 $.ajax({146 url: "/update_Prod_od_List_SP",147 type: "GET",148 data: {"pdn":String(URL_pdn['pdn'])},149 cache: false,150 success: function (data1) {151 var Prod_od_List_SP = JSON.parse(data1); // String 타입 -> Object 타입으로 변환152 var od_Row_Count_SP = $('#hidden_od_Row_SP').val();153 var update_od_Row_Count_SP = $('#hidden_update_od_Row_SP').val();154 var update_time_SP = JSON.stringify(Prod_od_List_SP[0]['update_time']).replace(/\"/g, "");155 $('#id_Update_time_SP').val("최근 업데이트 시간 : "+update_time_SP);156 157 for (var a = 0; a < Number(od_Row_Count_SP); a++) {158 var pdn_odn = JSON.stringify(Prod_od_List_SP[a]['pdn_odn']).replace(/\"/g, "");159 //if ($('#ck_' + String(a)).is(':checked') == false) { // 체크된 상품 제외160 $('#id_od_stock_' + String(a)+'_SP').remove();161 var after_Value2 = `<td align="center" id="id_od_stock_` + String(a) + `_SP"></td>`;162 $('#id_od_status_' + String(a)+'_SP').after(after_Value2); // 판매 상태 뒤에 추가163 //}164 }165 for (var b = 0; b < Number(od_Row_Count_SP); b++) {166 var od_pdn_odn = String($('#id_pdn_odn_' + String(b)+'_SP').text()); // 이미 페이지에 호출 된 상품번호167 for (var c = 0; c < Number(update_od_Row_Count_SP); c++) {168 var pdn_odn = JSON.stringify(Prod_od_List_SP[c]['pdn_odn']).replace(/\"/g, ""); // DB내 호출 된 상품번호169 var od_stock = JSON.stringify(Prod_od_List_SP[c]['od_stock']).replace(/\"/g, ""); // DB내 현재 재고170 //if (od_pdn_odn == pdn_odn && $('#ck_' + String(b)).is(':checked') == false) { // 이미 호출된 상품번호와 DB내 상품번호와 일치 시, 체크된 상품 제외171 if (od_pdn_odn == pdn_odn) { // 이미 호출된 상품번호와 DB내 상품번호와 일치 시172 $('#id_od_stock_' + String(b)+'_SP').append(CurrencyCommas(od_stock)); // 페이지내 호출되어 있는 상품을 찾아 현재 재고 변경173 }174 }175 }176 }177 });178 timerID5 = setTimeout("update_Prod_od_List_SP()", 5000); // 2초 단위로 갱신 처리179}180// SP 현재 재고 출력 END181// SP 입고 출고 업데이트 START //182function update_od_IN_quantity_SP() {183 $.ajax({184 url: "/update_od_IN_quantity_SP",185 type: "GET",186 data: {"pdn":String(URL_pdn['pdn'])},187 cache: false,188 success: function (data3) {189 var Prod_IN_and_Row = JSON.parse(data3); // String 타입 -> Object 타입으로 변환190 var IN_Row_Count = JSON.stringify(Prod_IN_and_Row[0]['COUNT(*)']); // Product_IN 테이블 행수191 // console.log("IN_Row_Count : "+IN_Row_Count);192 var od_Row_Count = $('#hidden_od_Row_SP').val();193 for (var c = 0; c < Number(od_Row_Count); c++){194 if($('#ck_' + String(c)+'_SP').is(':checked') == false){195 $('.in_quantity_'+String(c)+'_SP').remove();196 $('#in_insert_time_'+String(c)+'_SP').remove();197 // $('#id_in_quantity_'+String(c)).remove();198 var afterValue = `<td width=170px; class="in_quantity_`+String(c)+`_SP" align="center" style="cursor: default;">199 <div class="input-group">200 <input type="text" name="quantity" id="id_in_quantity_`+String(c)+`_SP" class="quantity form-control input-number" value="?" min="0" size="3" style="font-size:11pt" autocomplete="off">201 </div>202 </td>`;203 // var afterValue2 = `<input type="hidden" name="in_insert_time_`+String(c)+`_SP" id="in_insert_time_`+String(c)+`_SP"/>`;204 $('#id_od_stock_'+String(c)+'_SP').after(afterValue);205 // $('#hidden_ck_od_Row_SP').after(afterValue2);206 } 207 }208 if (IN_Row_Count != "0") {209 for (var a = 0; a < Number(od_Row_Count); a++) {210 if($('#ck_' + String(a)+'_SP').is(':checked') == false){211 var od_stock_sku = String($('#id2_od_stock_sku_' + String(a)+'_SP').text()); // 페이지내 stock_sku 호출212 var in_quantity = 0;213 for (var b = 0; b < Number(IN_Row_Count); b++) {214 var prod_code_size = JSON.stringify(Prod_IN_and_Row[b + 1]['custom_prod_code']).replace(/\"/g, "") + "-" + JSON.stringify(Prod_IN_and_Row[b + 1]['size']).replace(/\"/g, "");215 var prod_in_quantity = JSON.stringify(Prod_IN_and_Row[b + 1]['quantity']).replace(/\"/g, ""); // QR 입고 별 수량216 // var prod_in_insert_time = JSON.stringify(Prod_IN_and_Row[1]['insert_time']).replace(/\"/g, ""); // 가장 최신 QR 입고 날짜217 if (od_stock_sku == prod_code_size) {218 in_quantity += Number(prod_in_quantity);219 // $('#in_insert_time_' + String(a)+'_SP').val(prod_in_insert_time);220 }221 }222 $('#id_in_quantity_' + String(a)+'_SP').val(in_quantity);223 }224 }225 }226 else{227 for (var a = 0; a < Number(od_Row_Count); a++) {228 if($('#ck_' + String(a)+'_SP').is(':checked') == false){229 in_quantity = 0;230 // prod_in_insert_time = '';231 $('#id_in_quantity_' + String(a)+'_SP').val(in_quantity); // count가 0이면 0232 // $('#in_insert_time_' + String(a)+'_SP').val(prod_in_insert_time);233 }234 }235 }236 }237 });238 // timerID6 = setTimeout("update_od_IN_quantity_SP()", 3000); // 3초 단위로 갱신 처리239}240function update_od_OUT_quantity_SP() {241 $.ajax({242 url: "/update_od_OUT_quantity_SP",243 type: "GET",244 data: {"pdn":String(URL_pdn['pdn'])},245 cache: false,246 success: function (data4) {247 var Prod_OUT_and_Row = JSON.parse(data4); // String 타입 -> Object 타입으로 변환248 var OUT_Row_Count = JSON.stringify(Prod_OUT_and_Row[0]['COUNT(*)']);249 // console.log("OUT_Row_Count : "+OUT_Row_Count);250 var od_Row_Count = $('#hidden_od_Row_SP').val();251 for (var c = 0; c < Number(od_Row_Count); c++){252 if($('#ck_' + String(c)+'_SP').is(':checked') == false){253 $('.out_quantity_'+String(c)+'_SP').remove();254 $('#out_insert_time_'+String(c)+'_SP').remove();255 // $('#id_out_quantity_'+String(c)).remove();256 var afterValue = `<td width=170px; class="out_quantity_`+String(c)+`_SP" align="center" style="cursor: default;">257 <div class="input-group">258 <input type="text" name="quantity" id="id_out_quantity_`+String(c)+`_SP" class="quantity form-control input-number" value="?" min="0" size="3" style="font-size:11pt" autocomplete="off">259 </div>260 </td>`;261 // var afterValue2 = `<input type="hidden" name="out_insert_time_`+String(c)+`_SP" id="out_insert_time_`+String(c)+`_SP"/>`;262 $('.in_quantity_'+String(c)+'_SP').after(afterValue);263 // $('#sync_btn').before(afterValue2); 264 } 265 }266 if (OUT_Row_Count != "0") {267 for (var a = 0; a < Number(od_Row_Count); a++) {268 if($('#ck_' + String(a)+'_SP').is(':checked') == false){269 var od_stock_sku = String($('#id2_od_stock_sku_' + String(a)+'_SP').text());270 var out_quantity = 0;271 for (var b = 0; b < Number(OUT_Row_Count); b++) {272 var prod_code_size = JSON.stringify(Prod_OUT_and_Row[b + 1]['custom_prod_code']).replace(/\"/g, "") + "-" + JSON.stringify(Prod_OUT_and_Row[b + 1]['size']).replace(/\"/g, "");273 var prod_out_quantity = JSON.stringify(Prod_OUT_and_Row[b + 1]['quantity']).replace(/\"/g, ""); // QR 출고 별 수량274 // var prod_out_insert_time = JSON.stringify(Prod_OUT_and_Row[1]['insert_time']).replace(/\"/g, ""); // 가장 최신 QR 출고 날짜275 if (od_stock_sku == prod_code_size) {276 out_quantity += Number(prod_out_quantity);277 // $('#out_insert_time_' + String(a)+'_SP').val(prod_out_insert_time);278 }279 }280 $('#id_out_quantity_' + String(a)+'_SP').val(out_quantity);281 }282 }283 }284 else{285 for (var a = 0; a < Number(od_Row_Count); a++) {286 if($('#ck_' + String(a)+'_SP').is(':checked') == false){287 out_quantity = 0;288 // prod_out_insert_time = '';289 $('#id_out_quantity_' + String(a)+'_SP').val(out_quantity); // count가 0이면 0290 // $('#out_insert_time_' + String(a)+'_SP').val(prod_out_insert_time);291 }292 }293 }294 }295 });296 // timerID7 = setTimeout("update_od_OUT_quantity_SP()", 3000); // 3초 단위로 갱신 처리297}...

Full Screen

Full Screen

orderController.js

Source:orderController.js Github

copy

Full Screen

1/**2 * Created by 重书 on 2016/9/7.3 */4var db = require('../utils/db');5var config = require('../config/app_config');6var sd = require('silly-datetime');7var https = require('https');8var async = require('async');9var env = require('../app');10var couponController = require('../controller/couponController');11var balanceController = require('../controller/balanceController');12var requestify = require('requestify'); 13/**14 * new order data ={15 * channel:"wx_pub",16 * amount:1000,17 * orderInfo: [ {id:'1',name:"food1",count:2,price:10} , 18 * {id:'2',name:"food2",count:3,price:20} ,19 * ],20 * desk_id: 1,21 * store_id: 1,22 * price: 10,23 * open_id : "ofgw6w_9U_gXWa74bVa1Wjwixqbo"24 * }25 */26exports.createOrderInfoNew = function (data,callback){27 console.log('info New ' + JSON.stringify(data));28 var orderInfo = data.orderInfo;29 var userOpenId = data.openId || 123 ;30 var time = sd.format(new Date(), 'YYYY/MM/DD/HH:mm');31 var store_id = parseInt(data.store_id || 1);32 var desk_id = parseInt(data.desk_id || 1);33 var price = data.price;34 var realPrice = data.realPrice;35 var coupon_id = data.coupon_id;36 var couponDes = data.couponDes;37 var string = '';38 if (orderInfo.length != 0) {39 for (var i in orderInfo) {40 if(orderInfo[i].detail == null){41 string += orderInfo[i].name + "*" + orderInfo[i].count + ";";42 }else{43 string += orderInfo[i].name + "("+orderInfo[i].detail+") "+"*" + orderInfo[i].count + ";";44 }45 }46 var values_order = [store_id, desk_id, time, userOpenId,string,price, realPrice,0,'N',coupon_id,couponDes];47 var sql_order = 'INSERT INTO od_hdr (od_store_id,od_desk_id,od_date,od_wechatopenid,od_string,od_fixed_total_price,od_total_price,od_state,od_isprint,od_coupon_id,od_coupon_description) ' +48 'VALUES (?,?,?,?,?,?,?,?,?,?,?)';49 db.exec(sql_order, values_order, function (err, result) {50 if (err) {51 callback(err);52 return;53 }54 var order_id = result.insertId;55 callback(null,order_id);56 var j = 0;57 for (var i in orderInfo) {58 var sql_food = 'INSERT INTO od_ln (od_id,od_line_number,gd_name,gd_quantity,od_price,gd_id,gd_detail) ' +59 'VALUES (?,?,?,?,?,?,?)';60 var food_id = orderInfo[i].id;61 var food_name = orderInfo[i].name;62 var food_quantity = orderInfo[i].count;63 var food_price = orderInfo[i].price;64 var food_detail = orderInfo[i].detail;65 var values_food = [order_id, j + 1, food_name, food_quantity, food_price,food_id,food_detail];66 db.exec(sql_food, values_food, function (err, result) {67 if (err) {68 callback(err);69 return;70 } else {71 console.log("food inserted");72 }73 });74 ++j;75 }76 if(coupon_id != null){77 couponController.useCoupon(coupon_id,function (err,result) {78 if(err){79 console.log(err);80 return;81 }82 //console.log(result);83 })84 }85 });86 }87};88exports.finishOrderWithValueCard = function (req,res,next){89 var data = req.body;90 var orderInfo = data.orderInfo;91 var userOpenId = data.openId ||123 ;92 var time = sd.format(new Date(), 'YYYY/MM/DD/HH:mm');93 var store_id = parseInt(data.store_id || 1);94 var desk_id = parseInt(data.desk_id || 1);95 var price = data.price;96 var realPrice = data.realPrice;97 var coupon_id = data.coupon_id;98 var couponDes = data.couponDes;99 //var card_number = data.card_number;100 var string = '';101 balanceController.deduct(userOpenId,realPrice,function (err,result) {102 if(err){103 console.log(err);104 return;105 }106 var r = {};107 r.code = "success";108 res.json(r);109 res.end();110 if(coupon_id != null){111 couponController.useCoupon(coupon_id,function (err,result) {112 if(err){113 console.log(err);114 return;115 }116 //console.log(result);117 })118 }119 //console.log(result);120 121 });122 if (orderInfo.length != 0) {123 for (var i in orderInfo) {124 if(orderInfo[i].detail == null){125 string += orderInfo[i].name + "*" + orderInfo[i].count + ";";126 }else{127 string += orderInfo[i].name + "("+orderInfo[i].detail+") "+"*" + orderInfo[i].count + ";";128 }129 130 }131 var values_order = [store_id, desk_id, time, userOpenId,string,price, realPrice,1,'N',coupon_id,couponDes];132 var sql_order = 'INSERT INTO od_hdr (od_store_id,od_desk_id,od_date,od_wechatopenid,od_string,od_fixed_total_price,od_total_price,od_state,od_isprint,od_coupon_id,od_coupon_description) ' +133 'VALUES (?,?,?,?,?,?,?,?,?,?,?)';134 db.exec(sql_order, values_order, function (err, result) {135 if (err) {136 console.log(err);137 return;138 }139 var order_id = result.insertId;140 //callback(null,order_id);141 var j = 0;142 var sql_food = 'INSERT INTO od_ln (od_id,od_line_number,gd_name,gd_quantity,od_price,gd_id,gd_detail) ' +143 'VALUES (?,?,?,?,?,?,?)';144 async.every(orderInfo, function(food, callback) {145 var food_id = food.id;146 var food_name = food.name;147 var food_quantity = food.count;148 var food_price = food.price;149 var food_detail = food.detail;150 var values_food = [order_id, j + 1, food_name, food_quantity, food_price,food_id,food_detail];151 db.exec(sql_food, values_food, function (err, result) {152 if (err) {153 //callback(err);154 return;155 } else {156 //console.log("food inserted");157 callback(null, !err)158 }159 });160 ++j;161 }, function(err ,result) {162 if( !result ) {163 console.log('fetching err: ' + err);164 return;165 } else {166 if(env.config.printInProd){167 requestify.get('http://admin.shmddm.com/core/PrinterAPI.php?orderId=' + order_id)168 .then(function(response) {169 console.log('打印订单' + order_id +'请求返回:' +response.getCode() +' ' + response.body);170 });171 } else {172 console.log("dev: print order now ... ");173 }174 }175 });176 177 });178 }179};180/**181 * history order : 182 * order_list ={ historyOrder:183 * [184 * {"id":176,"date":"2016/11/18/05:05","items":[{"name":"蛋挞","counter":"3"}],"price":30,"state":0},185 * {"id":177,"date":"2016/11/18/05:05","items":[{"name":"蛋挞","counter":"1"},{"name":"慕斯","counter":"1"}],"price":30,"state":1}186 * ]187 * }188 */189exports.searchOrder = function (req, res, next) {190 var data = req.body;191 var userOpenId = req.body.openId || '123';192 // var openIdCode = data.code;193 var values_order = [userOpenId,0,5];194 var sql_order = 'SELECT * FROM od_hdr where od_wechatopenid = ? order by od_date DESC LIMIT ?,? ';195 db.exec(sql_order, values_order, function (err, result) {196 if (err) {197 console.log('get historyOrder from db err');198 res.end();199 return;200 }201 var order_detail = {};202 var order_list = [];203 if (result.length > 0) {204 for (var i = 0; i < result.length; ++i) {205 var items = new Array();206 var item_list = [];207 var item_detail = {};208 items = result[i].od_string.split(";");209 for (var j = 0; j < items.length; j++) {210 var item = items[j].split("*");211 if (item[0] != null && item[0] != '') {212 item_detail['name'] = item[0];213 item_detail['counter'] = item[1];214 item_list.push(item_detail);215 item_detail = {};216 }217 }218 order_detail['id'] = result[i].od_id;219 order_detail['date'] = sd.format(result[i].od_date, 'YYYY/MM/DD/HH:mm');220 order_detail['items'] = item_list;221 order_detail['price'] = result[i].od_fixed_total_price;222 order_detail['realPrice'] = result[i].od_total_price;223 order_detail['state'] = result[i].od_state;224 order_detail['couponId'] = result[i].od_coupon_id;225 order_detail['couponDes'] = result[i].od_coupon_description;226 order_list.push(order_detail);227 order_detail = {};228 }229 }230 var obj = {};231 obj.historyOrder = order_list;232 res.json(obj);233 res.end();234 });235};236exports.order = function (req, res, next) {237 var data = req.body;238 var userOpenId = req.body.openId || '123';239 var offset = (data.page - 1)*5;240 // var openIdCode = data.code;241 var values_order = [userOpenId,offset,5];242 //var sql_order = 'SELECT TOP 5 * FROM od_hdr WHERE od_id NOT IN ( SELECT TOP 5*(?-1) od_id FROM od_hdr where od_wechatopenid = ? order by od_date DESC ) and od_wechatopenid = ? order by od_date DESC';243 var sql_order = 'SELECT * FROM od_hdr where od_wechatopenid = ? order by od_date DESC LIMIT ?,? ';244 db.exec(sql_order, values_order, function (err, result) {245 if (err) {246 //callback(err);247 return;248 }249 //callback(null, result);250 //console.log(result);251 var order_detail = {};252 var order_list = [];253 if (result.length > 0) {254 for (var i = 0; i < result.length; ++i) {255 var items = new Array();256 var item_list = [];257 var item_detail = {};258 items = result[i].od_string.split(";");259 for (var j = 0; j < items.length; j++) {260 var item = items[j].split("*");261 if (item[0] != null && item[0] != '') {262 item_detail['name'] = item[0];263 item_detail['counter'] = item[1];264 item_list.push(item_detail);265 item_detail = {};266 }267 }268 order_detail['id'] = result[i].od_id;269 order_detail['date'] = sd.format(result[i].od_date, 'YYYY/MM/DD/HH:mm');270 order_detail['items'] = item_list;271 order_detail['price'] = result[i].od_fixed_total_price;272 order_detail['realPrice'] = result[i].od_total_price;273 order_detail['state'] = result[i].od_state;274 order_detail['couponId'] = result[i].od_coupon_id;275 order_detail['couponDes'] = result[i].od_coupon_description;276 order_list.push(order_detail);277 order_detail = {};278 }279 }280 var a = {};281 a.moreOrder = order_list;282 //console.log(a.moreOrder);283 res.json(a);284 });285}286exports.updateOrder = function (order_no) { // ***** 定义 0为未支付,1为支付成功,2为已出,3为取消 *******287 //var jsonSet = req;288 var orderId = order_no || '123';289 // var openIdCode = data.code;290 var values_order = [orderId];291 var sql_order = 'UPDATE od_hdr SET od_state = 1 where od_id = ? ';292 var sql_get_items = 'SELECT gd_id,gd_quantity FROM od_ln where od_id = ? ';293 var sql_get_coupon = 'SELECT od_coupon_id FROM od_hdr where od_id = ?';294 var sql_update_inventory = 'UPDATE gd_mst SET gd_inventory = gd_inventory - ? where gd_id = ? ';295 async.series({296 // update297 step_update: function(callback) {298 db.exec(sql_order, values_order, function (err, result) {299 if (err) {300 //callback(err);301 console.log(err);302 return;303 }304 //callback(null, result);305 callback(null, 'update order successfully');306 });307 },308 //getcoupon309 step_getcoupon: function(callback){310 db.exec(sql_get_coupon,values_order,function (err, result) {311 if(err){312 console.log(err);313 callback(err)314 }315 //console.log(result);316 callback(null,result);317 })318 },319 // get items320 step_get:function(callback) {321 db.exec(sql_get_items, values_order, function (err, result) {322 if (err) {323 console.log(err);324 return;325 }326 //callback(null, result);327 //console.log(result);328 //var item_detail = {};329 //var item_list = [];330 if (result.length > 0) {331 var item_list = [];332 var item_detail = {};333 for (var i = 0; i < result.length; ++i) {334 item_detail['id'] = result[i].gd_id;335 item_detail['quantity'] = result[i].gd_quantity;336 item_list.push(item_detail);337 item_detail = {};338 }339 callback(null, item_list);340 }341 });342 }343 },344 function(err, results) {345 // update inventory in parallel346 var item_list = results.step_get;347 var couponUsed = results.step_getcoupon;348 // if(couponUsed.length >0){349 // couponController.useCoupon(couponUsed[0].od_coupon_id,function (err,result) {350 // if(err){351 // console.log(err);352 // return;353 // }354 // console.log(result);355 // })356 // }357 if(env.config.printInProd){358 requestify.get('http://admin.shmddm.com/core/PrinterAPI.php?orderId=' + orderId)359 .then(function(response) {360 console.log('打印订单' + orderId +'请求返回:' +response.getCode() +' ' + response.body);361 });362 }363 if(item_list.length > 0){364 async.each(item_list, function(item, callback) {365 var values_item = [item.quantity,item.id];366 db.exec(sql_update_inventory, values_item, function (err, result) {367 if (err) {368 console.log(err);369 return;370 }371 //callback(null, result);372 //console.log(result);373 });374 }, function(err) {375 log('1.1 err: ' + err);376 return;377 });378 }379 });380};381exports.cancelOrder = function (req,res,next) {382 var data = req.body;383 var orderId = data.order_id;384 // var openIdCode = data.code;385 var values_order = [orderId];386 var sql_order = 'UPDATE od_hdr SET od_state = 3 where od_id = ? ';387 var sql_get_coupon = 'SELECT od_coupon_id FROM od_hdr where od_id = ?';388 async.series({389 // update390 step_update: function(callback) {391 db.exec(sql_order, values_order, function (err, result) {392 if (err) {393 //callback(err);394 console.log(err);395 return;396 }397 //callback(null, result);398 });399 callback(null, 'cancel order successfully');400 },401 //getcoupon402 step_getcoupon: function(callback){403 db.exec(sql_get_coupon,values_order,function (err, result) {404 if(err){405 console.log(err);406 callback(err)407 }408 //console.log(result);409 callback(null,result);410 })411 }412 },413 function(err, results) {414 // update inventory in parallel415 var couponUsed = results.step_getcoupon;416 if(couponUsed.length >0){417 couponController.rollbackCoupon(couponUsed[0].od_coupon_id,function (err,result) {418 if(err){419 console.log(err);420 return;421 }422 //console.log(result);423 })424 }425 res.end();426 });...

Full Screen

Full Screen

prescription.js

Source:prescription.js Github

copy

Full Screen

1function showItem(item){2 $("#both").toggle();3 $("#single").toggle();4 }5 var power_od = 0;6 var power_os = 0;7 //Upper value8 var sph_od;9 var cyl_od;10 var add_od;11 var axis_od;12 //lower value13 var sph_os;14 var cyl_os;15 var add_os;16 var axis_os;17 18 var pd;19 var pd_left;20 var pd_right;21 var patient_name;22 var remarks;// for comments provided by the user.23 function populate_value()24 {25 //Upper value26 sph_od = $('#sph_od').val();27 cyl_od = $('#cyl_od').val();28 if(sph_od=='SPH' || sph_od=="PLANO" || sph_od==""){29 sph_od=0;30 }31 if(cyl_od=='CYL' || cyl_od=="PLANO" || cyl_od==""){32 cyl_od=0;33 }34 add_od = $('#add_od').val();35 axis_od = $('#axis_od').val()36 //lower value37 sph_os = $('#sph_os').val();38 cyl_os = $('#cyl_os').val();39 if(sph_os=='SPH' || sph_os=="PLANO" || sph_os==""){40 sph_os=0;41 }42 if(cyl_os=='CYL' || cyl_os=="PLANO" || cyl_os==""){43 cyl_os=0;44 }45 add_os = $('#add_os').val();46 axis_os =$('#axis_os').val();47 48 // more infos49 remarks = $("#extraComment").val();50 pd = $('#PD').val();51 pd_left = $('#PD2').val();52 pd_right = $('#PD1').val();53 patient_name = $("#patientName").val();54 }55 function check_for_default()56 {57 if(sph_od =="0" && cyl_od =="" && add_od=="" && axis_od =="" && sph_os =="0" && cyl_os =="" && add_os=="" && axis_os =="")58 {59 if(window.location == base_url+'user/my_prescription'){60 var msg1 = 'At least insert value for either SPH OD or SPH OS.';61 $('#sph_od').attr('style','border:3px solid #BB0000');62 $('#sph_os').attr('style','border:3px solid #BB0000');63 overall_message = overall_message+'<br/>'+msg1+'<br/>';64 return true;65 }66 result = confirm("Do you want glasses with non-prescription lenses?");67 if(result == true)68 {69 $('#sph_od').attr('style','border:1px solid #CCC');70 $('#sph_os').attr('style','border:1px solid #CCC');71 return true;72 }73 if(result == false)74 {75 var msg = 'At least insert value for either SPH OD or SPH OS.';76 $('#sph_od').attr('style','border:3px solid #BB0000');77 $('#sph_os').attr('style','border:3px solid #BB0000');78 overall_message = overall_message+'<br/>'+msg+'<br/>';79 return true;80 }81 }82 else{83 $('#sph_od').attr('style','border:1px solid #CCC');84 $('#sph_os').attr('style','border:1px solid #CCC');85 }86 return false;87 }88function check_neg_pos()89{90 var flag_od = false;91 var flag_os = false;92 var msg = "";93 if((check_positive(sph_od) =="-" && check_positive(cyl_od) == "+") || (check_positive(sph_od) =="+" && check_positive(cyl_od) == "-") )94 {95 if(feedback_od!=true){96 flag_od = true;97 $('#sph_od').attr('style','border:3px solid #BB0000');98 $('#cyl_od').attr('style','border:3px solid #BB0000');99 msg = "The values you have entered for SPH and CYL is +ve and –ve in OD";100 }101 }102 if((check_positive(sph_os) =="-" && check_positive(cyl_os) == "+") || (check_positive(sph_os) =="+" && check_positive(cyl_os) == "-") )103 {104 if(feedback_os!=true){105 flag_os = true;106 $('#sph_os').attr('style','border:3px solid #BB0000');107 $('#cyl_os').attr('style','border:3px solid #BB0000');108 msg = msg +"\nThe values you have entered for SPH and CYL is +ve and –ve in OS";109 }110 }111 if (flag_od == true || flag_os == true)112 {113 var msg1 = msg+"\n\n\nIf the prescription is correct click Ok."114 var flag =confirm(msg1);115 if(flag == false)116 {117// alert('Dont proceed with check out');118 overall_message = overall_message+'<br/>'+msg;119 }120 else if(flag == true)121 {122 feedback_od=true;123 feedback_os=true;124 $('#sph_od').attr('style','border:1px solid #ccc');125 $('#cyl_od').attr('style','border:1px solid #ccc');126 $('#sph_os').attr('style','border:1px solid #ccc');127 $('#cyl_os').attr('style','border:1px solid #ccc');128// alert('Proceed with check out');129 }130 }131 if((check_positive(sph_od)!=check_positive(sph_os)) && sph_od!=0 && sph_os!=0){132 if(feedback_sph!=true){133 msg = "The values you have entered for SPH OD and SPH OS is +ve and –ve.\n\n\nIf the prescription is correct click Ok.";134 var flag = confirm(msg);135 if(flag==true){136 feedback_sph=true;137 $('#sph_od').attr('style','border:1px solid #ccc');138 $('#sph_os').attr('style','border:1px solid #ccc');139 //proceed further.140 }141 else if(flag==false){142 overall_message = overall_message+'<br/>'+"The values you have entered for SPH OD and SPH OS is +ve and –ve.";143 $('#sph_od').attr('style','border:3px solid #BB0000');144 $('#sph_os').attr('style','border:3px solid #BB0000');145 }146 }147 }148 149 if((check_positive(cyl_od)=='-' && check_positive(cyl_os)=='+') ||(check_positive(cyl_od)=='+' && check_positive(cyl_os)=='-')){150 if(feedback_cyl!=true){151 msg = "The values you have entered for CYL OD and CYL OS is +ve and –ve.\n\n\nIf the prescription is correct click Ok.";152 var flag = confirm(msg);153 if(flag==true){154 feedback_cyl=true;155 $('#cyl_od').attr('style','border:1px solid #ccc');156 $('#cyl_os').attr('style','border:1px solid #ccc');157 //proceed further.158 }159 else if(flag==false){160 $('#cyl_od').attr('style','border:3px solid #BB0000');161 $('#cyl_os').attr('style','border:3px solid #BB0000');162 overall_message = overall_message+'<br/>'+'The values you have entered for CYL OD and CYL OS is +ve and –ve.';163 }164 }165 }166}167 function check_sph_value()168 {169 var od_flag=false;170 var os_flag=false;171 msg ="";172 if(sph_od=="0" && plano_od==false)173 {174 msg = "Would you like a plano in OD";175 od_flag=true;176 }177 if(sph_os=="0" && plano_os==false)178 {179 msg = msg + "\nWould you like a plano lens in OS ";180 os_flag=true;181 }182 if(msg!="")183 {184 var flag = confirm(msg);185 if(flag==true){186 if(od_flag==false)plano_os = true;187 if(os_flag==false)plano_od = true;188 }189 else{190 overall_message = overall_message+'<br/>'+"Please insert at least value for either SPH OD or SPH OS ";191 }192 }193 }194 function check_axis_cyl()195 {196 flag_cyl_od = false;197 flag_axis_od = false;198 flag_cyl_os = false;199 flag_axis_os = false;200 if(cyl_od !="")201 flag_cyl_od = true;202 if(axis_od!="")203 flag_axis_od = true;204 if(cyl_os !="")205 flag_cyl_os = true;206 if(axis_os!="")207 flag_axis_os = true;208 if((flag_cyl_od == false && flag_axis_od == true ) || (flag_cyl_od == true && flag_axis_od == false ) )209 {210 if(flag_cyl_od == false)211 {212 $('#cyl_od').attr('style','border:3px solid #BB0000');213 overall_message = overall_message+'<br/>'+"Please enter CYL value for OD ";214 }215 else if (flag_axis_od == false)216 {217 $('#axis_od').attr('style','border:3px solid #BB0000');218 overall_message = overall_message+'<br/>'+"Please enter Axis value for OD ";219 }220 }221 else{222 $('#cyl_od').attr('style','border:1px solid #ccc');223 $('#axis_od').attr('style','border:1px solid #ccc');224 }225 if((flag_cyl_os == false && flag_axis_os == true ) || (flag_cyl_os == true && flag_axis_os == false ) )226 {227 if(flag_cyl_os == false)228 {229 $('#cyl_os').attr('style','border:3px solid #BB0000');230 overall_message = overall_message+'<br/>'+"Please enter CYL value for OS";231 }232 else if (flag_axis_os == false)233 {234 $('#axis_os').attr('style','border:3px solid #BB0000');235 overall_message = overall_message+'<br/>'+"Please enter Axis value for OS";236 }237 }238 else{239 $('#cyl_os').attr('style','border:1px solid #ccc');240 $('#axis_os').attr('style','border:1px solid #ccc');241 }242 }243 function check_add_power()244 {245 var disabled = $("#add_od").attr('disabled');246 if(disabled=='' || disabled==null){247 if(add_od==""&& (sph_od!=0 && sph_od!='')){248 $('#add_od').attr('style','border:3px solid #BB0000');249 overall_message = overall_message+"<br/>Please add power for OD.";250 }251 else $('#add_od').attr('style','border:1px solid #CCC');252 if(add_os=="" && (sph_os!=0 && sph_os!='')){253 $('#add_os').attr('style','border:3px solid #BB0000');254 overall_message = overall_message+"<br/>Please add power for OS.";255 }else $('#add_os').attr('style','border:1px solid #CCC');256 return false;257 }258 }259 function validate()260 {261 populate_value();262 if(check_prism()==false){263 if(check_for_default()==false)264 {265 var flag = check_prism();266 if(flag==false){267 check_sph_value();268 check_neg_pos();269 check_axis_cyl();270 check_add_power();271 check_patient_name();272 check_pd();273 }274 }275 }else {276 $(".presc_validation_error").remove();277 var msg = '<div class="presc_validation_error">'+overall_message+'</div>';278 $(msg).insertBefore("#file_uploader");279 show_tab('email_presc');280 }281 }282 function check_prism(){283 var prism_value = checked_buttons('prism');284 if(prism_value=="Yes"){285 alert("You have selected Prism so, you don't need to fill prescription but you must upload your prescription.\nPlease upload your prescription");286 overall_message="You have selected Prism so, you don't need to fill prescription but you must upload your prescription.<br/>Please upload your prescription";287 return true;288 }289 return false;290 }291 function check_pd(){292 var display_single = $("#single").css('display');293 var display_both = $("#both").css('display');294 if(display_single=='block'){295 var pd = $("#PD").val();296 if(pd==""){297 $("#PD").css('border','3px solid #BB0000');298 overall_message=overall_message+'<br/>'+'Please select a value for PD';299 }else{300 $("#PD").css('border','1px solid #CCC');301 }302 }303 if(display_both=='block'){304 var pd1 = $("#PD1").val();305 var pd2 = $("#PD2").val();306 if(pd1==""){307 overall_message=overall_message+'<br/>'+'Please select a value for Right PD';308 $("#PD1").css('border','3px solid #BB0000');309 }else{310 $("#PD1").css('border','1px solid #CCC');311 }312 if(pd2==""){313 $("#PD2").css('border','3px solid #BB0000');314 overall_message=overall_message+'<br/>'+'Please select a value for Left PD';315 }else{316 $("#PD2").css('border','1px solid #CCC');317 }318 }319 //alert()320 }321 function check_patient_name(){322 patient_name = $("#patientName").val();323 if(patient_name=="" || patient_name==null){324 $("#patientName").css('border','3px solid #BB0000');325 overall_message=overall_message+'<br/>'+'Please insert the patient name';326 }327 else{328 $("#patientName").css('border','1px solid #ccc');329 }330 }331 function check_positive(val)332 {333 if(val>=0){334 return ('+')335 }else if(val<0) return ('-');336 else return ('+');337// return val.charAt(0);338 }339 function calculate_power(sph, cyl){340 return parseFloat(sph) + parseFloat(cyl /2)341 }342 343 $(function(){344 if(lens == 1 || lens == 2){345 $("#add_od").removeAttr('disabled');346 $("#add_od_overlay").css('display','none');347 348 $("#add_os").removeAttr('disabled');349 $("#add_os_overlay").css('display','none');350 }351 else {352 $("#add_od").attr('disabled','disabled');353 $("#add_os").attr('disabled','disabled');354 $("#add_od_overlay").show();355 $("#add_os_overlay").show();356 $("#add_od_overlay, #add_os_overlay").click(function(){357 alert("The lens type you have selected is not Bifocal nor Progressive.\nIf your prescription defines these fields please go back and select either Bifocal or Progressive lens type.\nOR\nYou can email the prescription.\nThankyou.");;358 })359 }360 });361 362 function compare(x, y){ //returns greater value363 var a=Math.abs(x);364 var b=Math.abs(y);365 return Math.max(a,b);366 }367 368 $(function(){369 $('.presc_detail').click(function(){ 370 var id = this.id;371 $("."+id).css('opacity',0);372 $("."+id).show();373 setTimeout(function(){374 var top = ($(window).height() - $("."+id).height())/2;375 $("."+id).css('margin-top',top);376 $("."+id).animate({377 opacity:1378 },600);379 },10)380 });381 })382 383 function remove_popup(popup){384 if(popup=='popup_presc_upload'){385 $("."+popup+" form")[0].reset();386 }387 if(popup=='popup_presc_entry'){388 $txtfields = $('.'+popup).find('input[type=text]')389 $txtfields.val('');390 $('#extraComment').val('');391 $('.'+popup+' select').each(function(){392 $('#'+this.id).val($('#'+this.id).find('option[selected]').val());393 })394 }395 $("."+popup).fadeOut(400);396 }397 398 function get_power(element){399 var id=element.id;400 populate_value();401 if(id=="power_od"){402// if(sph_od!=0 && sph_od!="PLANO" && sph_od!="SPH" && sph_od!="" && sph_od!=null && cyl_od!=0 && cyl_od!="PLANO" && cyl_od!="SPH" && cyl_od!="" && cyl_od!=null){403// if(sph_od!="" && sph_od!=null && cyl_od!="" && cyl_od!=null){404 power_od = calculate_power(sph_od, cyl_od);405 power_od = parseFloat(power_od).toFixed(2); //rounding off to two decimal406 $(element).attr('value',power_od)407// }408// else alert('Some of the values are missing. \nPower cannot be calculated');409 }410 else{411// if(sph_os!=0 && sph_os!="PLANO" && sph_os!="SPH" && sph_os!="" && sph_os!=null && cyl_os!=0 && cyl_os!="PLANO" && cyl_os!="SPH" && cyl_os!="" && cyl_os!=null){412// if(sph_os!="" && sph_os!=null && cyl_os!="" && cyl_os!=null){413 power_os = calculate_power(sph_os, cyl_os);414 power_os = parseFloat(power_os).toFixed(2); //rounding off to two decimal415 $(element).attr('value',power_os)416// }417// else alert('Some of the values are missing. \nPower cannot be calculated');418 }...

Full Screen

Full Screen

drugsdata.js

Source:drugsdata.js Github

copy

Full Screen

1<!--2var generic = ["CAPTOPRIL", "GLIBENCLAMIDE", "METFORMIN", "QUINAPRIL", "ASPIRIN", "AMLODIPINE",3 "LENTE INSULIN", "SOLUBLE INSULIN", "HYDROCHLOROTHIAZIDE", "NIFEDIPINE", "NIFEDIPINE SR", "PROPANOLOL",4 "METHYLDOPA", "FUROSEMIDE", "ATENOLOL", "AMITRIPTYLINE", "IBUPROFEN", "VITAMIN B CO", "PYRIDOXINE", 5 "LISINOPRIL", "HYDRALAZINE", "PARACETAMOL"];6var drugs = {};7drugs["AMLODIPINE"] = [["5MG", "OD"],8 ["10MG", "OD"]];9 10drugs["LISINOPRIL"] = [["10MG", "OD"],11 ["20MG", "OD"]];12drugs["GLIBENCLAMIDE"] = [["2.5MG", "OD"],13 ["2.5MG", "BD"],14 ["5MG", "OD"],15 ["5MG", "BD"],16 ["10MG", "OD"],17 ["10MG", "BD"]];18drugs["METFORMIN"] = [["500MG", "BD"],19 ["500MG", "OD"],20 ["500MG", "TDS"],21 ["750MG", "BD"],22 ["750MG", "OD"],23 ["750MG", "TDS"],24 ["850MG", "BD"],25 ["850MG", "OD"],26 ["850MG", "TDS"],27 ["1000MG", "BD"],28 ["1000MG", "OD"],29 ["1000MG", "TDS"]];30drugs["LENTE INSULIN"] = null;31drugs["SOLUBLE INSULIN"] = null;32drugs["CAPTOPRIL"] = [["6.25MG", "BD"],33 ["6.25MG", "TDS"],34 ["12.5MG", "BD"],35 ["12.5MG", "TDS"],36 ["25MG", "BD"],37 ["25MG", "TDS"],38 ["50MG", "BD"],39 ["50MG", "TDS"]];40drugs["QUINAPRIL"] = [["20MG", "OD"],41 ["40MG", "OD"]];42drugs["ASPIRIN"] = [["75MG", "OD"],43 ["150MG", "OD"],44 ["300MG", "OD"]];45drugs["NIFEDIPINE"] = [["10MG", "TDS"],46 ["20MG", "TDS"]];47drugs["NIFEDIPINE SR"] = [["10MG", "BD"],48 ["20MG", "BD"]];49drugs["HYDROCHLOROTHIAZIDE"] = [["12.5MG", "OD"],50 ["25MG", "OD"]];51drugs["PROPANOLOL"] = [["40MG", "BD"],52 ["40MG", "TDS"],53 ["80MG", "BD"],54 ["80MG", "TDS"],55 ["160MG", "BD"],56 ["160MG", "TDS"],57 ["240MG", "BD"],58 ["240MG", "TDS"],59 ["320MG", "BD"],60 ["320MG", "TDS"]];61drugs["METHYLDOPA"] = [["125MG", "BD"],62 ["125MG", "TDS"],63 ["250MG", "BD"],64 ["250MG", "TDS"],65 ["500MG", "BD"],66 ["500MG", "TDS"]];67 68drugs["FUROSEMIDE"] = [["120MG", "BD"],69 ["120MG", "OD"],70 ["20MG", "BD"],71 ["20MG", "OD"],72 ["40MG", "BD"],73 ["40MG", "OD"],74 ["60MG", "BD"],75 ["60MG", "OD"],76 ["80MG", "BD"],77 ["80MG", "OD"]];78drugs["ATENOLOL"] = [["50MG", "OD"],79 ["100MG", "OD"]];80drugs["AMITRIPTYLINE"] = [["25MG","NOCTE"],81 ["50MG", "NOCTE"]];82drugs["IBUPROFEN"] = [["400MG","TDS"]];83drugs["VITAMIN B CO"] = [["15MG","BD"]];84drugs["PYRIDOXINE"] = [["25MG","OD"],85 ["50MG", "OD"]];86drugs["HYDRALAZINE"] = [["25MG","OD"],87 ["25MG","BD"],88 ["50MG", "OD"],89 ["50MG", "BD"],90 ["100MG", "OD"],91 ["100MG", "BD"]];92drugs["PARACETAMOL"] = [["1G","TDS"],93 ["500MG", "TDS"]];...

Full Screen

Full Screen

vezbanja.js

Source:vezbanja.js Github

copy

Full Screen

1let s= 15;2let m= 21;3let odPonoci = s*60 + m ;4console.log ('Od ponoci je proslo ' + odPonoci + " minuta");5let doPonoci= 24 * 60 - odPonoci;6// let doPonoci = (24 - s) * 60 - m;7console.log('Do ponoci je ostalo: ' + doPonoci + ' minuta');8//zadatak 29let minOdPonoci = 921; // minOdPonoci = ___ * 60 + minSada10// minOdPonoci - minSada = ____ * 6011//(minOdPonoci - minSada) / 60 = __12let minSada = minOdPonoci % 60;13let satSada= (minOdPonoci - minSada) / 60;14console.log("Sada je" + satSada + ":" + minSada);15//Drugi nacin16// console.log(minOdPonoci / 60); -deljenje vraca tacan broj17// console.log(Math.floor(minOdPonoci/60)); - ceo broj manji ili jednak od rez18// console.log(Math.ceil(minOdPonoci / 60)); ceo veci broj ili jednak od rez19// console.log(Math.round(minOdPonoci/ 60)); ceo broj rezultat zaokruzivanja20let satSada2 = Math.floor(minOdPonoci/ 60);21let minSada2 = minOdPonoci % 60;22console.log("sada je " + satSada2+ ":" + minSada2);23// Zadatak 324let cenaRobe = 1750;25let novcanica = 2000;26let kusur = novcanica-cenaRobe;27console.log("Kusur koji treba da se vrati je " + kusur + ' Dinara');28let today = new Date();29let dd = String(today.getDate()).padStart(2, '0');30let mm = String(today.getMonth() + 1).padStart(2, '0'); 31let yyyy = today.getFullYear();32today = mm + '/' + dd + '/' + yyyy;33console.log('Danasnji datum je ' + today);34today = dd + '/' + mm + '/' + yyyy;35console.log('Druga verzija danasnjeg datuma je ' + today);36// let e = 50;37// let kurs = 117;38// let din = e* kurs;39// console.log("Razmenom iz evra u dinare smo dobili " + din + " din");40// kurs = 118;41// e= din / kurs;42// console.log(Math.floor(e));43// console.log("Razmenom iz dinara u evre smo dobili " + e + " evra");44let e = 200;45let kursEvri = 117.5782;46let evriUDinare = e * kursEvri;47console.log('Imamo ' + evriUDinare + 'dinara nakon razmene');48let novacDinari = 10000;49let dinariUEvre = novacDinari / kursEvri;50console.log('Imamo ' + dinariUEvre + ' evra nakon razmene');51// zadatak 752let kursDolari = 104.7281;53 let k1 = e * kursEvri;54 let k2 = k1 / kursDolari;55 console.log('Imamo' + k2 + ' dikara nakon razmene');56 let novacDolari = 200;57 58 let k3 = novacDolari *kursDolari /kursEvri;59 console.log('Imamo ' + k3 + ' evra nakon razmene');60//trenutno vreme i datum61let datum = new Date(); //datum postaje objekat koji sadrzi info. o trenutnom datumu i vremenu62let godina = datum.getFullYear();63let mesec = datum.getMonth() +1;64let datumUMesecu = datum.getDate();65let danUNedelji = datum.getDay();66console.log( 'Danas je ' + datumUMesecu + "." + mesec + '.' + godina );...

Full Screen

Full Screen

Order.js

Source:Order.js Github

copy

Full Screen

1var mongoose = require('mongoose');2// var OrderSchema = new mongoose.Schema({3// odCode: String,4// odUser: {},5// odTotal: Number,6// odController: {7// odToken: String,8// odStatus: String9// },10// odShip: {11// odShipWayBillBarcode: String,12// odShipWayBillDate: String,13// odShipOutDate: String,14// odTotalWeight: Number,15// odCost: Number,16// odWeightCode: String,17// odZone: String,18// odWeightBand: Number19// },20// odCart: [],21// odCartTotalAmount: Number,22// odPayStatus: {},23// odPayObj: {24// odDate: String,25// odPayMethod: String,26// odPayDate: String,27// odCardType: String,28// odCardNumber: String,29// odCVVC: String30// }31// });32var OrderSchema = new mongoose.Schema({33 odCode: String,34 uuidv1: String,35 odCreationDate: String,36 odUser: {},37 odTotal: Number,38 odCart: [],39 odCartTotalAmount: Number,40 controlObj: {41 odToken: String,42 odStatus: String43 },44 odShip: {45 odShipWayBillBarcode: String,46 odShipWayBillDate: String,47 odShipOutDate: String,48 odTotalWeight: Number,49 odCost: Number,50 odWeightCode: String,51 odZone: String,52 odWeightBand: Number53 },54 odPayObj: {}55});56// var OrderSchema = new mongoose.Schema({57// odStatus:String,58// odWayBill:{odBarcode:String,odWayBillDate:String},59// odUser:{}, 60// odc:String,61// odcc:[],62// odccc:Number,63// odcccc:{64// odDate: String,65// odPayMethod:String,66// odPayDate:String,67// odCardType:String,68// odCardNumber:String,69// odCVVC:String 70// }71// });72OrderSchema.methods.toJSON = function() {73 var order = this.toObject();74 return order;75};76var OrderCounterSchema = new mongoose.Schema({77 incrementId: String,78 seq: Number79});80var Ordercounter = mongoose.model('OrderCounter', OrderCounterSchema);81OrderSchema.pre('save', function(next) {82 var doc= this;83 Ordercounter.findOneAndUpdate({84 'incrementId': 'order'85 }, {86 $inc: {87 seq: 188 }89 }, function(err, item) {90 doc.odCode=item.seq;91 next();92 })93})...

Full Screen

Full Screen

group__sys__od.js

Source:group__sys__od.js Github

copy

Full Screen

1var group__sys__od =2[3 [ "od.h", "od_8h.html", null ],4 [ "OD_FLAGS_ADDRESS_DECIMAL", "group__sys__od.html#ga2ad71c26f98042cf532428cbf95b802b", null ],5 [ "OD_FLAGS_ADDRESS_HEX", "group__sys__od.html#gaef2e0a60ec72a3badb2ed330b1ecdf14", null ],6 [ "OD_FLAGS_ADDRESS_MASK", "group__sys__od.html#ga0efb79f150f2887ee6c78fa0fd28b58f", null ],7 [ "OD_FLAGS_ADDRESS_NONE", "group__sys__od.html#ga04c1607aee3ce76f0d1c85b25358d762", null ],8 [ "OD_FLAGS_ADDRESS_OCTAL", "group__sys__od.html#gaf5d6e2e8a69458f5aa25a33191536629", null ],9 [ "OD_FLAGS_BYTES_CHAR", "group__sys__od.html#gade903ebbdbd9b316a10cc0d8398b9472", null ],10 [ "OD_FLAGS_BYTES_DECIMAL", "group__sys__od.html#gaa394fb52e5b47a8ac877dd54b39c6540", null ],11 [ "OD_FLAGS_BYTES_HEX", "group__sys__od.html#ga307aaaae491f1553374bb99c0027f2e3", null ],12 [ "OD_FLAGS_BYTES_INT", "group__sys__od.html#gabaed5d94b40077200d7aa960feeb7281", null ],13 [ "OD_FLAGS_BYTES_MASK", "group__sys__od.html#gae1b155fcaa4042898e013cb941f5728e", null ],14 [ "OD_FLAGS_BYTES_OCTAL", "group__sys__od.html#gae84418cae6a1a1b042fc7938cf04110a", null ],15 [ "OD_FLAGS_BYTES_UINT", "group__sys__od.html#ga81a81d90174b9594fc3353c4c378f1f5", null ],16 [ "OD_FLAGS_LENGTH_1", "group__sys__od.html#ga3d43e8e4237267be0628a7fb41e54f77", null ],17 [ "OD_FLAGS_LENGTH_2", "group__sys__od.html#ga6bf63b75dad873daec384a07af6e8fb1", null ],18 [ "OD_FLAGS_LENGTH_4", "group__sys__od.html#ga835dc896d813fc9c3ec2430c51d5cca9", null ],19 [ "OD_FLAGS_LENGTH_8", "group__sys__od.html#ga1ddd4bc7aa6f395ff59e0eb43854e72c", null ],20 [ "OD_FLAGS_LENGTH_CHAR", "group__sys__od.html#ga2be95dcf968da2ba78e9547879f4d770", null ],21 [ "OD_FLAGS_LENGTH_LONG", "group__sys__od.html#ga1a27291d697cfb9b08a17b4dfb60a9da", null ],22 [ "OD_FLAGS_LENGTH_MASK", "group__sys__od.html#gad4ba90362dcd11b3b2b91064062f9d19", null ],23 [ "OD_FLAGS_LENGTH_SHORT", "group__sys__od.html#ga9eae93b165da5bd844ee961ac21d38a1", null ],24 [ "OD_WIDTH_DEFAULT", "group__sys__od.html#gae7f08b526f03ba3406db001709ddd295", null ],25 [ "od", "group__sys__od.html#ga0a460d7594feda89bc928ae2c2e678f1", null ],26 [ "od_hex_dump", "group__sys__od.html#ga767db72ee82d499f725f82bdb9463be9", null ]...

Full Screen

Full Screen

od_8h.js

Source:od_8h.js Github

copy

Full Screen

1var od_8h =2[3 [ "OD_FLAGS_ADDRESS_DECIMAL", "group__sys__od.html#ga2ad71c26f98042cf532428cbf95b802b", null ],4 [ "OD_FLAGS_ADDRESS_HEX", "group__sys__od.html#gaef2e0a60ec72a3badb2ed330b1ecdf14", null ],5 [ "OD_FLAGS_ADDRESS_MASK", "group__sys__od.html#ga0efb79f150f2887ee6c78fa0fd28b58f", null ],6 [ "OD_FLAGS_ADDRESS_NONE", "group__sys__od.html#ga04c1607aee3ce76f0d1c85b25358d762", null ],7 [ "OD_FLAGS_ADDRESS_OCTAL", "group__sys__od.html#gaf5d6e2e8a69458f5aa25a33191536629", null ],8 [ "OD_FLAGS_BYTES_CHAR", "group__sys__od.html#gade903ebbdbd9b316a10cc0d8398b9472", null ],9 [ "OD_FLAGS_BYTES_DECIMAL", "group__sys__od.html#gaa394fb52e5b47a8ac877dd54b39c6540", null ],10 [ "OD_FLAGS_BYTES_HEX", "group__sys__od.html#ga307aaaae491f1553374bb99c0027f2e3", null ],11 [ "OD_FLAGS_BYTES_INT", "group__sys__od.html#gabaed5d94b40077200d7aa960feeb7281", null ],12 [ "OD_FLAGS_BYTES_MASK", "group__sys__od.html#gae1b155fcaa4042898e013cb941f5728e", null ],13 [ "OD_FLAGS_BYTES_OCTAL", "group__sys__od.html#gae84418cae6a1a1b042fc7938cf04110a", null ],14 [ "OD_FLAGS_BYTES_UINT", "group__sys__od.html#ga81a81d90174b9594fc3353c4c378f1f5", null ],15 [ "OD_FLAGS_LENGTH_1", "group__sys__od.html#ga3d43e8e4237267be0628a7fb41e54f77", null ],16 [ "OD_FLAGS_LENGTH_2", "group__sys__od.html#ga6bf63b75dad873daec384a07af6e8fb1", null ],17 [ "OD_FLAGS_LENGTH_4", "group__sys__od.html#ga835dc896d813fc9c3ec2430c51d5cca9", null ],18 [ "OD_FLAGS_LENGTH_8", "group__sys__od.html#ga1ddd4bc7aa6f395ff59e0eb43854e72c", null ],19 [ "OD_FLAGS_LENGTH_CHAR", "group__sys__od.html#ga2be95dcf968da2ba78e9547879f4d770", null ],20 [ "OD_FLAGS_LENGTH_LONG", "group__sys__od.html#ga1a27291d697cfb9b08a17b4dfb60a9da", null ],21 [ "OD_FLAGS_LENGTH_MASK", "group__sys__od.html#gad4ba90362dcd11b3b2b91064062f9d19", null ],22 [ "OD_FLAGS_LENGTH_SHORT", "group__sys__od.html#ga9eae93b165da5bd844ee961ac21d38a1", null ],23 [ "OD_WIDTH_DEFAULT", "group__sys__od.html#gae7f08b526f03ba3406db001709ddd295", null ],24 [ "od", "group__sys__od.html#ga0a460d7594feda89bc928ae2c2e678f1", null ],25 [ "od_hex_dump", "group__sys__od.html#ga767db72ee82d499f725f82bdb9463be9", null ]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Protractor Demo App', function() {2 it('should add one and two', function() {3 element(by.model('first')).sendKeys(1);4 element(by.model('second')).sendKeys(2);5 element(by.id('gobutton')).click();6 });7});8describe('Protractor Demo App', function() {9 it('should add one and two', function() {10 element(by.model('first')).sendKeys(1);11 element(by.model('second')).sendKeys(2);12 element(by.id('gobutton')).click();13 });14});15describe('Protractor Demo App', function() {16 it('should add one and two', function() {17 element(by.model('first')).sendKeys(1);18 element(by.model('second')).sendKeys(2);19 element(by.id('gobutton')).click();20 });21});22describe('Protractor Demo App', function() {23 it('should add one and two', function() {24 element(by.model('first')).sendKeys(1);25 element(by.model('second')).sendKeys(2);26 element(by.id('gobutton')).click();27 });28});29describe('Protractor Demo App', function() {30 it('should add one and two', function() {31 element(by.model('first')).sendKeys(1);32 element(by.model('second

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Protractor Demo App', function() {2 it('should add one and two', function() {3 element(by.model('first')).sendKeys(1);4 element(by.model('second')).sendKeys(2);5 element(by.id('gobutton')).click();6 });7});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Protractor Demo App', function() {2 it('should add one and two', function() {3 element(by.model('first')).sendKeys(1);4 element(by.model('second')).sendKeys(2);5 element(by.id('gobutton')).click();6 });7});8describe('Protractor Demo App', function() {9 it('should add one and two', function() {10 element(by.model('first')).sendKeys(1);11 element(by.model('second')).sendKeys(2);12 element(by.id('gobutton')).click();13 });14});15describe('Protractor Demo App', function() {16 it('should add one and two', function() {17 element(by.model('first')).sendKeys(1);18 element(by.model('second')).sendKeys(2);19 element(by.id('gobutton')).click();20 });21});22describe('Protractor Demo App', function() {23 it('should add one and two', function() {24 element(by.model('first')).sendKeys(1);25 element(by.model('second')).sendKeys(2);26 element(by.id('gobutton')).click();27 });28});29describe('Protractor Demo App', function() {30 it('should add one and two', function() {31 element(by.model('first')).sendKeys(1);32 element(by.model('second')).sendKeys(2);33 element(by.id('gobutton')).click();34 expect(element(by.binding('latest')).getText

Full Screen

Using AI Code Generation

copy

Full Screen

1var Od = require('od');2describe('Protractor Demo App', function() {3 it('should have a title', function() {4 expect(browser.getTitle()).toEqual('AngularJS — Superheroic JavaScript MVW Framework');5 });6});7[MIT](

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Protractor Demo App', function() {2 it('should have a title', function() {3 expect(browser.getTitle()).toEqual('Super Calculator');4 });5});6describe('Protractor Demo App', function() {7 it('should add one and two', function() {8 element(by.model('first')).sendKeys(1);9 element(by.model('second')).sendKeys(2);10 element(by.id('gobutton')).click();11 });12});13describe('Protractor Demo App', function() {14 it('should add one and two', function() {15 element(by.model('first')).sendKeys(1);16 element(by.model('second')).sendKeys(2);17 element(by.id('gobutton')).click();18 });19});

Full Screen

Using AI Code Generation

copy

Full Screen

1var Od = require('Od');2describe('test', function() {3 beforeEach(function() {4 });5 it('should work', function() {6 Od('query').sendKeys('protractor');7 Od('search').click();8 expect(browser.getCurrentUrl()).toContain('protractor');9 });10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var Od = require('od');2var ptor = protractor.getInstance();3var Od = new Od(ptor);4Od.click('button');5### .click(selector, [options])6### .doubleClick(selector, [options])7### .rightClick(selector, [options])8### .dragAndDrop(sourceSelector, destinationSelector, [options])9### .sendKeys(selector, text, [options])10### .clear(selector, [options])11### .selectByValue(selector, value, [options])12### .selectByIndex(selector, index, [options])13### .selectByVisibleText(selector, text, [options])14### .moveTo(selector, [options])15### .scrollTo(selector, [options])16### .scrollToTop([options])17### .scrollToBottom([options])18### .scrollToRight([options])19### .scrollToLeft([options])20### .scrollToElement(selector, [options])21### .scrollToElementTop(selector, [options])22### .scrollToElementBottom(selector, [options])23### .scrollToElementRight(selector, [options])24### .scrollToElementLeft(selector, [options])25### .scrollToElementCenter(selector, [options])26### .scrollToElementMiddle(selector, [options])27### .scrollToElementLeftEdge(selector, [options])

Full Screen

Selenium Protractor Tutorial

Protractor is developed by Google Developers to test Angular and AngularJS code. Today, it is used to test non-Angular applications as well. It performs a real-world user-like test against your application in a real browser. It comes under an end-to-end testing framework. As of now, Selenium Protractor has proved to be a popular framework for end-to-end automation for AngularJS.

Let’s talk about what it does:

  • Protractor, built on WebDriver JS (Selenium), offers Angular-specific locator strategies.
  • It helps to construct automated tests for applications other than Angular JS and is not just intended to test AngularJS applications.
  • Page object design pattern is supported by Protractor Selenium, which improves in producing clear and legible code. Automation testers need to write clean code.
  • Frameworks like Jasmine, Cucumber, and others are fully integrated with Protractor.

Chapters:

Protractor is a JavaScript framework, end-to-end test automation framework for Angular and AngularJS applications.

Protractor Selenium provides new locator methods that actually make it easier to find elements in the DOM.

Two files are required to execute Protractor Selenium tests for end-to-end automation: Specs & Config. Go through the link above to understand in a better way.

To carry out extensive, automated cross browser testing, you can't imagine installing thousands of the available browsers on your own workstation. The only way to increase browser usage is through remote execution on the cloud. To execute your automation test scripts across a variety of platforms and browser versions, LambdaTest offers more than 3000 browsers.

We recommend Selenium for end-to-end automation for AngularJS because both are maintained and owned by Google, and they build JavaScript test automation framework to handle AngularJS components in a way that better matches how developers use it.

For scripting, selenium locators are essential since if they're off, your automation scripts won't run. Therefore, in any testing framework, these Selenium locators are the foundation of your Selenium test automation efforts.

To make sure that your Selenium automation tests function as intended, debugging can be an effective option. Check the blog to know more.

Get familiar with global variables that are majorly used in locating the DOM elements with examples for better understanding of these Selenium locators in protractor.

If you are not familiar with writing Selenium test automation on Protractor, here is a blog for you to get you understand in depth.

Selenium tests are asynchronous and there are various reasons for a timeout to occur in a Protractor test. Find out how to handle timeouts in this Protractor tutorial.

In this Protractor tutorial, learn how to handle frames or iframes in Selenium with Protractor for automated browser testing.

Handle alerts and popups in Protractor more efficiently. It can be confusing. Here's a simple guide to understand how to handle alerts and popups in Selenium.

Run Protractor automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful