Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3248 chandransh 1
#!/bin/bash
2
 
3318 chandransh 3
if [ $# -lt 3 ]
3248 chandransh 4
then
5
	echo "Usage: $0 <from> <passwd> <email> [<email> ...]"
6
	exit  1
7
fi
8
 
9
# resolve links - $0 may be a softlink
10
PRG="$0"
11
 
12
while [ -h "$PRG" ]; do
13
  ls=`ls -ld "$PRG"`
14
  link=`expr "$ls" : '.*-> \(.*\)$'`
15
  if expr "$link" : '/.*' > /dev/null; then
16
    PRG="$link"
17
  else
18
    PRG=`dirname "$PRG"`/"$link"
19
  fi
20
done
21
 
22
# Get standard environment variables
23
PRGDIR=`dirname $(readlink -f "$PRG")`
24
PYTHON_DIR=${PRGDIR}/../PyProj/src/shop2020/utils
25
 
26
DATE=`date +%Y-%b-%d`
3276 chandransh 27
mysql -uroot -pshop2020 catalog -e " select i.id as ID, i.brand as Brand, i.model_number as 'Model Number', i.model_name as 'Model Name', i.color as Color, sum(c.availibility) as Availability from item i left join currentinventorysnapshot c on c.item_id = i.id where i.product_group = 'Handsets' and i.status =3 group by i.id having sum(c.availibility) >= 2 order by i.brand, i.model_number, i.color" > /tmp/items-deliverable-on-next-day.${DATE}.csv
28
mysql -uroot -pshop2020 catalog -e " select i.id as ID, i.brand as Brand, i.model_number as 'Model Number', i.model_name as 'Model Name', i.color as Color, sum(c.availibility) as Availability from item i left join currentinventorysnapshot c on c.item_id = i.id where i.product_group = 'Handsets' and i.status =3 group by i.id having sum(c.availibility) < 2 order by i.brand, i.model_number, i.color" > /tmp/items-not-deliverable-on-next-day.${DATE}.csv
3319 chandransh 29
mysql -uroot -pshop2020 catalog -e " select i.id as ID, i.brand as Brand, i.model_number as 'Model Number', i.model_name as 'Model Name', i.color as Color, sum(c.availibility) as Availability from item i left join currentinventorysnapshot c on c.item_id = i.id where i.product_group = 'Handsets' and i.status in (2,6) group by i.id order by i.brand, i.model_number, i.color" > /tmp/items-marked-out-of-stock.${DATE}.csv
3248 chandransh 30
 
31
#Email the two report files.
32
 
33
FROM=$1
34
PASSWD=$2
35
 
36
shift 2
37
 
3317 chandransh 38
TO_LIST=""
3248 chandransh 39
while (( "$#" ))
40
do
3317 chandransh 41
	TO_LIST="${TO_LIST} -t $1"
3248 chandransh 42
	shift
43
done
44
 
3317 chandransh 45
python ${PYTHON_DIR}/EmailAttachmentSender.py -f ${FROM} -p ${PASSWD} ${TO_LIST} -s "Item stock reports" -a /tmp/items-deliverable-on-next-day.${DATE}.csv -a /tmp/items-not-deliverable-on-next-day.${DATE}.csv -a /tmp/items-marked-out-of-stock.${DATE}.csv
46
 
47
rm /tmp/items-deliverable-on-next-day.${DATE}.csv /tmp/items-not-deliverable-on-next-day.${DATE}.csv /tmp/items-marked-out-of-stock.${DATE}.csv